Part 4 of 8 · 1 min read
Hybrid search
Ask both searches, then merge the two lists.
Think of asking the librarian for the exact words, and also browsing the topic shelf yourself, then putting the two piles together.
Hybrid search
Running keyword search and vector search for the same query and merging their results into one ranking.
The two retrievers score on different scales (BM25 scores are unbounded; cosine similarity is between −1 and 1), so you cannot simply add the scores. Two common ways to merge:
Reciprocal rank fusion (RRF). Ignore the scores and use only the ranks. Each list gives a passage 1 / (k + rank) points; add the points across lists. k (often 60) softens the advantage of first place.
rrf([bm25_ranking, dense_ranking], k=60)
Example by hand with k = 60: passage A is 1st in the keyword list and 3rd in the vector list, so 1/61 + 1/63 = 0.0164 + 0.0159 = 0.0323. Passage B is 2nd in both, so 1/62 + 1/62 = 0.0323. Almost a tie, and a passage that appears in only one list gets only one term. RRF therefore rewards agreement between the retrievers and needs no tuning of scales.
Weighted score fusion. Rescale each score list to 0 to 1 (min-max), then compute alpha × dense + (1 − alpha) × sparse. You get a knob (alpha), but you must trust the rescaling, which is sensitive to outliers.
On this toy corpus both give the same results (94 percent recall at 3, 78 percent top-1). Do not conclude they always agree; exercise Medium 2 explores it.