sentence-similarity Β· text Β· 50+ languages Β· WASM q8 Β· 295.7 MB Β· Apache-2.0

paraphrase-multilingual-mpnet-base-v2

Map sentences & paragraphs across 50+ languages into a single shared 768-dimensional meaning space locally in your browser. Distilled from English paraphrase-mpnet-base-v2 into an xlm-roberta student (250,002 SentencePiece vocab, mean pooling + L2 norm) with zero server calls.

At a glance

Upstream model sentence-transformers/paraphrase-multilingual-mpnet-base-v2
Browser ONNX mirror Xenova/paraphrase-multilingual-mpnet-base-v2
Task / pipeline sentence-similarity (Transformers.js pipeline task: feature-extraction)
Architecture XLMRobertaModel (model_type: "xlm-roberta", 12 layers Β· 12 heads Β· 768 hidden Β· 3072 FFN) distilled from paraphrase-mpnet-base-v2 Β· 250,002 SentencePiece vocab Β· max_position_embeddings: 514 (model_max_length: 512; SBERT trained max_seq_length: 128)
Pooling recipe Attention-mask-aware mean pooling (pooling: "mean", 1_Pooling/config.json) + L2 unit normalization Β· symmetric (no query/passage prefix required)
Quantization & size q8 (onnx/model_quantized.onnx 278,647,663 B = 278.65 MB + tokenizer.json 17,082,913 B = 17.08 MB + configs 1,449 B = 295.7 MB first-visit total, 282.0 MiB)
Runtime & backend Shared @huggingface/transformers@3.7.5 via lib/webai.js on WebAssembly (wasm) in a dedicated module Web Worker
License Apache-2.0
Web APIs WebAssembly, Web Workers, Cache Storage, Canvas 2D, File & Clipboard APIs

Run it β€” 50+ Language Sentence Similarity & Semantic Search

Initialise paraphrase-multilingual-mpnet-base-v2 above to embed sentences locally.

Backend / dtype–
Latency–
Vectors / dim–
Mean pre-norm β€–v‖–
NaN count–
Parity max |Ξ”|–

Cosine similarity matrix

Click any cell to inspect exact pair similarity and script pairing.

Selected pair: Click any cell in the cosine matrix to inspect it.

2D PCA semantic constellation

Projects the 768-d unit vectors onto their top 2 principal components.

Ranked semantic search hits

See inside β€” 768-d mean-pooled vector & 250k SentencePiece tokens

XLMRobertaModel outputs one 768-number vector per subword token (including <s> and </s>). Mask-aware mean pooling averages those vectors before L2 normalization. Pick any embedded sentence below to inspect its real pre-norm magnitude, top active dimensions, 96-dim signed strip, and SentencePiece pieces.

Dimensions768
Pre-norm β€–v‖–
Post-norm β€–v‖–
Script / tokens–
UNK count–
250k XLM-R SentencePiece subword tokens appear after embedding.

First 96 of 768 normalized dimensions (indigo = positive, amber = negative):

Why it matters

Instead of training separate embedding models for every language, paraphrase-multilingual-mpnet-base-v2 aligns 50+ languages into the exact same 768-d coordinate space using multilingual knowledge distillation. A customer query written in Spanish, Japanese, Arabic, or Hindi lands right next to English documentation.

Use-case ladder

Wild

6-Probe Stress Lab & 2D Semantic Drift

Test negation/antonym traps, role reversals, code-switching, and trace live multilingual perturbations across a frozen 6-anchor PCA constellation.

How the API works & inspect source

Show the code Β· worker.js β€” embed()
Show the code Β· mpnet-multi-core.mjs β€” fitPca2D()

References