Why it matters
BM25 cannot match a query to a passage that uses a different word for the same thing, and dense retrieval gives up exact term matching and score interpretability. Learned sparse retrieval keeps the inverted index — each dimension is still a term — but predicts which terms should be present and how strongly, including terms absent from the original text. That buys semantic reach at lexical speed, with a longer postings list as the bill.
Mental model
Sparse retrieval is a searchable thesaurus: the index still works term by term, but each term now carries a list of related terms with weights. The metaphor breaks because the expansion is learned from data and cannot be read off, so a wrong expansion looks like a normal search result rather than a bad suggestion.
How it works
The interactive figure loads with JavaScript. The text version below describes the same frame.
Figure. A learned sparse query with four weighted terms plus two learned expansion weights, and six synthetic passages as sparse vectors over the same six dimensions. Score is the dot product over all six; the dashed, starred terms are added by the model and are not in the query text.
What to notice. Error PAY-4092 scores 2.32 and is found. Expansion lifts billed twice from 0.00 to 0.54 — above the statement line — but it still ranks fourth at k = 3. The model adds billed and refund as query weights, closing part of the synonym gap without replacing the exact code match. Expansion is a recall aid, not a guarantee.
Text version
A term-weight table rather than a scatter, because sparse vectors have one dimension per vocabulary term. The query has four text terms — error, PAY-4092, duplicate and charge — and two starred learned expansion weights, billed and refund. Six passages are ranked by dot product: Error PAY-4092 first at 2.32; refund policy second at 0.86 after the refund expansion; retry idempotency third at 0.76; the paraphrase I was billed twice fourth at 0.54 because of the billed expansion, still outside k = 3 and marked missed; statement line fifth at 0.35; contact support sixth at 0.00 and marked below k. A slider sets k from one to five.
- Start from a lexical baseline and measure it, so any gain from expansion is visible rather than assumed.
- Choose a learned sparse model that emits term weights over the vocabulary, and check its tokenizer matches the index analyzer.
- Index the expanded term weights into an inverted index or a sparse-vector index that supports term lookups.
- Cap the number of non-zero terms per document, because expansion multiplies postings and query cost.
- Score queries with the same model so query and document weights share a scale.
- Compare on identifier-heavy and paraphrase-heavy slices; expansion helps the second and can hurt the first.
Trade-offs
| Choice | Good for | Cost | Fails when |
|---|---|---|---|
| Plain BM25 | Explainable scores and cheap postings | No synonym coverage | Users paraphrase or translate their question |
| Learned sparse with wide expansion | Semantic reach at lexical speed | Longer postings and slower queries | The corpus is large and latency-sensitive |
| Narrow expansion | Predictable, near-lexical behaviour | Little gain over BM25 | Vocabulary mismatch is the main failure |
| Sparse-only | Exact terms plus some synonymy | No deep paraphrase matching | Questions are conversational and indirect |
Good for
Explainable scores and cheap postings
Cost
No synonym coverage
Fails when
Users paraphrase or translate their question
- Users paraphrase or translate their question
- The corpus is large and latency-sensitive
- Vocabulary mismatch is the main failure
- Questions are conversational and indirect
Figure. Each choice with what it buys, what it costs, and the case where it loses.
What to notice. The fourth column is the decision: if the losing case describes your situation, the choice is wrong.
Text version
Four trade-offs: Plain BM25 is good for Explainable scores and cheap postings, costs No synonym coverage, and fails when Users paraphrase or translate their question. Learned sparse with wide expansion is good for Semantic reach at lexical speed, costs Longer postings and slower queries, and fails when The corpus is large and latency-sensitive. Narrow expansion is good for Predictable, near-lexical behaviour, costs Little gain over BM25, and fails when Vocabulary mismatch is the main failure. Sparse-only is good for Exact terms plus some synonymy, costs No deep paraphrase matching, and fails when Questions are conversational and indirect
Failure modes
- Expansion drift. A term expands to a related but wrong sense, so unrelated passages surface with a plausible score. Debug: inspect the top-weighted expansion terms for the failing query and check whether the wrong sense is present.
- Postings blow-up. Query latency rises after enabling expansion because each term now scans many more documents. Debug: compare the number of postings scanned per query with expansion on and off.
- Tokenizer mismatch. The sparse model emits subword terms that the index analyzer never produced, so weights are dropped. Debug: take one document through both paths and diff the term sets.
In production
Track postings scanned per query and p95 latency after any expansion change. Store the expansion model version beside the index, since term weights are model-specific and cannot be mixed across versions.
Common misconceptions
People think: Sparse means keyword-only.
Actually: Learned sparse models add weighted related terms, so they capture some synonymy while staying term-addressable.
People think: Sparse and dense vectors are interchangeable.
Actually: They occupy different spaces and fail on different queries; fusion exploits the difference rather than erasing it.
Interview angle
Distinguish vocabulary-dimension sparsity from learned term expansion, and explain why an inverted index can still serve it. Mention the postings and latency bill and the queries where expansion hurts. Treating sparse retrieval as BM25 renamed, with no account of what the model learns, is the standard gap.
Sources
- Formal et al., SPLADE — learned sparse expansion with an inverted-index-compatible representation.
- Robertson & Zaragoza, The Probabilistic Relevance Framework: BM25 and Beyond — the lexical scoring model that learned sparse retrieval extends.
- Khattab & Zaharia, ColBERT — late interaction as a third point between sparse and single-vector dense retrieval.