Sparse Retrieval

LLM foundationsRetrieval and dataPublished By Simon Budziak

Sparse retrieval searches documents using mostly zero-valued vectors where the remaining values represent exact words or learned lexical features. Methods such as BM25 rank documents by term matches, which makes sparse retrieval strong for names, codes, rare phrases, and other questions where exact wording matters.

Its limitation is equally useful to understand. A sparse retriever sees words and weighted expansions, not meaning in the broad sense, so it can miss a relevant passage that says the same thing differently.

How does sparse retrieval work?

The index records which terms appear in each document and how distinctive they are across the collection. At query time, BM25 scores documents that contain the requested terms. Exact lexical matching is its advantage, not an outdated compromise. Reranking can inspect the top candidates with a stronger model, while a vector database supports the semantic path used by dense retrieval.

Should RAG use sparse or dense retrieval?

Most production systems should evaluate both on real questions. Semantic search is better when the wording varies. Sparse retrieval protects identifiers and short precise queries. Hybrid search combines both rankings. It is often the simpler answer to mixed enterprise data than forcing one method to do every job.

Frequently asked questions

Is sparse retrieval just keyword search?

Classical sparse retrieval is keyword-based, including BM25. Learned sparse methods can expand or weight terms with a neural model while keeping a sparse representation.

When is sparse retrieval better than vector search?

It is often better for identifiers, product names, legal phrases, error codes, and rare terms that should match exactly rather than by general semantic similarity.

Summarize this page with

Train your team to build this