Özer Cem KELAHMETKELAHMET
Articles · Hybrid search

Hybrid search for RAG: BM25, SPLADE and dense vectors fused with reciprocal rank fusion

Keyword search finds exact codes and names; dense search finds paraphrases. Hybrid search runs both and fuses the lists. This guide works the BM25 formula by hand, explains SPLADE, and shows with numbers why reciprocal rank fusion is the safe default for merging.

Download Markdown
At a glance
Reading time
14 min
Sections
7
Code examples
2
Tables
2
Sources
8
Published
24 Nov 2026
In 30 seconds
What changed
bm25s 0.3.16 released
Why it matters
Hybrid search is the cheapest large improvement available to most RAG systems.
What to do
Add BM25 to any dense-only retriever

Dense embeddings changed search by matching meaning instead of words. A question about "printouts not working" can find a passage about a "printer that cannot reach the server" without sharing a single keyword. But dense search has a blind spot that every team running retrieval-augmented generation (RAG) discovers quickly: exact strings. Error codes, part numbers, product names, legal citations and people's names are often rare tokens that an embedding model blurs into something vaguely similar.

Hybrid search fixes this by running two kinds of retrieval, lexical and semantic, and merging the results. It is now the default recommendation for production RAG, and most vector databases support it natively. This month the fastest pure-Python BM25 library and the main open-source embedding library both shipped new versions that make hybrid retrieval easier to build locally. This article explains the three signal types (BM25, learned sparse and dense), works the BM25 formula by hand, and shows with numbers why reciprocal rank fusion is the safest way to combine them.

An everyday analogy: a librarian who only matches titles word by word will miss a book called "Fixing printers" when you ask about printouts. One who only goes by topic will hand you ten printer books but not the one with your exact error code. A good librarian does both, then compares notes.

What happened

bm25s 0.3.16 released (28 October 2026)

The bm25s library, a BM25 implementation in Python built on NumPy and sparse matrices, released 0.3.16 on 28 October 2026, its fourth release in October. Its README states it computes scores eagerly for all document tokens at index time, which makes query-time scoring fast, and that it has no dependency on Java or PyTorch. It supports five BM25 variants: the original Robertson form, ATIRE, BM25L, BM25+ and Lucene's, with Lucene's as the default. For hybrid RAG prototypes this means an exact, Lucene-compatible keyword retriever can live in the same Python process as the embedding model.

Sentence Transformers 6.3.0 keeps sparse encoders in the core package (11 November 2026)

Sentence Transformers 6.3.0 reached PyPI on 11 November 2026. Its README documents a SparseEncoder class for learned sparse models, with naver/splade-cocondenser-ensembledistil as the example, alongside dense embedding models, cross-encoder rerankers and multi-vector models. A team can now produce BM25-style sparse vectors with learned weights and dense vectors from one library, which is the core of a three-way hybrid.

Three kinds of retrieval signal

Table 1. Three kinds of retrieval signal
Signal Representation Strength Weakness
BM25 (lexical) Term counts in an inverted index Exact terms, codes, names; no training; explainable No synonyms; vocabulary mismatch
Learned sparse (SPLADE) Weights over the model's vocabulary, mostly zeros Expands with related terms; still uses an inverted index Needs a model at index and query time; English-centric models are common
Dense A few hundred to a few thousand real numbers Paraphrase and meaning; cross-lingual with the right model Blurs rare tokens; less explainable

BM25 by hand

BM25 scores a document for a query by adding up one term at a time. For a query term t:

score(t, D) = IDF(t) × tf × (k1 + 1) / (tf + k1 × (1 − b + b × |D| / avgdl))

with IDF(t) = ln(1 + (N − n_t + 0.5) / (n_t + 0.5)) in the Lucene variant. Here N is the number of documents, n_t the number containing t, tf the term's count in the document, |D| the document length and avgdl the average length. The two constants are k1, which controls how fast repeated terms stop adding score, and b, which controls length normalisation.

Take N = 1,000 documents, a term that appears in 10 of them, three times in a 120-token document where the average is 100 tokens, with k1 = 1.2 and b = 0.75:

  • IDF = ln(1 + 990.5 / 10.5) = 4.557
  • term-frequency part = 3 × 2.2 / (3 + 1.2 × (0.25 + 0.75 × 1.2)) = 1.507
  • score = 4.557 × 1.507 = 6.867

Saturation is the key property. With the same settings, the term-frequency part is 0.924 for one occurrence, 1.507 for three, 1.933 for ten and 2.170 for a hundred. Repeating a word does not let a document win forever. The site's BM25 simulation lets you move tf, length and b and watch the curve.

Learned sparse retrieval: SPLADE

SPLADE (Formal and colleagues, 2021) runs a transformer over the text and predicts a weight for every word in the model's vocabulary, then keeps the vector sparse with a regulariser. The result looks like a BM25 document, terms and weights, so it fits an inverted index, but the weights are learned and the model adds related terms that are not in the text. A passage about "printer cannot reach the server" may get small weights on "network" and "offline". You get some of dense retrieval's semantic reach with keyword search's exactness and infrastructure.

