← All models

feature-extraction · text · WASM · ~105 MB

all-mpnet-base-v2 — a strong all-purpose sentence embedding

all-mpnet-base-v2 fine-tunes Microsoft’s MPNet — pre-trained with a permutation objective that blends masked and autoregressive language modelling — over a billion paired sentences, and turns each sentence into a 768-number point in meaning space. No query prefix is required: questions and documents use the same mean-pooling recipe (symmetric). Build a live similarity matrix, search by meaning, and inspect the real vector geometry. Nothing leaves your device.

At a glance

Canonical modelsentence-transformers/all-mpnet-base-v2
Browser ONNX mirrorXenova/all-mpnet-base-v2 @ e086c5e — a q8 ONNX conversion of the canonical weights, pinned (immutable)
Lineagecanonical sentence-transformers/all-mpnet-base-v2 (Apache-2.0) → browser mirror Xenova/all-mpnet-base-v2 → q8 (int8) quantized export. The mirror inherits the canonical Apache-2.0 license.
Task / pipelinefeature-extraction (the card’s public tag is sentence-similarity)
ArchitectureMPNet encoder (permutation language modelling) → 768-dimensional sentence embedding; inputs longer than the canonical 384-token limit are truncated
Poolingattention-mask-aware mean pooling, then L2 normalization; no instruction prefix (symmetric)
ONNX dtypeint8-quantized (q8) — onnx/model_quantized.onnx, 110,086,122 bytes (~105 MB). Quantization is lossy compression, not a numerically exact copy.
BackendWebAssembly (no WebGPU required)
Download~105 MB quantized ONNX, cached after first load
LicenseApache-2.0 (canonical; inherited by the mirror)
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

Put one sentence per line, then embed. The matrix shows the cosine similarity between every pair (1.00 = identical direction). The scatter is a 2D PCA projection of the 768-d vectors — a flattened map where near = similar. Then type a query below to rank the lines by meaning. Cosine is this model’s uncalibrated relatedness score (higher = more similar); it is not a universal threshold or calibrated probability.

Cosine similarity matrix

2D map (PCA)

See inside — the vector, and why the model choice matters

The encoder emits one 768-number vector per token. To get a single vector per sentence, all-mpnet-base-v2 mean-pools those token vectors (mask-aware) and L2-normalizes, so every sentence becomes a unit-length arrow and cosine similarity is a plain dot product. Pick a sentence to see its real vector and its pre-normalization magnitude.

Embed some sentences above to inspect a vector.

Why it matters

Embeddings are the quiet workhorse behind search, recommendations, deduplication, clustering, and retrieval-augmented generation. all-mpnet-base-v2 is a long-standing strong all-purpose English sentence embedder on the sentence-transformers leaderboards. Its geometry tends to separate meaning sharply (unrelated sentences often score near zero rather than bunching together). When you want a strong general-purpose sentence vector and can spare a ~105 MB download, it is a sensible default.

Use cases

Basics

Do two lines mean the same thing? Read one real cosine-similarity score.

Practical

Semantic search, exploratory clustering, and classify-by-nearest-label with abstention.

Wild

Embedding arithmetic on a curated vocabulary: A − B + C ≈ ?

Multi-model

MPNet retrieves a shortlist by meaning, then a cross-encoder reranker re-scores the top hits.

How the API works

Feature-extraction plus the pooling discipline is the whole recipe — and note there is no prefix:

import { pipeline } from "@huggingface/transformers";

const extract = await pipeline(
  "feature-extraction",
  "Xenova/all-mpnet-base-v2",
  { dtype: "q8" }, // downloads + caches ~105 MB once
);

// MPNet uses MEAN pooling and needs NO instruction prefix — embed query and doc identically:
const out = await extract(["how do I sign in?", "the login page rejects my password"], {
  pooling: "mean",
  normalize: true,
});
const [q, d] = out.tolist();

// unit-length vectors → cosine similarity is just the dot product:
const sim = q.reduce((s, x, i) => s + x * d[i], 0); // higher — more similar

This page loads the browser-ready Xenova/all-mpnet-base-v2 ONNX mirror (a q8 conversion of sentence-transformers/all-mpnet-base-v2) pinned to a fixed revision, and asks the worker for the un-normalized pooled vectors so “See inside” can show the real pre-normalization magnitude, then normalizes them in JS. Inference runs in a Web Worker, so the matrix, projection and comparison never jank the page.

References