feature-extraction · text · WASM q8 · 22.97 MB · 384-d · Apache-2.0
Multi-QA MiniLM — find the passage that answers the question
A 6-layer, 22.7M-parameter MiniLM bi-encoder trained on 215 million question–answer pairs (StackExchange, WikiAnswers, Natural Questions, GooAQ, MS MARCO and more). It maps questions and answer passages into the same 384-dimensional unit-vector space, so the passage with the highest dot product is the most likely answer — computed privately on your device with WebAssembly.
At a glance
| Upstream model | sentence-transformers/multi-qa-MiniLM-L6-cos-v1 |
|---|---|
| Browser ONNX build | Xenova/multi-qa-MiniLM-L6-cos-v1 · onnx/model_quantized.onnx |
| Task / pipeline | feature-extraction with { pooling: "mean", normalize: true } → one 384-d unit vector per text |
| Architecture | BertModel (MiniLM-L6) · 6 layers · 12 heads · hidden 384 · 30,522 WordPiece vocab · [CLS]=101 / [SEP]=102 |
| Scoring | Vectors are L2-normalised, so cosine similarity = dot product (the model card recommends either) |
| Sequence length | 512 WordPiece tokens maximum (longer text is truncated); trained on inputs up to 250 word pieces |
| Quantisation & size | q8 · 22.97 MB ONNX + 0.71 MB tokenizer, cached by Transformers.js after first download |
| Backend | WebAssembly (CPU, shared Transformers.js 3.7.5) — no WebGPU needed, runs inside a Web Worker |
| License | Apache-2.0 |
Interactive QA passage retriever
Dense · Multi-QA MiniLM
score = q · p (cosine of unit vectors)
Lexical · BM25
k1 = 1.2, b = 0.75, stopwords removed
Hybrid · RRF
Σ 1 / (60 + rank) over both lists
See inside: tokens, pooling and the 384-d vector
Text is lower-cased and split into WordPiece tokens wrapped in [CLS] … [SEP]. The
6-layer encoder produces one 384-d vector per token; Multi-QA MiniLM averages them over the attention mask
(mean pooling) and divides by the L2 norm, so every vector below has length 1.0000.
Tokens ([CLS]/[SEP] highlighted, ## = sub-word continuation):
First 96 of 384 dimensions (indigo = positive, amber = negative):
Why a QA-trained embedder?
General sentence embedders learn "these two sentences mean the same thing". Multi-QA MiniLM was trained with a contrastive loss on question → answer pairs, so it learns "this passage answers that question" — even when the two share almost no words. That asymmetry is exactly what search boxes, help centres and retrieval-augmented generation need, and at 22.97 MB it is small enough to index a few thousand passages entirely in a browser tab.
- Private semantic search over notes, docs or tickets with zero server calls.
- RAG retrieval stage that feeds a local reader or LLM only the relevant passages.
- Hybrid ranking: fuse with BM25 to keep exact-keyword precision (product codes, error IDs).
Use-case ladder
Basics · Question-vs-answer asymmetry
Compare question, statement and keyword phrasings; watch BM25 fall into keyword traps; inspect the 512-token budget and cosine ≡ dot.
Practical · Helpdesk QA search engine
Index an IT, HR or product knowledge base — or drop your own .txt/.md/.json/.csv — then search with MMR diversity, thresholds and CSV/JSON export.
Wild · QA constellation & failure lab
Fly a query through a keyboard-navigable 2-D map of passages and stress-test retrieval with paraphrases, typos and adversarial rewrites.
Multi-model · 2-stage open-book QA
Multi-QA MiniLM retrieves the top passages, then TinyRoBERTa-SQuAD2 extracts the exact answer span — or abstains when the corpus can't answer.
How it works
The worker loads the real feature-extraction pipeline and enforces the model card's mean pooling + L2 normalisation: