Choose an example and press Play. BM25 looks for matching words. Cosine compares topic vectors. Both searches receive the same query, then reciprocal rank fusion (RRF) combines their rankings into one list.
The exact-identifier example shows why the searches complement each other: BM25 finds the right contract, while the topic vector also retrieves documents about related incidents. Different wording shows the opposite case: no exact words match, but the vector search still returns candidates. Combining lists can help, but does not guarantee relevance.
The demonstration uses eight fictional UK business documents. BM25 is computed from their text with k1 = 1.2 and b = 0.75, preserving identifiers such as NB-204 without stemming or stop-word removal. Cosine uses four hand-authored coordinates: incidents, billing, privacy and staff. These are teaching vectors, not model-generated embeddings. The 3D lanes separate the searches; their positions do not measure relevance. Playback illustrates the sequence, not service latency.
The maths
- Reciprocal rank fusion
This example keeps up to three candidates per search and fixes c at 60. A document receives 1 / (60 + rank) from each list containing it. Missing from a list means zero from that branch. Add these contributions, then sort by the total. Raw BM25 and cosine scores are not added.
Sources and model assumptions
Follow the original mechanism behind this explainer. The interactive examples identify their toy data and simplifying assumptions above.
Put it to work
Related terms
- Hybrid searchHybrid search runs a keyword search and a vector search over the same corpus and merges the two result lists. It exists because embeddings are good at meaning and bad at exact strings, and keyword search is the other way round.
- RerankingReranking retrieves a generous set of candidates cheaply, then reorders them with a slower, more accurate model before any of it reaches the context. It buys precision at the top of the list without paying that cost across the whole corpus.