Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Two librarians and an expert
One librarian matches the exact words you wrote: perfect for a part number, useless if you used a different word from the manual. Another understands meaning: great for ‘how do I stop the pump from overheating’, poor at telling part P-4471 from P-4417. Asking both and merging their lists catches what either would miss. An expert then reads the merged short list carefully and puts the best answers first. The demo shows how rank fusion combines two lists.
Hybrid retrieval with reranking is the default for production RAG over technical documents, which are full of identifiers, codes and abbreviations as well as prose.
- 1. BM25 is strong at…
- 2. Dense search is strong at…
- 3. A reranker…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Sparse retrieval: BM25 or learned sparse models (SPLADE) over an inverted index; exact matches, interpretable, no training.
- Dense retrieval: bi-encoders embed query and document separately; fast with ANN (F10-3); captures meaning; weak on rare strings and out-of-domain jargon.
- Rank fusion: reciprocal rank fusion (RRF) sums 1/(k + rank) with k ≈ 60; needs no score calibration but ignores how decisive a score is.
- Score fusion: normalise scores (min-max or z-score) and take a weighted sum; uses magnitudes; the weight needs tuning.
- Reranking: a cross-encoder scores each (query, candidate) pair with full attention between them; far more accurate than a bi-encoder, but too slow for the whole corpus, so it rescores the top 20–100. ColBERT-style late interaction is in between.
- LLM rerankers: prompting a language model to judge relevance; strong but costly.
- Evaluation: recall@k for the candidate stage; MRR or nDCG@10 for the final order.
- 1. RRF score of a document:
- 2. A cross-encoder reads…
- 3. Rerankers are applied to…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Building a hybrid retriever
Exercise 1.
- Reciprocal rank fusion.
- Min-max score fusion with a weight.
- Mean reciprocal rank.
Practice.
- Elasticsearch, OpenSearch, Weaviate, Qdrant and Vespa support hybrid queries natively.
- Rerankers: BGE-reranker, Cohere Rerank, cross-encoder/ms-marco models in sentence-transformers.
- Retrieve 50–100 candidates from each retriever, fuse, rerank, keep 5–10 for the prompt.
- Tune the fusion weight and reranker depth on real queries; look at failures by query type (identifiers, paraphrases, acronyms).
- Domain jargon: fine-tune the embedding model or add a synonym and acronym list to BM25.
from sentence_transformers import CrossEncoder
ce = CrossEncoder("BAAI/bge-reranker-base")
def search(q, k=5):
cand = rrf([bm25_top(q, 50), dense_top(q, 50)])[:50]
scores = ce.predict([(q, chunks[i]) for i in cand])
return [cand[i] for i in np.argsort(-scores)[:k]]- 1. A common RRF constant k:
- 2. A cross-encoder reranker model:
- 3. Analyse failures by…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Complementary errors. BM25 matches surface tokens: an identifier appearing in one document gets a large inverse document frequency and an unambiguous top rank, but a paraphrase sharing no words scores zero. A bi-encoder compresses a text into one vector; frequent concepts are well represented, rare strings are not, so it ranks by topic rather than identity.
Rank versus score fusion. RRF gives the first item of each list the same credit, 1/(k + 1), regardless of whether it won by a mile or by a hair. When one retriever is certain and the other is guessing, rank fusion can tie the certain answer with the guess. Score fusion keeps the margin but depends on comparable score scales; z-score normalisation per query is a robust default.
Why rerankers help. A bi-encoder must commit to a document vector before seeing the query; a cross-encoder attends across both and can check exact matches and meaning together. Its accuracy is bounded by the candidate stage’s recall.
- 1. RRF ignores…
- 2. A bi-encoder represents rare strings…
- 3. Reranker accuracy is bounded by…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.When does keyword search beat dense search, how should their results be fused, and what does a reranker add?
History.
- S. Robertson and H. Zaragoza, “The probabilistic relevance framework: BM25 and beyond” (2009).
- G. Cormack, C. Clarke and S. Büttcher, “Reciprocal rank fusion outperforms Condorcet and individual rank learning methods” (SIGIR 2009).
- V. Karpukhin et al., “Dense passage retrieval” (2020); R. Nogueira and K. Cho, “Passage re-ranking with BERT” (2019); O. Khattab and M. Zaharia, “ColBERT” (2020).
Exercise 2. 3000 documents, each mentioning 6 of 400 concepts with one of 3 synonyms each, plus a unique part number.
- Dense model: synonyms share an embedding; part numbers get a weak random direction; embeddings carry noise.
- Queries: 300 paraphrased (3 of the target’s concepts, synonyms chosen at random) and 300 keyword (part number + one concept word).
- Reranker: a stand-in cross-encoder scoring concept overlap and exact part-number match with noise, applied to the RRF top 50.
| retriever | recall@10 paraphrase | MRR paraphrase | recall@10 part number | MRR part number |
|---|---|---|---|---|
| BM25 | 0.410 | 0.325 | 1.000 | 1.000 |
| dense | 0.663 | 0.422 | 0.093 | 0.030 |
| RRF (k = 60) | 0.743 | 0.481 | 0.883 | 0.273 |
| z-score fusion, 0.5 / 0.5 | 0.687 | 0.572 | 1.000 | 1.000 |
| RRF + rerank top 50 | 0.910 | 0.764 | 1.000 | 0.986 |
- Opposite failures: BM25 missed paraphrases; dense search could not find part numbers.
- RRF helped paraphrases but hurt part numbers: BM25’s certain answer at rank 1 tied with dense search’s top guess, so MRR fell from 1.0 to 0.27, and 12% fell out of the top 10.
- Score fusion kept BM25’s large margin on identifiers.
- The reranker gave the best of both, limited by the fused top 50.
- Seeds 1 and 2: RRF + rerank paraphrase recall 0.897 and 0.910; RRF part-number MRR 0.253 and 0.314.
- Caveat: the reranker is a simulated scorer that knows the concept structure; real cross-encoders are strong but not this well informed.
Hybrid retrieval in AI, robotics and aerospace
- Maintenance documentation: part numbers, fault codes and torque values need exact match; symptom descriptions need meaning.
- Requirements traceability: requirement identifiers plus semantic search over requirement text.
- Incident reports: acronyms and call signs (keyword) alongside free-text narratives (dense).
References
- S. Robertson and H. Zaragoza (2009). “The probabilistic relevance framework: BM25 and beyond.” Foundations and Trends in IR.
- G. V. Cormack, C. L. A. Clarke and S. Büttcher (2009). “Reciprocal rank fusion outperforms Condorcet and individual rank learning methods.” SIGIR.
- R. Nogueira and K. Cho (2019). “Passage re-ranking with BERT.” arXiv:1901.04085.
- O. Khattab and M. Zaharia (2020). “ColBERT: efficient and effective passage search via contextualized late interaction over BERT.” SIGIR.