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

Model identity, architecture, pooling, quantisation and runtime
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

Each run embeds the passage pool once (cached until you edit it), embeds your question in ~10–50 ms, and ranks passages three ways side by side: dense (Multi-QA MiniLM dot product), lexical (Okapi BM25 keyword baseline) and hybrid (reciprocal rank fusion).

Backend · dtype–
Query latency–
Pool latency–
Query tokens–
Longest passage–
L2 norm range–
NaN count–
Dense ∩ BM25 @K–

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.

WordPiece tokens–
L2 norm–
Min / max dim–
Score vs query–

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.

Use-case ladder

How it works

The worker loads the real feature-extraction pipeline and enforces the model card's mean pooling + L2 normalisation:

Show the code — off-main-thread mean-pooled, normalised embedding in worker.js
Show the code — the BM25 lexical baseline the dense ranking is compared against

References