Dense retrieval

Dense retrieval embeds the query and each chunk into one vector each and ranks by cosine similarity. It handles paraphrase, synonyms and even other languages, but it compresses the whole chunk into a few hundred numbers, and rare strings such as "E1042" carry little weight in that summary.

Fusing the lists: RRF versus score blending

Each retriever returns its own ranked list with its own score scale. BM25 scores are unbounded and depend on the query; cosine similarities usually fall in a narrow band. You cannot add them directly. Two families of fusion are common.

Reciprocal rank fusion (RRF), from Cormack, Clarke and Büttcher (2009), ignores scores and uses only ranks:

RRF(d) = Σ over lists of 1 / (k + rank(d))

with k = 60 in the original paper. Documents near the top of any list get a large share; documents in several lists add up.

Score blending normalises each list, often with min-max scaling to the range 0 to 1, and takes a weighted sum such as 0.5 × lexical + 0.5 × dense.

The code below fuses two lists for the query "E1042 printer offline". BM25 ranks the knowledge-base article with the exact code, kb-17, first. The dense model prefers kb-08, a general article on offline printers, and also returns kb-21.

bm25  = {"kb-17": 14.2, "kb-03": 9.8, "kb-44": 6.1, "kb-08": 5.5}
dense = {"kb-08": 0.83, "kb-17": 0.81, "kb-21": 0.80, "kb-03": 0.62}

def ranks(sc): return {d: i + 1 for i, d in enumerate(sorted(sc, key=lambda d: -sc[d]))}

def rrf(*lists, k=60):
    out = {}
    for sc in lists:
        for d, r in ranks(sc).items():
            out[d] = out.get(d, 0) + 1 / (k + r)
    return sorted(out.items(), key=lambda x: -x[1])

def minmax(sc):
    lo, hi = min(sc.values()), max(sc.values())
    return {d: (s - lo) / (hi - lo) for d, s in sc.items()}

def weighted(a, b, w=0.5):
    na, nb = minmax(a), minmax(b)
    return sorted(((d, w * na.get(d, 0) + (1 - w) * nb.get(d, 0))
                   for d in set(a) | set(b)), key=lambda x: -x[1])

print(rrf(bm25, dense))
print(weighted(bm25, dense))
Table 2. Fusing the lists: RRF versus score blending
Document BM25 rank Dense rank RRF score RRF order Min-max 50/50 Blend order
kb-17 1 2 0.03252 1 0.952 1
kb-08 4 1 0.03202 2 0.500 2
kb-03 2 4 0.03175 3 0.247 4
kb-21 absent 3 0.01587 4 (tie) 0.429 3
kb-44 3 absent 0.01587 4 (tie) 0.034 5

Both methods put kb-17 first, which is right. The difference is kb-03. It appears in both lists, second for BM25 and fourth for dense, so RRF ranks it third. Min-max scaling turns the last item of each list into exactly zero, so kb-03's dense contribution vanishes and it falls below kb-21, which only one retriever found. Min-max also makes the dense scores, which sit between 0.62 and 0.83, look as spread out as the BM25 scores, which sit between 5.5 and 14.2. Small, meaningless gaps in one list get amplified.

That is why RRF is the usual default. It needs no tuning, ignores score scales and rewards agreement between retrievers. Score blending can do better when you tune the weight on labelled data and use a more careful normalisation, but it can also do worse when score distributions shift between queries. The hybrid RAG simulation lets you change k and the weights and see the order move.

One more detail: RRF's k sets how much the top ranks dominate. With k = 60 the gap between rank 1 and rank 2 is tiny (1/61 versus 1/62), so agreement across lists matters more than winning one list. A smaller k, such as 10, rewards first places more strongly.

Building it

A hybrid retriever has four steps:

  1. Index twice. Build a BM25 (or SPLADE) inverted index and a dense vector index over the same chunk IDs.
  2. Query both in parallel. Retrieve the top 50 to 100 from each. The extra depth matters because fusion can only promote documents that appear in a list.
  3. Fuse. Apply RRF with k = 60, or a tuned weighted blend.
  4. Rerank. Send the top 20 to 50 fused results to a cross-encoder reranker and keep the best few for the prompt.

Most engines can do steps 1 to 3 internally. Elasticsearch and OpenSearch combine their native BM25 with vector fields; Weaviate and Qdrant offer hybrid queries that merge keyword or sparse results with dense ones; pgvector users typically run a full-text search query and a vector query in SQL and fuse in the application. For local prototypes, bm25s plus a Sentence Transformers model and the 15-line rrf function above is enough.

What it means in practice

Hybrid search is the cheapest large improvement available to most RAG systems. It costs a second index and a few milliseconds per query, and it removes the most embarrassing failure of dense-only retrieval: not finding the document that contains the exact code or name the user typed. The site's RAG types simulation shows where hybrid retrieval sits among the other upgrades.

