Reranking
A second-stage retrieval step where a Cross-Encoder jointly inspects each query–document pair from a fast first-stage candidate pool to produce highly accurate final rankings
Table of Contents
Structure Diagram
Independent vectors · Ultra-fast
- ScaleMillions of docs → Top 30–50
- InteractionSingle vector dot product only
- Latency10–30ms via precomputed index
Joint full attention · High precision
- ScaleTop 30–50 → Sharpest Top 3–5
- InteractionToken-level cross-attention scoring
- ImpactCuts noise, tokens & hallucinations
What is Reranking?
A second-stage retrieval step where a Cross-Encoder jointly inspects each query–document pair from a fast first-stage candidate pool to produce highly accurate final rankings. It is a core concept in Retrieval & RAG within AI / ML.
Core Principles
First-stage Bi-Encoder retrieval compresses queries and documents independently, enabling millisecond search over millions of records at the cost of fine-grained token interaction.
Reranking feeds the top 20–50 candidates as (query, document) pairs into a Cross-Encoder that performs full token-to-token attention across both texts. This produces dramatically sharper relevance scores, ensuring only the best 3–5 passages enter the LLM's context window.
Practical Takeaways
- Highest-ROI RAG upgrade: Adding a reranker frequently improves answer accuracy more cheaply than upgrading to a larger LLM or fine-tuning.
- Balance candidate pool size and latency: Reranking cost scales linearly with candidate count. A
Top-30 → Top-5funnel typically hits the sweet spot (~50–150ms added latency). - Apply a relevance score cutoff: If even the top reranked chunk falls below your calibrated score threshold, skip generation or trigger abstention to prevent hallucinations.
Notable Examples
- Cohere Rerank & BGE-Reranker: Widely deployed commercial and open-weights multilingual Cross-Encoders for production RAG.
- Multi-Source Federation: Merges and uniformly ranks heterogeneous results pulled from wikis, tickets, and chat logs.
- Context Budget Optimization: Sends 5 precision-ranked chunks instead of 20 noisy ones, lowering LLM input costs and latency.