Lesson 05.04 · Phase 05 · Retrieval & Agentic RAG

Reranking

Retrieve wide and cheap, then read each candidate next to the question and reorder. A reranker can only choose among what the first stage found, and more candidates also means more ways to be fooled.

Learning objectives

  • Explain two-stage retrieval: a fast first stage for recall, a slower pair-wise reranker for precision.
  • Implement a reranker that scores (query, chunk) pairs together, offline and with a model as a relevance grader.
  • Measure precision at 1, the recall ceiling of the first stage, and the number of reranker calls for different candidate pool sizes.
  • Choose the candidate pool size from measurements, knowing that a larger pool raises the ceiling and also adds distractors.

A first-stage retriever compares one vector for the query with one vector per chunk. It never looks at the query and a chunk together. That is what makes it fast enough to search millions of chunks, and it is also why it ranks "Claims for a faulty toaster need the order number" above "To make a warranty claim, send the order number and a photo of the fault" when you ask about a faulty kettle. Both look like "claims, faulty, order number".

Loading the full lesson…