Three Ways to Search
There are three major families of methods for finding passages in a corpus. They differ in what they compare.
- Sparse search, whose standard representative is BM25, compares the words of the question against the words of the documents.
- Dense search compares the vectors of question and documents: each text is first turned into a fixed-length list of numbers, then you look for the nearest lists.
- Hybrid search runs both and merges the two rankings.
A word on vocabulary, because it lays a trap in the first line. People commonly say that dense search "understands meaning" or "grasps user intent". That is not what happens. What happens is a proximity computation between two lists of numbers, followed by a sort. Those numbers were produced by a model trained so that texts on the same subject end up as neighbours; that is why the result is often relevant. But the procedure contains no check on meaning, and it always returns K ranked results, even when the answer exists nowhere in the corpus. What the method supplies is an ordering, not a judgement.
"automobile" versus "car": dense search brings them together, because both words occur in similar contexts and their vectors reflect that. BM25 will never connect them: they are two different strings.
"error 404": BM25 returns exactly the documents containing those two terms. Dense search may put an article on "HTTP error handling" first, judging it close, and push down the one that literally held the answer.
Each misses precisely what the other finds. That is the whole argument for hybrid.
Sparse Search (BM25): The Old Guard That Still Works
BM25 (for Best Matching 25, the twenty-fifth variant in a family of formulas proposed by Robertson and colleagues in the 1990s) is the classic search algorithm, the one that has powered Elasticsearch and traditional engines for some thirty years. It is called "sparse" because you can picture each document as a huge table with one cell per word in the vocabulary: nearly every cell is zero, and only the words actually present are filled in.
Its principle is counting words, with three corrections that make all the difference:
- term frequency: a document that repeats "encumbrance" ten times is more likely to be about encumbrances than one that uses it once;
- term rarity, or inverse document frequency (IDF): a word that is rare across the corpus is more informative than a common one. If "photosynthesis" appears in 3 documents out of a million, its presence is far more discriminating than that of "the", which appears everywhere and therefore says nothing;
- document length: without a correction, a very long document would mechanically contain more occurrences of everything and would always come out on top. BM25 normalises by length, and also makes repetition saturate, the tenth occurrence of a word adds far less than the second.
None of these three corrections involves any learning: they are computed directly from the corpus. That is what makes BM25 immediately explainable, you can always say why a document ranked first.
from rank_bm25 import BM25Okapi
bm25 = BM25Okapi([doc.split() for doc in documents])
scores = bm25.get_scores(query.split())
Strengths:
- Proper nouns, error codes, reference numbers: found every time
- No GPU (graphics processing unit), no embedding model, it runs on a Raspberry Pi
- Scales well: the inverted index (the table listing, for each word in the vocabulary, the documents it appears in) is one of the most efficient data structures in existence
- Explainable result, and a corpus becomes searchable as soon as it is written, with no training phase
What BM25 misses:
- Synonyms and paraphrases: "termination" and "ending the contract" share no word, so BM25 sees no link. This is the central weakness, known as vocabulary mismatch
- Rephrasings: the same question worded differently returns different results
- Cross-language search: an English question will not find a French document
- Typos and morphological variants, unless you add extra processing (stemming, spelling correction)
When BM25 Is Enough
Technical corpus (code, API documentation, logs). Questions phrased as precise keywords. Zero compute budget. If your users are searching for identifiers, function names, or error codes, BM25 is hard to beat.
Dense Search (Embeddings): Comparing Vectors
An embedding model turns a text into a vector: a list of a few hundred numbers, always the same length regardless of how long the text is. The model was trained so that two texts on the same subject (however differently phrased) yield two nearby lists. The representation is called "dense" because, unlike the previous one, every cell is filled and no cell corresponds to any particular word.
The foundational paper for applying this to retrieval is DPR (Dense Passage Retrieval) by Karpukhin and colleagues, 2020. Their setup: two separate BERT encoders (one for the question, one for the passage) trained together so that the right passage lands near its question in vector space.
The result the paper reports is precise, and worth reading exactly: DPR beats a strong BM25 system (Lucene's) by 9 to 19 points in top-20 accuracy. That metric is the share of questions for which at least one of the 20 retrieved passages contains the answer. In other words, what is compared is not "relevance scores" but success rates on a defined task, and on open-domain question answering sets, not on search in general.
Dense Passage Retrieval for Open-Domain QA (Karpukhin et al., 2020)
Strengths:
- No shared word is required: "how to reduce my electricity bill" retrieves an article titled "everyday energy savings"
- Synonyms, paraphrases, rephrasings: handled with no special tuning
- Cross-lingual with the right models: an English question can retrieve a French document, because both texts end up in the same region of vector space
What dense search misses:
- Rare or highly technical terms: a contract reference, a version number, an unusual proper noun. The model never saw them in training, so it learned nothing about them and places them more or less anywhere
- Fine distinctions that hang on a single word: "with" versus "without", "before" versus "after", two references differing by one digit. The vector is a summary, and a summary loses those differences
- False neighbours: two texts the model places side by side although they are about different things. Nothing in the score reveals it
- Cost: you need an embedding model, a vector database, and a full recomputation of every corpus vector if you change models
Dense alone can miss the obvious. A user searches for "error 404"? It may return an article about "HTTP error handling", which it judges close, leaving behind the one that literally contains "error 404". BM25 finds the latter immediately. Which do you want as the first result?
The general point: dense search is blurry by construction, since it works on a summary of the text. That makes it excellent on vague questions and mediocre on exact ones.
Hybrid: Both at Once
The idea is simple: run both searches in parallel, then merge the two result lists. How to merge is where the difficulty lies. Two methods.
Weighted Score Fusion
Every symbol, in words. dense_score is the score dense search gave the document, sparse_score the one BM25 gave it, and α (alpha) a number between 0 and 1 that you choose. The formula reads: the final score is an average of the two, with alpha setting the mix, alpha = 0.7 gives 70% of the weight to dense and 30% to sparse, and alpha = 0 ignores dense entirely.
The flaw is serious: the two scores are not in the same unit. A cosine similarity lives between −1 and 1; a BM25 score has no upper bound and depends on the corpus. Adding them, weighted or not, is adding degrees Celsius to kilometres. So you must normalise first, and the outcome depends heavily on how you normalise.
Reciprocal Rank Fusion (RRF)
A more robust solution: instead of merging scores (incomparable across systems), throw the scores away and keep only the ranks, each document's position in each list.
Every symbol, in words. doc is the document being scored. i indexes the retrieval systems being merged (here two: dense and BM25). rank_i(doc) is that document's position in system i's list, 1 if first, 2 if second, and so on. The sigma ∑ means you add the result across all systems. k is a damping constant fixed once and for all (60 is the common choice, inherited from the original paper).
The formula reads: each system awards a document more points the higher it ranked it, and you add up the points. A document ranked first everywhere gets the maximum; one ranked first by a single system gets a middling score; one absent from both lists gets nothing.
What is k for? To flatten the gap between the very top ranks. Without it, going from rank 1 to rank 2 would halve the points (1 then 0.5), giving enormous weight to first place, when neither system is reliable enough to deserve that trust. With k = 60, rank 1 is worth 1/61 and rank 2 is worth 1/62: almost the same. The constant makes the fusion tolerant of each system's small ordering mistakes.
Its decisive advantage: no normalisation is needed, since no raw score is involved. You can merge two engines you know nothing about.

dense_results = vector_db.search(query_embedding, top_k=20)
sparse_results = bm25.get_top_k(query, k=20)
final = reciprocal_rank_fusion(dense_results, sparse_results, k=60)
Hybrid is the reasonable default, and the argument for it is structural: the two methods fail on different cases, so combining them covers more cases than either alone. That does not mean it always wins, nor by how much.
Be wary of quoted gains with no corpus and no protocol attached: "hybrid gains N points" means nothing outside a given test set. The gap between the three methods depends directly on the nature of your questions, lots of exact references, and BM25 alone may do; lots of free-form language, and dense dominates. The only measurement that counts is your own.
And a point of logic: fusion can only rank what was retrieved. If a passage appears neither in BM25's top N nor in dense's, no fusion will conjure it up. Hybrid fixes ordering, not absences.
SPLADE: Sparse, but with Term Expansion
SPLADE (Sparse Lexical and Expansion model) blurs the boundary between the two families. It is a transformer that produces sparse vectors (one cell per vocabulary word, nearly all zero, as with BM25) but whose non-zero cells have been learned rather than counted.
Concretely: each dimension of the vector corresponds to a vocabulary word, and the model can assign weight to words absent from the original text. That is what term expansion means. A document about "car" will also carry weight on "automobile", "vehicle", "drive". Those weights come from BERT's masked-language-modelling head (MLM, the training task of guessing a hidden word from its surroundings): by construction, it already knows which words could stand in for the ones present.
SPLADE: Sparse Lexical and Expansion Model for First Stage Ranking (Formal et al., 2021)The appeal is twofold: you regain dense search's tolerance for synonyms while staying compatible with the classic inverted index, so it stays fast, with no vector database. The price is that search gets more expensive as the model activates more words per document, which the paper controls explicitly with a penalty term pushing the vectors to stay very sparse. In practice the BM25 + dense hybrid remains more common, because it is built from parts you already have.

Comparison Table
| Aspect | BM25 | Dense | Hybrid | SPLADE |
|---|---|---|---|---|
| Finds a synonym with no shared word | No | Yes | Yes | Yes |
| Finds an exact reference | Excellent | Average | Excellent | Good |
| Setup cost | Minimal | Model + GPU | Both | Model |
| Latency | Very fast | Fast | Moderate | Fast |
| Explainable result | Yes | No | Partly | Yes, word by word |
When to Use What
BM25 Alone
- Technical corpus with precise terminology (code, API docs, logs)
- Questions phrased as keywords, where matching synonyms adds nothing
- Compute budget = 0
Dense Alone
- Questions asked in ordinary language, as sentences
- Cross-lingual search (question in English, docs in French)
- You have an embedding model suited to your domain and the hardware to run it
Hybrid (the reasonable default)
- Whenever possible. Adding BM25 to a dense system costs little: an inverted index on disk, no extra model. And it covers exactly the class of failures dense search lets through.
Results vary enormously by domain. Build a small test set (say fifty questions, each with the passages that genuinely answer it). Compare sparse, dense and hybrid on your data. That is the only way to know what works for your case; the method is described in RAG evaluation, and Search Toolkit shows what a tool that makes this measurement routine looks like.
Pragmatic recommendation: start with hybrid (dense + BM25 merged by RRF). It is simple and robust. More importantly, the architecture hands you a free diagnostic: by looking at which of the two lists held the right passage, you know where the fault lies. If only BM25 had it, your embedding model is a poor fit for the domain; if only dense had it, the question's vocabulary doesn't match the documents'. And if neither had it, the problem is upstream, most likely the chunking (Chunking strategies).
Once the right passages are retrieved, they still have to be put in the right order: that is what reranking is for.
1. A question whose answer exists nowhere in the corpus is sent to a dense retrieval system. What happens?
2. Why will BM25 never connect termination and breach of contract, while dense retrieval handles it with no particular tuning?
3. Why is Reciprocal Rank Fusion (RRF) more robust than weighted score fusion?
4. A relevant passage appears neither in BM25's top 20 results nor in the dense system's. What can hybrid fusion do for it?
5. In your hybrid system, the right passage was in the BM25 list but not in the dense list. What does that tell you?