Chapter 12: Hybrid retrieval inside the loop

Run two searches and merge them. The vector search returns the 20 closest chunks. The keyword search returns the 20 best BM25 matches. Reciprocal Rank Fusion merges the two lists by rank. Each chunk scores the sum of 1 divided by 60 plus its rank in each list.

Figure 12.1. Hybrid retrieval. RRF uses rank positions, not raw scores, so a vector distance and a BM25 score never need to be compared. Chapter 13 adds filters and a reranker.

Worked example of the RRF formula. A chunk ranked 1st in the vector list and 3rd in the keyword list scores 1/61 + 1/63 ≈ 0.0323. A chunk ranked 2nd in the vector list only scores 1/62 ≈ 0.0161. Appearing in both lists wins.

Expose the merged search as a tool. Require a citation for each claim. If the answer has no citation and does not say no match, send one correction. Stop if it still has none.

Figure 12.2. One correction, never a second. The chapter does not name the stop reason for an uncited answer.
docs