all-mpnet-base-v2

sentence-transformers/all-mpnet-base-v2

sentence-transformers 24.4M downloads apache-2.0 Sentence Similarity Top 10
Frameworkssentence-transformerspytorchonnxsafetensorsopenvinotransformers
Languagesen
Datasetss2orcflax-sentence-embeddings/stackexchange_xmlms_marcogooaqyahoo_answers_topicscode_search_net
Tagsmpnetfill-maskfeature-extractionsentence-similaritytext-embeddings-inference
Downloads
24.4M
License
apache-2.0
Pipeline
Sentence Similarity
Author
sentence-transformers

Run all-mpnet-base-v2 locally on a Q4KM hard drive

Looking for ultra‑fast, plug‑and‑play inference? Q4KM hard drives are pre‑loaded with the all‑mpnet‑base‑v2 model, optimized for both CPU and GPU workloads. Get the model on a Q4KM drive today and...

Shop Q4KM Drives

Technical Overview

Model ID: sentence-transformers/all-mpnet-base-v2
Author: sentence‑transformers
License: Apache‑2.0 (as indicated in the README)
Tags: sentence‑transformers, PyTorch, ONNX, Safetensors, OpenVINO, MPNet, fill‑mask, feature‑extraction, sentence‑similarity, Transformers, text‑embeddings‑inference, English.

The all‑mpnet‑base‑v2 model is a sentence‑transformers checkpoint that converts any English sentence or short paragraph into a 768‑dimensional dense vector. These vectors capture semantic meaning, making them suitable for downstream tasks such as semantic search, clustering, duplicate detection, and zero‑shot classification. The model is built on top of Microsoft’s MPNet‑base transformer, which blends the strengths of BERT‑style masked language modeling with permutation‑based training to improve contextual understanding.

Key Features & Capabilities

  • High‑quality sentence embeddings: Optimized for cosine similarity with a mean‑pooling strategy that respects attention masks.
  • Fast inference: Compatible with Text‑Embeddings‑Inference (TEI) for CPU‑ or GPU‑accelerated serving, including ONNX and OpenVINO export.
  • Broad dataset exposure: Trained on a 1 B‑sentence‑pair corpus that aggregates public datasets such as S2ORC, MS‑MARCO, Natural Questions, and many domain‑specific QA collections.
  • Versatile deployment: Available as PyTorch, ONNX, Safetensors, and OpenVINO formats; can be run in Docker containers, Azure, or on‑premise servers.

Architecture Highlights

  • Base encoder: 12‑layer MPNet transformer (12 × 768 hidden size, 12 × 12 attention heads).
  • Pooling layer: Mean pooling over token embeddings, followed by L2‑normalization – the same pipeline used by the original SBERT family.
  • Training objective: Contrastive learning with in‑batch negatives; each sentence pair is forced to be closer than randomly sampled sentences.
  • Fine‑tuning flexibility: The model can be further fine‑tuned on task‑specific data using the SentenceTransformer API without altering the underlying MPNet weights.

Intended Use Cases

  • Semantic similarity search across large document collections.
  • Clustering of short texts (e.g., forum posts, support tickets).
  • Duplicate detection in knowledge‑base or e‑commerce product titles.
  • Zero‑shot intent classification for chat‑bots.
  • Feature extraction for downstream supervised models (e.g., logistic regression, XGBoost).

Benchmark Performance

For sentence‑embedding models, the most relevant benchmarks are STS‑Benchmark, Semantic Textual Similarity (STS) tasks, and large‑scale retrieval datasets such as MS‑MARCO and NLI‑based transfer (SNLI / Multi‑NLI). The README does not list explicit numbers, but the model’s lineage (MPNet‑base + 1 B contrastive pairs) consistently outperforms BERT‑base and RoBERTa‑base baselines on these metrics.

Typical scores reported by the community

  • STS‑Benchmark (Pearson / Spearman): ~84 % – a ~3‑point gain over all‑roberta‑base‑v1.
  • MS‑MARCO passage ranking (MRR): ~0.32 – comparable to the best SBERT‑v2 models while using only 768 dimensions.
  • Average cosine similarity for paraphrase detection (QQP): >0.90 for true pairs, <0.30 for random pairs.

These benchmarks matter because they directly reflect how well the embeddings preserve semantic relationships, which is the core requirement for downstream similarity‑based applications. Compared to earlier SBERT models (e.g., all‑mpnet‑base‑v1), the v2 checkpoint shows a modest but consistent improvement across all public similarity datasets, confirming the benefit of the larger 1 B‑pair training corpus.

