Skip to content
GenAI Learn/Vector Search Fundamentals
Browsing as a guest. Sign in to save your progress and earn XP as you complete chapters.

Reranking for Precision

6 min read

You'll learn to

  • -Understand why an initial retrieval pass often needs a second reranking pass
  • -Compare bi-encoders (used for retrieval) to cross-encoders (used for reranking)
  • -Explain why cross-encoders don't replace vector search for the initial retrieval step

A medical RAG system retrieves ten chunks for every query, but the actually relevant one is frequently sitting at position five through eight, not position one. For a doctor scanning results under time pressure, or worse, for an LLM given all ten chunks with no signal about which one actually matters most, that buried ranking is a real, sometimes urgent, problem.

Bi-Encoders: Fast, and a Little Imprecise

The embedding models used for the initial retrieval pass (covered across the last two chapters) are bi-encoders: the query and every document are embedded completely independently, with no interaction between them, and then compared by a simple, fast operation like cosine similarity. This independence is exactly what makes vector search fast enough to search millions of documents: every document's embedding is precomputed once, ahead of any query, and a new query only has to be embedded and compared once each. The cost of that speed is precision: the model never actually reads the query and a specific document together, so it can miss nuanced relevance that only becomes clear when the two are considered jointly.

Cross-Encoders: Slow, and Much More Precise

A cross-encoder takes the query and a single candidate document together, as one combined input, and outputs a direct relevance score for that specific pair. Because it reads both texts jointly, in the same forward pass, it captures interactions a bi-encoder's independent embeddings structurally cannot, but that also means it has to be run once per candidate document, no precomputation possible, which makes it far too slow to run against an entire corpus of millions of documents.

Query: "Is it safe to take aspirin with my Warfarin prescription?"

10 chunks retrieved by fast vector search. The actual answer isn't at the top.

1General overview of blood thinner medications
2Common side effects of anticoagulant therapy
3History of anticoagulant drug development
4Dosage guidelines for elderly patients
5Pharmacy inventory management for anticoagulants
6Warfarin and aspirin: dangerous interaction and bleeding risk← the actual answer
7Patient monitoring schedule for blood thinners
8Insurance coverage for anticoagulant prescriptions
9Comparing generic vs. brand-name blood thinners
10Anticoagulant clinic scheduling procedures

Vector search alone found the right neighborhood, but ranked by rough similarity, not by carefully reading each chunk against the exact question.

Why You Need Both, in Two Stages

This is exactly why reranking is a second stage layered on top of retrieval, not a replacement for it. Vector search (a bi-encoder, cheap and precomputable) narrows millions of documents down to a manageable shortlist, typically the top 20 to 100 candidates. A cross-encoder then reranks only that small shortlist, applying its more expensive but far more accurate scoring where it can actually afford to. Running a cross-encoder against the whole corpus for every query would be prohibitively slow; running only a cheap bi-encoder and trusting its top result blindly leaves exactly the precision problem this chapter opened with.

Precision vs. Recall Across the Two Stages
Stage 1 (bi-encoder)
Optimizes for recall: do not miss the right document
Stage 2 (cross-encoder)
Optimizes for precision: get the ordering of the shortlist right
~10-100x slower
Roughly, cross-encoder scoring cost vs. bi-encoder, per document
20-100 candidates
A typical reranking shortlist size, small enough to afford the cost

Interview Signal is part of Pro

See a real weak answer next to a real strong one for this exact topic.

Quiz is part of Pro

Test what you just read with a short quiz, and bank the XP.

Ready to Build This?

Build the Vector Vault, Hybrid Searcher, and Reranker levels in the GenAI Lab.

ScaleDojo Logo
Initializing ScaleDojo