passdrill
AI & LLM Engineering · RAG & Embeddings · Card 024/032 medium

A hybrid retrieval pipeline runs a keyword search (BM25) and a vector similarity search against the same query in parallel, producing two separately ranked lists whose raw scores are not on comparable scales (BM25 scores are unbounded, while cosine similarity is bounded between -1 and 1). Reciprocal Rank Fusion (RRF) combines these two lists into a single final ranking without needing to normalize either list's raw scores first. How does it do this?

  1. For each document, it takes the position (rank) that document holds within each list it appears in, converts each rank into a score of 1/(rank + k) for a small constant k, and sums that value across every list the document appears in, so the fused ranking depends only on where each document placed in each list rather than on the raw scores those lists produced
  2. It discards whichever of the two lists has a lower average raw score and returns the other list unchanged, on the theory that the higher-scoring method is more trustworthy for that particular query
  3. It retrains a single embedding model on both the keyword-matched and vector-matched documents so that one unified raw score can be produced for every document going forward
  4. It re-runs a cross-encoder over every document that appears in either list, discarding both original lists' scores entirely and ranking purely by the cross-encoder's joint query-document score
Next card → Shuffle