The fusion method matters less than people expect, as long as it is rank-based or carefully tuned. RRF with k = 60 is a sensible default and has no parameters to drift. If you have a labelled evaluation set, try a weighted blend and keep it only if it beats RRF by a clear margin on held-out questions.

Learned sparse models are a middle path. If your stack already has an inverted index, SPLADE can replace or complement BM25 and capture some synonyms. The trade-off is running a transformer at index and query time, and checking that the model covers your language.

The releases this month lower the barrier to experiment. A single Python process can now hold a Lucene-compatible BM25 index and dense, sparse and reranking models, so you can test a three-way hybrid on your own data before committing to a database feature.

What to do now

  1. Add BM25 to any dense-only retriever. Run both and fuse with RRF; it is the lowest-risk retrieval upgrade.
  2. Retrieve deep before fusing. Take 50 to 100 candidates from each retriever so fusion has material to work with.
  3. Start with RRF at k = 60. Change k or switch to weighted blending only after measuring on labelled questions.
  4. Build an "exact string" test set. Include queries with error codes, SKUs, names and citations; dense-only systems fail these first.
  5. Tune BM25 for your text. Defaults of k1 around 1.2 and b around 0.75 are common; very short or very long documents may need a different b.
  6. Use a tokenizer that keeps codes intact. Make sure "E1042" and "ISO-27001" survive tokenisation as searchable tokens.
  7. Try SPLADE if you already run an inverted index. Compare it with BM25 on the same evaluation set.
  8. Rerank after fusion. A cross-encoder on the top fused results usually gives a larger gain than tuning fusion weights.

Risks and open questions

Fusion can hide a broken retriever. If one retriever silently fails, for example after a tokenizer change, RRF still returns plausible results from the other. Monitor each retriever's recall separately.

Score blending is fragile. Min-max normalisation depends on the best and worst scores in each list, which change per query. Weights tuned on one query set may not transfer.

Latency doubles in the worst case. Two retrievers in sequence add up; run them in parallel and set timeouts so one slow index does not stall answers.

Sparse models have language limits. Many SPLADE checkpoints are trained on English data. Check coverage before using them for other languages.

Lexical search inherits spelling problems. BM25 misses typos and morphological variants unless you add stemming or fuzzy matching, which can add noise.

Watch next: whether database engines converge on RRF as the default hybrid operator, and how much learned sparse models narrow the gap to dense retrieval on multilingual benchmarks.

Frequently asked questions

What is hybrid search in RAG?

Hybrid search runs a keyword retriever, such as BM25, and a semantic retriever, usually dense embeddings, on the same question and merges their ranked lists. It catches both exact terms and paraphrases, which neither method does well alone.

Why is k set to 60 in reciprocal rank fusion?

The value comes from the original 2009 RRF paper by Cormack, Clarke and Büttcher, where it worked well across test collections. It dampens the advantage of first place, so documents that several retrievers agree on rise. You can tune it, but 60 is a robust default.

Is SPLADE better than BM25?

SPLADE often finds more relevant documents because it learns term weights and adds related terms, but it needs a transformer at index and query time and may not cover every language. BM25 needs no model and is fully predictable. Many systems use one of them alongside dense retrieval.

Should I normalise scores before fusing?

Only if you use score blending. Reciprocal rank fusion uses ranks, so it needs no normalisation. If you blend scores, choose the normalisation and weight on a labelled set, and check that they hold on new queries.

Does hybrid search replace reranking?

No. Hybrid search improves the candidate list; a cross-encoder reranker then orders the top candidates more accurately. The two stages work best together.

Summary

Hybrid search combines lexical and semantic retrieval so a RAG system finds both exact strings and paraphrases. BM25 scores terms by rarity and saturating frequency, as the hand-worked example showed: a term with IDF 4.557 and three occurrences scores 6.867, and a hundred occurrences only raise the frequency part from 1.507 to 2.170. SPLADE learns sparse term weights, and dense models match meaning. Reciprocal rank fusion with k = 60 merges the lists by rank, rewarding agreement and avoiding the distortions of min-max score blending seen in the worked example. This month's bm25s and Sentence Transformers releases make it easy to try BM25, sparse and dense retrieval side by side; the durable recipe is to retrieve deep from each, fuse with RRF, then rerank.

Sources

Cite this article

Kelahmet, Ö. C. (2026, November 24). Hybrid search for RAG: BM25, SPLADE and dense vectors fused with reciprocal rank fusion. Özer Cem KELAHMET. https://www.ozercemkelahmet.com/articles/hybrid-search-bm25-splade-dense-rrf

BibTeX
@online{kelahmet2026hybrid,
  author = {Kelahmet, {\"O}zer Cem},
  title  = {{Hybrid search for RAG: BM25, SPLADE and dense vectors fused with reciprocal rank fusion}},
  year   = {2026},
  month  = {nov},
  url    = {https://www.ozercemkelahmet.com/articles/hybrid-search-bm25-splade-dense-rrf}
}
Version historyfirst version
  1. Published

Factual corrections are listed here with what changed. Wording and formatting edits are not listed.

Last updated Nov 24, 2026
Type to search.
    ↑↓ navigate↵ open