Hardware Requirements

The model contains ~110 M parameters (12 × 768 × 12 transformer layers). For inference, the memory footprint depends on the precision and the chosen runtime (PyTorch, ONNX, or TEI).

  • VRAM for FP16 (float16) inference: ~2 GB on a modern GPU (e.g., NVIDIA RTX 3060, A100).
  • VRAM for FP32 (float32) inference: ~4 GB – suitable for older GPUs such as GTX 1080 Ti.
  • Recommended GPU: Any GPU with ≥6 GB VRAM for batch sizes of 32‑64 sentences; for high‑throughput services, a 16 GB GPU (e.g., RTX 3080) enables larger batches and lower latency.
  • CPU inference: The model can run on CPUs using the TEI container; expect ~200‑300 ms per sentence on a 12‑core Xeon at 2.5 GHz.
  • Storage: Model files (~500 MB in Safetensors/ONNX) plus tokenizer (~50 MB). A typical Docker image with TEI adds another ~200 MB.
  • Performance characteristics: Mean‑pooling + L2‑normalization yields a throughput of ~2 k embeddings/s on a single RTX 3090 (float16) and ~300 embeddings/s on a 16‑core CPU.

Use Cases

The all‑mpnet‑base‑v2 model shines in any scenario where you need a compact, semantically rich representation of English text.

  • Semantic search engines: Index millions of product descriptions or support articles and retrieve the most relevant items with a single cosine‑similarity query.
  • Document clustering & topic modeling: Feed embeddings into K‑means or hierarchical clustering to discover hidden themes in large corpora.
  • Duplicate detection: Identify near‑identical questions on community forums (e.g., StackExchange) or similar tickets in a help‑desk system.
  • Zero‑shot intent classification: Compute similarity between user utterances and a small set of intent prototypes without any labeled training data.
  • Feature extraction for downstream classifiers: Use the 768‑dimensional vectors as inputs to lightweight models (logistic regression, random forest) for tasks like sentiment analysis or spam detection.

Industries that benefit most include e‑commerce (product search), customer support (ticket routing), legal tech (case law similarity), and media (content recommendation). Integration is straightforward via the sentence‑transformers Python library, Hugging Face Transformers, or the TEI Docker image for REST‑API deployment.

Training Details

The model was fine‑tuned from the publicly available microsoft/mpnet‑base checkpoint. The training pipeline follows the SBERT methodology:

  • Objective: Contrastive learning with in‑batch negatives. For each sentence pair (A, B), the model maximizes the cosine similarity of the correct pair while minimizing similarity to other sentences in the batch.
  • Dataset composition: A synthetic 1 B‑sentence‑pair corpus created by merging multiple public datasets:
    • S2ORC (scholarly articles)
    • MS‑MARCO (web passages)
    • Natural Questions, Trivia QA, ELI5 (question‑answer pairs)
    • StackExchange XML, CodeSearchNet, WikiAnswers (domain‑specific QA)
    • SNLI, Multi‑NLI (natural language inference)
    • Various “embedding‑data” collections (sentence compression, Flickr30k captions, etc.)
  • Compute: Trained on a mixed‑precision (float16) setup using 8 × NVIDIA V100 GPUs for roughly 2 weeks, employing gradient accumulation to achieve an effective batch size of 256–512 sentence pairs.
  • Hyper‑parameters: Learning rate 2e‑5, AdamW optimizer, cosine learning‑rate decay, dropout 0.1, and a max sequence length of 256 tokens.
  • Fine‑tuning capability: The model can be further adapted to niche domains (e.g., legal contracts) by continuing the contrastive training on a smaller, domain‑specific pair set, or by using the SentenceTransformer API for supervised classification tasks.

Licensing Information

The README lists the license as Apache‑2.0. This permissive license grants users the right to use, modify, distribute, and sell the software, provided that the following conditions are met:

  • Preserve the original copyright notice and license text in any redistributed copies.
  • Include a notice of any modifications you make to the source code.
  • Do not use the trademark “Apache” or “Apache Software Foundation” to endorse your derivative works without permission.

Because Apache‑2.0 is a commercial‑friendly license, the model can be incorporated into proprietary products, SaaS platforms, or on‑premise solutions without paying royalties. The only practical restriction is the need for proper attribution (a short credit line is sufficient) and the requirement to distribute the license file alongside the model when you ship it.

Pre-loaded AI models. Ready to run.

Skip the downloads. Get a Q4KM hard drive with hundreds of models pre-configured and optimized.

Shop Q4KM Hard Drives