Skip to content

MPNet / all-mpnet-base-v2

Model guide index

Overview and status

Registry type: mpnet. The encoder implements MPNet relative-position buckets, bidirectional attention, mean pooling, normalization, and single-vector retrieval. sentence-transformers/all-mpnet-base-v2 is the primary checkpoint candidate. Native loading and synthetic execution are implemented. The selected checkpoint now passes real native embedding and applicable interface checks; see the current support record.

Model Architecture

The diagram follows the native implementation. Layer counts, widths, head counts, and input sizes come from the checkpoint configuration; this is an architecture map, not an additional support or qualification claim.

Token IDs → token + position embeddings → LayerNorm
                    ↓
┌──────────────── Bidirectional encoder × L ─────────────────┐
│ Multi-head attention + relative-position bias              │
│ Residual/LayerNorm → feed-forward → residual/LayerNorm     │
└────────────────────────────────────────────────────────────┘
                    ↓
          Padding-aware masked mean pooling
                    ↓
     Optional L2 normalization → one vector per text
                    └→ Cosine similarity for sentence pairs

Papers and upstream references

Paper: MPNet: Masked and Permuted Pre-training for Language Understanding. Sentence-embedding background: Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks.

Masked/permuted objectives describe upstream pretraining, not extra inference branches. The local sentence-embedding path uses the pooling shown above.

Installation and assets

Install python -m pip install -e . from the repository root using Python 3.10+. Execution needs Apple Silicon/Metal. Keep config.json, safetensors weights/index, tokenizer.json, tokenizer metadata, sentence_bert_config.json, and 1_Pooling/config.json. Relative-position weights and special-token IDs must match the MPNet configuration; a BERT checkpoint is not a substitute.

CLI and Python examples

Use ordinary sentences. These candidate examples may download weights; pin an immutable revision for reproducibility.

mlx-one inspect sentence-transformers/all-mpnet-base-v2
mlx-one embed sentence-transformers/all-mpnet-base-v2 "MLX uses unified memory." \
  --max-length 384
from mlx_one import embed

result = embed(
    "sentence-transformers/all-mpnet-base-v2",
    ["How does unified memory work?", "CPU and GPU share one memory pool."],
    max_length=384,
    batch_size=2,
)
query, document = result.embeddings
print(sum(left * right for left, right in zip(query, document)))

The dot product is cosine similarity when the outputs are normalized. The service returns one vector per input; it does not return token embeddings for late interaction.

Settings and troubleshooting

  • Set max_length explicitly. The native profile's sentence limit is 384 tokens, whereas the generic service default is 8192; the loaded config governs validation.
  • The native profile is 768 dimensions. Arbitrary reduced dimensions are unsupported; omit dimensions or use the native width.
  • Query instructions/chat markers are not automatically applied to this family.
  • Missing pooling metadata or relative-attention tensors requires a complete matching Sentence Transformer snapshot.
  • MPNet is an encoder workflow: generation KV, server APC, and block decoding are not embedding capabilities.

Implementation and validation

See configuration, model, weights, retrieval loading, architecture tests, and synthetic Metal tests.

pytest -q tests/test_native_sentence_transformers_architectures.py
MLX_ONE_RUN_MLX_TESTS=1 pytest -q tests/test_native_sentence_transformers_mlx.py

See qualification levels and the family backlog.


Edit this page