Learned sparse retrieval

On this page 7

Learned sparse retrieval is a family of search methods in which a neural language model assigns weights to vocabulary terms for each query and document, producing sparse, high-dimensional vectors that can be searched with a classic inverted index. In artificial intelligence, it sits within retrieval & knowledge as a bridge between lexical search such as BM25 and dense retrieval with embeddings.

The approach keeps the efficiency and interpretability of term matching while adding what neural models know about meaning: it can expand a document with related terms that are absent from its text and downweight terms that carry little relevance. Well-known models include SPLADE, uniCOIL, DeepImpact and the Elastic Learned Sparse Encoder.

How learned sparse retrieval encodes text

A learned sparse encoder maps text to a vector over the model vocabulary, typically about 30,000 WordPiece tokens for BERT-based models. Each dimension corresponds to one token, and its value is a learned importance weight. Most dimensions are zero, so the vector is stored as a short list of token and weight pairs.

In SPLADE, each input token produces logits over the whole vocabulary through the masked language modeling head. The model applies a log-saturated ReLU and max pooling across input positions, so a document about automobiles can receive positive weight for car or vehicle even when neither word appears in it. This is learned term expansion.

Relevance is the dot product of the query and document vectors, which only involves tokens present in both. That operation is exactly what an inverted index computes efficiently by walking posting lists.

ComponentRoleTypical choice
Encoder backboneContextual understanding of textBERT or DistilBERT
Term weighting headScore each vocabulary tokenMasked language modeling projection
Sparsity regularizerKeep vectors shortFLOPS or L1 penalty
Inverted indexFast candidate lookupLucene, Anserini, PISA
Scoring functionRank documentsSparse dot product
Building blocks of a learned sparse retrieval system

Training objectives and sparsity control

Learned sparse models are trained with contrastive ranking losses on query and passage pairs, most often from MS MARCO, with hard negatives mined by BM25 or a stronger retriever. Many recent models also use knowledge distillation from a cross-encoder, which teaches the encoder finer relevance distinctions than binary labels can.

Without a constraint, the model would activate thousands of terms per document and make the index slow. A sparsity regularizer such as the FLOPS penalty pushes down the expected number of posting list operations. Its coefficient sets the central trade-off between effectiveness and latency: a stronger penalty yields shorter vectors and faster search but lower recall.

Model familyExpansionQuery encodingNotable trait
DeepCTNonePlain termsReweights existing terms only
DeepImpactVia doc2queryPlain termsLearns impact scores
uniCOILVia doc2queryLearned weightsSingle weight per term
SPLADELearned by the modelLearned weightsStrong zero-shot results
Inference-free SPLADEDocuments onlyTokenizer lookupNo neural query encoder
Main families of learned sparse models

The inference-free variants move all neural computation to indexing time. Queries are tokenized and weighted with a fixed table, so query latency approaches that of BM25 at a modest cost in quality.

Learned sparse retrieval compared with BM25 and dense retrieval

Learned sparse retrieval differs from neighboring approaches in how term weights are obtained and how vectors are searched. BM25 uses fixed statistical weights, dense retrieval uses compact learned vectors, and learned sparse retrieval uses learned weights over an explicit vocabulary.

PropertyBM25Learned sparseDense retrieval
RepresentationTerm frequenciesWeighted vocabulary termsLow-dimensional embedding
Vocabulary mismatchNot handledPartly handled by expansionHandled semantically
Index typeInverted indexInverted indexVector index such as HNSW
InterpretabilityHighHighLow
Exact term matchingStrongStrongOften weak
Out-of-domain robustnessStrong baselineUsually strongVariable
Comparison of retrieval paradigms

On the BEIR benchmark, strong learned sparse models typically outperform BM25 and many single-vector dense models in zero-shot settings, although results vary by dataset. Their exact matching of rare identifiers, product codes and names is an advantage over dense embeddings, which tend to blur such tokens.

Deploying learned sparse retrieval

Learned sparse retrieval fits well where an organization already runs an inverted-index search engine and wants semantic gains without operating a separate vector database. Elasticsearch, OpenSearch, Vespa and Lucene-based systems support weighted term fields for this purpose.

SituationRecommendationReason
Existing Lucene-based stackAdopt learned sparse firstReuses current infrastructure
Many codes and identifiersPrefer learned sparse or hybridKeeps exact term matching
Multilingual corpusCheck vocabulary coverageEnglish vocabularies fit poorly
Highest recall neededHybrid with dense retrievalSignals are complementary
Strict query latency budgetInference-free variantNo encoder at query time
When to choose learned sparse retrieval
  • Index size grows with expansion; expect several times the size of a BM25 index for aggressive models.
  • Prune low weights at indexing time to cut posting list length with little quality loss.
  • Combine with reranking: a cross-encoder over the top 50 to 100 candidates often adds the largest gain.

Limitations and common misconceptions

Learned sparse retrieval is bound to the vocabulary of its tokenizer. Words split into subword pieces can lose meaning, and models trained on English data transfer poorly to other languages unless they use a multilingual vocabulary and training data.

  • Not free of neural cost: document encoding requires a GPU or long CPU batches at indexing time.
  • Not fully interpretable: expansion terms are visible, but why the model chose them is not.
  • Query latency risk: long expanded queries touch many posting lists and can exceed latency budgets.
  • Domain shift: weights learned on web search data may misjudge legal or medical terminology.

A common misconception is that sparse means old or lexical. In this context, sparse describes the vector format, not the method; the weights themselves come from a deep transformer model.

The simple explanation

Classic search works like a book index. It lists which pages contain which words. If a page never uses your word, it is not found. Learned sparse retrieval keeps the index but makes it smarter.

A trained language model reads every document first. It decides which words truly matter and adds related words the author did not write. A page about automobiles can then be found with the word car. Search stays fast, because the system still uses an index. You can also see which words caused a match.

How it is used in practice

An industrial equipment supplier runs a support portal with about 400,000 manuals and service notes on an Elasticsearch cluster. Technicians search with informal phrases such as pump losing pressure, while manuals use terms like hydraulic cavitation. BM25 misses many of these matches, yet a dense vector search loses exact part numbers that technicians also type.

The team encodes all documents with a learned sparse model at indexing time and stores the weighted terms in a rank features field, then applies a cross-encoder reranker to the top 50 results. Offline evaluation on 600 real support queries shows recall@10 rising from 0.58 to 0.74, while median query latency stays under 80 milliseconds and part number searches still return the exact manual.