Week 11 • Day 3Week 11

Day 3:Week 11, Day 3: Hybrid Search Fusion — Convex Score Combination vs Reciprocal Rank Fusion

Battle-tested daily lesson note • 100% runnable code, interview Q&A, test suite & interactive quiz

Week 11, Day 3: Hybrid Search Fusion — Convex Score Combination vs Reciprocal Rank Fusion (RRF)


1. Why Combining BM25 and Cosine Similarity Scores Directly is Tricky

In Hybrid Search, we run two retrievers in parallel:

  1. Lexical Retriever (Okapi BM25): Scores live in [0,+∞)[0, +\infty) (e.g., 18.4, 7.2, 1.1) and vary wildly depending on how many words the user typed!
  2. Dense Vector Retriever (Cosine Similarity): Scores live in [−1,+1][-1, +1] (typically clustered tightly in [0.65, 0.88]).

If you naively compute 0.5 * bm25_score + 0.5 * cosine_score, a BM25 score of 18.4 completely swamps a Cosine score of 0.85! And if you use Min-Max normalization per query, a single outlier BM25 score distorts the entire scale.


2. The Production Standard: Reciprocal Rank Fusion (RRF — Cormack et al., 2009)

Instead of relying on uncalibrated raw scores, Reciprocal Rank Fusion (RRF) fuses multiple ranked lists based purely on each document's 1-based rank position rankr(d)∈{1,2,3,… }\text{rank}_r(d) \in \{1, 2, 3, \dots\} in each retriever r∈Rr \in \mathcal{R}:

RRF_Score(d)=∑r∈Rwrk+rankr(d)\text{RRF\_Score}(d) = \sum_{r \in \mathcal{R}} \frac{w_r}{k + \text{rank}_r(d)}

where k=60k = 60 is the universal smoothing constant (and wrw_r is an optional retriever weight, default 1.0).

Why k=60k = 60 Works So Well:

  • It requires zero score calibration across heterogeneous retrievers (BM25, Dense, SPLADE).
  • A document ranked #2 in BM25 AND #3 in Dense Search gets: 160+2+160+3=0.01613+0.01587=0.03200\frac{1}{60 + 2} + \frac{1}{60 + 3} = 0.01613 + 0.01587 = \mathbf{0.03200}
  • Whereas a document ranked #1 in BM25 only (and missing from Dense) gets: 160+1+0=0.01639\frac{1}{60 + 1} + 0 = \mathbf{0.01639} Consensus winners that appear near the top of BOTH lexical and semantic search automatically float to #1!

In Simple English: Why RRF Beats Naive Score Averaging

Suppose BM25 returns scores like 18.4, 12.1, 4.0 while Cosine Vector Search returns 0.88, 0.85, 0.79. If you simply add 18.4 + 0.88, BM25 always bullies Cosine into irrelevance! Reciprocal Rank Fusion (RRF) ignores raw scores and looks ONLY at position (1st, 2nd, 3rd...) using $1 / (60 + \text{rank})$:

  • Document ranking #2 in BM25 ($1/62 = 0.01613) AND **#3 in Vector** (\1/63 = 0.01587) earns **\0.03200$** total!
  • It easily beats a fluke document that ranked #1 in BM25 ($1/61 = 0.01639$) while missing completely from semantic search (0.01639)!