Hybrid Search

BM25 is great at exact words: product codes, names, rare terms. Vector search is great at meaning: it finds a puppy when you search for a pet. Each one fails where the other shines.

Hybrid search runs both retrievers on the same query and merges their two rankings into one. Most production search engines work this way today.

Querypet training
→
BM25ranking by words
Vectorsranking by meaning
→
Fusionmerge the two rankings
→
Resultsone final ranking

1. Query & Documents

Try:
Learn more: about the vectors on this page

Real embedding models learn hundreds of dimensions from billions of sentences. To keep this demo self-contained, each word here has hand-written scores on 6 concepts: animal, pet, machine, tech, food, sport. A text's vector is the average of its words' vectors; unknown words (like 0x80070005) are ignored.

Like early embeddings (word2vec), one word gets one vector whatever the context: the CAT excavator still looks a bit like an animal.

Known words:

2. Fusion

score = Σ 1 / (k + rank) over both rankings
Learn more

Why not simply add the two scores? They live on different scales: BM25 scores are unbounded (2.3, 7.9…), cosine similarities sit between -1 and 1. Adding them lets BM25 dominate.

Reciprocal Rank Fusion (RRF) sidesteps this by ignoring scores and using only ranks. A document ranked 1st gets 1/(k+1), 2nd gets 1/(k+2), and so on, summed over both lists. Being decent in both lists beats being great in one. k = 60 is the value from the original paper and still the common default: a larger k flattens the gap between top and lower ranks.

Weighted scores first rescale each list to 0–1 (min-max normalization), then mix them with a weight. It can beat RRF, but the right weight depends on your data and must be tuned.

3. Rankings

BM25

    Vectors