Lesson 05.03 · Phase 05 · Retrieval & Agentic RAG

Hybrid search: BM25 + vectors

Keyword search finds the exact error code. Vector search finds the paraphrase. Fuse their rankings, not their scores, and drop the non-matches before you do.

Learning objectives

  • Implement BM25 from scratch and explain its three ingredients: inverse document frequency, saturating term frequency, and length normalisation.
  • Explain which queries keyword search wins (identifiers, codes, names) and which vector search wins (paraphrases).
  • Implement reciprocal rank fusion (RRF), and explain why it fuses ranks instead of scores.
  • Avoid the most common hybrid bug: letting zero-score keyword "matches" vote in the fusion.

Support agents get two kinds of questions. Some contain an exact identifier: "what does ERR-4012 mean?", "KT-250 warranty". Others are paraphrases: "stop my membership" for a document that says "cancel a subscription".

Loading the full lesson…