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.
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.