Interactive lab / RAG in Production

Rank fusion lab: let BM25 rescue what embeddings miss

Run real BM25 and dense retrieval over a synthetic corpus, fuse them with RRF, and tune k, weights and depth across four missions.

By Sandeep Belgavi · Published 2026-10-30

Evidence label: deterministic synthetic model. This page runs a small JavaScript model of hybrid retrieval. It generates documents from topic vocabularies with distinctive terms and unique identifiers, scores queries with real BM25 (k1 = 1.2, b = 0.75) over an inverted index, scores them with cosine similarity over synthetic embeddings, and fuses the two ranked lists by reciprocal rank fusion or min-max linear fusion. All corpora, queries and results are synthetic, and the numbers are calculated estimates for learning, not measurements of any search engine.

Play the lab

How to play

Pick a retrieval method and watch recall@10 overall and per query type. With RRF selected, move the constant k, the BM25 weight (the dense weight is two minus it) and the candidates per retriever. The canvas cycles through an identifier query, a paraphrased question and a keyword query; the bars in the fused list show how much of each document's score came from BM25 (orange) and from dense retrieval (cyan).

Inject events to see the trade-offs move: identifier-heavy traffic, out-of-domain embeddings and vocabulary mismatch. Missions unlock in order; load each setup, fix it, and earn more stars for higher nDCG or fewer candidates. Use New random seed to make sure a tuned setting is not an accident of one corpus.

What the model assumes

Documents draw 35% of tokens from frequent low-IDF words, 25% from six distinctive terms and the rest from their topic vocabulary; 70% carry a unique identifier. Identifier queries contain the identifier plus a topic word, and their embeddings carry almost no document-specific signal. Paraphrased questions use mostly topic words other than the document's distinctive terms, while their embeddings carry the document's meaning plus noise. The out-of-domain event raises embedding noise; vocabulary mismatch reduces term overlap. Each query has one relevant document.

What it cannot tell you

Real queries have several relevant documents, graded relevance, misspellings and analysers that change what BM25 sees. Real embedding errors are structured, not Gaussian. The model ignores latency, rerankers and multi-field BM25. Use it to understand why fusion helps and how k, weights and depth change the outcome, then tune on your own labelled queries.

Read the full explanation

All AI in Production labs · Lab catalog

Views are my own and do not represent any employer, past or present.