Your retrieval-augmented system is only as good as what it retrieves. And a single retrieval method — keyword or vector — will quietly fail on a predictable class of queries, in ways nobody notices until an answer is wrong in front of a regulator.
Most write-ups on retrieval treat the choice as a religious one: lexical search is old, vector search is modern, pick the modern thing. That framing is wrong, and it costs teams recall they did not have to lose. The two methods fail on different queries. The engineering answer is to run both and fuse the results, and the boring, robust way to fuse them is reciprocal rank fusion. This is a reading of how hybrid search actually works, how to combine the two rankings, and — the part almost everyone skips — how to prove the hybrid is better on your own corpus rather than assuming it.
Why one method is never enough
BM25 is a lexical ranking function: it scores documents on the terms they share with the query, weighted by term frequency and inverse document frequency. It is exact, explainable, and unbeatable when the query contains a token that must match — a policy number, an ISIN, an error code, a specific article reference, a surname. It has no idea that “redundancy” and “business continuity” are related concepts, because they share no characters.
Free · 4 minutes
When two of your systems disagree, do you know which one to believe?
Fourteen questions on ownership, lineage, and quality — the difference between a number on a dashboard and a number you could defend. Banded finding on screen, full sheet by email.
Dense-vector search is the mirror image. It embeds the query and the documents into the same vector space and ranks by cosine similarity, so it retrieves on meaning rather than tokens. It finds the continuity document from a query about redundancy. It also, reliably, fails to retrieve the document containing an exact identifier the user typed, because that identifier carries almost no semantic signal and gets washed out by the surrounding prose. Ask a dense retriever for “clause 7.3.1” and it will happily return five documents about clauses in general.
These are not edge cases you can ignore. In any regulated corpus — contracts, filings, incident records, standards — real queries mix exact identifiers with conceptual language in the same sentence. A retriever that is strong on one and blind to the other is a retriever with a hole in it. Hybrid search exists to close that hole, not to chase a benchmark.
Why you fuse ranks, not scores
The naive way to combine two retrievers is to add their scores. Do not do this. BM25 scores are unbounded and corpus-dependent; cosine similarities sit between roughly minus one and one. Adding them means one method silently dominates, and the balance shifts every time your index changes. You can normalise the scores, but normalisation is fragile — it depends on the score distribution of a particular query, which is exactly the thing you cannot hold stable.
Reciprocal rank fusion sidesteps the problem by throwing the scores away and keeping only the ranks. Each retriever returns an ordered list. A document’s fused score is the sum, across retrievers, of one divided by a constant plus its rank in that retriever’s list. Documents that rank highly in either list rise; documents that rank highly in both rise furthest. Because rank is ordinal, it does not matter that BM25 and cosine live on different scales — position one is position one in both.
The method comes from Cormack, Clarke and Buettcher’s 2009 SIGIR paper, which showed this one-line formula outperforming more elaborate learned fusion methods. The rank constant, conventionally written k and defaulting to 60, controls how sharply the top ranks dominate: a smaller k rewards being first more aggressively, a larger k flattens the contribution so deeper results still matter. Sixty is a sensible default and rarely the thing worth tuning first.
The fusion, in code
Here is the whole algorithm. Two ranked lists in, one fused list out. This is deliberately backend-agnostic: the BM25 list can come from Elasticsearch or Postgres full-text search, the dense list from pgvector or any vector store.
from collections import defaultdict
def reciprocal_rank_fusion(rankings, k=60, weights=None):
"""Fuse several ranked lists of document ids into one.
rankings: list of lists, each an ordered list of doc ids
(best first) from one retriever.
k: rank constant; higher flattens the top-rank bias.
weights: optional per-retriever weights (defaults to 1.0).
"""
weights = weights or [1.0] * len(rankings)
fused = defaultdict(float)
for ranking, weight in zip(rankings, weights):
for rank, doc_id in enumerate(ranking, start=1):
fused[doc_id] += weight * (1.0 / (k + rank))
return sorted(fused, key=fused.get, reverse=True)
# bm25_ids: exact-term recall (e.g. an Elasticsearch match query)
# dense_ids: semantic recall (e.g. a pgvector <=> nearest-neighbour scan)
bm25_ids = ["doc-14", "doc-3", "doc-91", "doc-7"]
dense_ids = ["doc-91", "doc-55", "doc-14", "doc-2"]
# Lexical weighted a little heavier here; measure before you trust it.
results = reciprocal_rank_fusion([bm25_ids, dense_ids], weights=[1.2, 1.0])
print(results[:5])
If you would rather not run the fusion yourself, Elasticsearch ships an rrf retriever that fuses a standard (BM25) retriever and a knn retriever natively, exposing rank_constant (default 60) and rank_window_size parameters. On Postgres you run the BM25 query and the pgvector nearest-neighbour query separately and fuse their id lists in the application with the function above. Both approaches produce the same shape of result; the managed retriever just saves you a round trip. Getting a clean, reproducible environment to run this in is its own small discipline — isolated Python tooling pays off the first time an eval has to be re-run months later.
Weighting, and why you should distrust your own
The weights are the tempting knob. If your corpus is identifier-heavy, lexical recall matters more and you lean the weight towards BM25; if queries are conversational, you lean towards the dense side. That intuition is a starting hypothesis, not a setting. The whole point of hybrid search is that the failure modes are query-dependent, which means the right weighting is a property of your query distribution, and you do not know your query distribution as well as you think you do. Guessing a weight and shipping it is how a team convinces itself the hybrid works while the fusion is quietly worse than BM25 alone on half the traffic.
Measure the lift, or you have not built anything
Hybrid search is a claim: that fusing two retrievers beats either alone on your queries. A claim you have not measured is a claim you are asking a supervisor to take on faith, and in a regulated retrieval pipeline that is not a position you want to defend. Build a small evaluation set before you tune anything — fifty to a couple of hundred real queries with the documents that should be retrieved marked as relevant. Then run BM25 alone, dense alone, and the fusion, and compare them on a retrieval metric such as recall at ten or nDCG. Treat that evaluation set as a contract the retriever has to satisfy, defined before the implementation, the same way you would design an API contract before writing the code behind it.
Two things fall out of doing this honestly. First, you will find queries where the hybrid is worse than a single method — usually short exact-match lookups where the dense list drags a good BM25 result down. That is signal, not failure: it tells you where weighting or a routing rule earns its place. Second, you can only trust any of it if you know what is in the index to begin with. Retrieval quality is downstream of corpus quality, and a documented account of what you embedded, which model produced the vectors, and when — the kind of bill of materials for models and training data that makes an AI system auditable — is what lets you re-run the evaluation after a re-index and know whether a regression came from the fusion or the data underneath it.
Reciprocal rank fusion is ten lines of code. The engineering is not the fusion. It is having the evaluation set that lets you say, with evidence, that your retriever got better — instead of shipping a fashionable architecture and hoping.
Free interactive tool
Interactive deadline calculator
Check which regulations apply to you and when
Regulation across the EU, UK, US and Asia-Pacific has moved considerably in the past eighteen months, and several headline dates have shifted more than once. Twelve questions, about three minutes.
Results are shown on screen — no email required. A dated summary is available to download, and can be sent on if that's more useful. What we do with your answers.
Governance is what happens when nobody is watching.
Policies are easy. Consistent decision-making is harder. Understand where governance exists and where it has quietly become assumed.
Full Governance by Sixteen Pillars
Govern your business. Prove your compliance.
A board assurance cockpit for EU-regulated financial firms — tamper-evident, hash-chained proof of governance across DORA, GDPR, NIS2, ISO 27001, the EU AI Act and MiCA. In development.
See what's coming