basics · feature-extraction · Xenova/multi-qa-MiniLM-L6-cos-v1 · WASM q8 · 22.97 MB
Inside Multi-QA MiniLM: question-vs-answer asymmetry & the token budget
Four small experiments, each running the real model in a Web Worker: how phrasing changes the score, why keyword search gets fooled where a QA-trained embedder doesn't, what the 512-token limit actually cuts, and why cosine and dot product give identical rankings for this model.
Model
A · Same need, four phrasings
Multi-QA MiniLM was trained on (question, answer) pairs. Score one answer passage against a question, a flat statement, bare keywords, and an answer-like sentence — and against an off-topic distractor from the same domain.
| Phrasing | Text | cos → answer | cos → distractor | Margin | Tokens |
|---|---|---|---|---|---|
| Load the model to score the phrasings. | |||||
B · Keyword-overlap traps
Each trap pairs a decoy that repeats the query's words with an answer that uses different vocabulary. BM25 counts shared terms; the dense model compares meaning.
BM25 picks…
–
Multi-QA MiniLM picks…
–
| Trap | Keyword overlap (decoy / answer) | BM25 | Dense cos (decoy / answer) | Dense |
|---|---|---|---|---|
| Run all 4 traps to fill the scoreboard. | ||||
C · 512-token truncation inspector
The encoder sees at most 512 WordPiece tokens (and was trained on ≤ 250). A key sentence is buried after repeated filler; move it deeper and shrink the budget to see when it falls off the end and the score collapses.
Indigo = tokens kept by the budget · amber line = where the key sentence starts.
Show the WordPiece tokens (struck = dropped by the budget)
D · Cosine ≡ dot product for unit vectors
The model card says to score with dot product or cosine. Embed two texts with and without the final L2 normalisation step: cosine is unchanged, and once vectors have length 1 the plain dot product equals it.
| Vectors | ‖A‖ | ‖B‖ | A · B | cos(A, B) | |cos − dot| |
|---|---|---|---|---|---|
| Run the comparison. | |||||