Two-stage retrieval is an information retrieval architecture where a fast, recall-oriented first-stage retriever (e.g., BM25 or a dual encoder) fetches a broad set of candidate documents, which are then reordered by a slower, precision-oriented second-stage reranker (e.g., a cross-encoder). This design optimizes the trade-off between search speed and result accuracy, making it foundational for production RAG systems. The first stage maximizes recall, ensuring relevant information is in the candidate pool, while the second stage refines precision by deeply analyzing context.
Glossary
Two-Stage Retrieval (Retrieve-and-Rerank)

What is Two-Stage Retrieval (Retrieve-and-Rerank)?
Two-stage retrieval, or retrieve-and-rerank, is a hybrid search architecture designed to balance high recall with high precision in information retrieval systems like Retrieval-Augmented Generation (RAG).
The reranker, typically a computationally intensive cross-encoder, performs a full-attention joint analysis of the query and each candidate, producing a more accurate relevance score than the initial similarity search. This stage filters out irrelevant candidates and boosts the most pertinent documents to the top of the list before they are passed to a large language model. This architecture is a core component of hybrid retrieval systems, combining the scalability of approximate nearest neighbor search with the nuanced understanding of transformer-based reranking models.
Key Components of a Two-Stage System
A two-stage retrieval (retrieve-and-rerank) system decomposes the search problem into two specialized phases: a fast, broad-coverage first stage and a slow, high-precision second stage. This architecture optimizes the trade-off between recall and latency.
First-Stage Retriever
The first-stage retriever is optimized for high recall and low latency. Its primary function is to rapidly scan a massive corpus (millions to billions of documents) and return a manageable candidate set (e.g., 100-1000 documents).
- Common Implementations: Sparse retrievers like BM25 or fast dense retrievers using a dual encoder architecture (e.g., DPR, SBERT).
- Key Characteristic: Uses efficient, pre-computed indexes—an inverted index for sparse methods or a vector index (e.g., HNSW, IVF) for dense methods—to enable approximate nearest neighbor (ANN) search.
- Output: A ranked list of candidate documents where the goal is to ensure the truly relevant documents are within the retrieved set, even if the ranking is imperfect.
Second-Stage Reranker
The second-stage reranker is a precision-oriented model that reorders and scores the candidate set from the first stage. It is computationally intensive but operates on a small subset, making the cost manageable.
- Common Implementation: A cross-encoder model, which jointly processes a query-document pair through a transformer to produce a fine-grained relevance score.
- Key Advantage: Achieves much higher precision and ranking accuracy than the first stage by performing deep, contextual interaction between the query and each candidate.
- Trade-off: Speed. Reranking 100 documents with a cross-encoder is significantly slower than the initial retrieval of those 100 documents, which is why it's applied only to a shortlist.
Hybrid First-Stage Retrieval
Modern systems often use a hybrid retrieval approach in the first stage to maximize recall. This combines the strengths of sparse and dense methods.
- Method: Executes both a sparse retrieval (e.g., BM25) and a dense retrieval (vector search) in parallel. The results are merged into a single candidate list.
- Fusion Technique: Uses algorithms like Reciprocal Rank Fusion (RRF) to combine the ranked lists without requiring score normalization. RRF is robust and effective for this purpose.
- Benefit: Captures both exact keyword matches (crucial for specific entities, codes, or jargon) and semantic matches (for conceptual or paraphrased queries), ensuring comprehensive coverage.
Candidate Set & Latency Budget
The size of the candidate set passed from the first to the second stage is a critical engineering parameter that directly impacts system latency and accuracy.
- Engineering Trade-off: A larger candidate set (e.g., 200 docs) increases the chance of including all relevant documents (higher recall) but linearly increases reranking latency and cost. A smaller set (e.g., 50 docs) is faster but risks missing relevant results.
- Determining Factors: The optimal size is determined by the latency budget (e.g., < 200ms total) and the performance characteristics of the retrievers. It is typically tuned via offline evaluation on a validation set.
- Practical Range: In production RAG systems, candidate sets commonly range from 50 to 200 documents.
Indexing & Embedding Pipeline
A robust indexing pipeline is the offline foundation that feeds both retrieval stages. It prepares the document corpus for efficient online querying.
- For Sparse Retrieval: Builds an inverted index from tokenized document text, often with stopword removal and stemming/lemmatization.
- For Dense Retrieval: Uses an embedding model (e.g., text-embedding-ada-002, BGE-M3) to generate document embeddings for every chunk. These vectors are then indexed in a specialized vector database like Pinecone, Weaviate, or using a library like FAISS.
- Pre-computation: All document representations (sparse vectors, dense vectors) are computed and indexed offline, which is what makes the first-stage retrieval so fast.
First-Stage vs. Second-Stage: A Technical Comparison
A detailed comparison of the distinct roles, technical characteristics, and performance trade-offs between the first-stage retriever and the second-stage reranker in a retrieve-and-rerank pipeline.
| Feature / Metric | First-Stage Retriever | Second-Stage Reranker |
|---|---|---|
Primary Objective | Maximize Recall | Maximize Precision |
Core Function | Fetch a broad candidate set (e.g., top-1000) | Re-rank the candidate set for final ordering |
Typical Model Architecture | Dual Encoder (Bi-Encoder), Sparse (BM25) | Cross-Encoder |
Inference Latency | < 10 ms | 10-100 ms per candidate pair |
Query-Document Interaction | Independent encoding, late similarity (e.g., dot product) | Full, joint attention across the query-document pair |
Indexing Requirement | Requires pre-built index (vector or inverted) | Stateless; operates on provided text pairs |
Common Algorithms / Models | BM25, DPR, Sentence Transformers, ColBERT | MonoT5, BERT-based cross-encoders, RankT5 |
Output | Ranked list of candidate IDs/scores | Refined ranked list with recalibrated scores |
Scalability to Large Corpora | Highly scalable via ANN search (HNSW, IVF) | Not scalable; applied only to ~100-1000 candidates |
Primary Use Cases and Applications
The retrieve-and-rerank architecture is deployed to balance the competing demands of recall, precision, and computational efficiency in production retrieval systems. Its primary applications are in domains where the cost of a missed relevant document is high.
Enterprise Search & RAG Pipelines
This is the most common application, where a fast first-stage retriever (like BM25 or a dual encoder) fetches 100-1000 candidate documents from a massive corpus. A powerful cross-encoder then reorders these candidates to surface the most relevant 5-10 passages for the Large Language Model context window. This ensures the LLM receives high-precision grounding data, directly mitigating hallucinations.
- Key Benefit: Maximizes the chance of including the 'needle in the haystack' document (high recall) while ensuring the most relevant documents are prioritized (high precision).
- Example: A legal RAG system searches millions of case files; BM25 ensures all documents mentioning key statutes are retrieved, and the cross-encoder identifies the most precedential cases for the query.
Question Answering & Chatbots
For open-domain QA, the first stage retrieves a broad set of potentially relevant facts or paragraphs from a knowledge base (e.g., Wikipedia). The reranker evaluates each candidate's direct relevance to the specific question's intent, filtering out tangentially related or out-of-context information. This is critical for producing concise, accurate answers.
- Key Benefit: Dramatically improves answer accuracy by ensuring the final context contains the exact evidence needed, not just semantically similar text.
- Architecture: Often uses Dense Passage Retrieval (DPR) for stage 1 and a BERT-based cross-encoder (e.g.,
cross-encoder/ms-marco-MiniLM-L-6-v2) for stage 2.
Document Ranking & Recommendation
Used in systems that must personalize or prioritize content from a large inventory, such as news feeds, e-commerce product listings, or internal knowledge base articles. The first stage applies broad user interest or content filters. The second stage uses a fine-tuned reranker to predict engagement (click-through rate, dwell time) or relevance for the specific user context.
- Key Benefit: Enables real-time personalization at scale by decoupling broad filtering from fine-grained scoring.
- Contrast with Learned Retrieval: Unlike a single end-to-end model, this architecture allows the reranker to be updated frequently with new engagement data without rebuilding the entire retrieval index.
Hybrid Search Orchestration
Two-stage retrieval naturally complements hybrid retrieval. The first stage can execute parallel sparse (BM25) and dense (vector) searches, merging their results using a technique like Reciprocal Rank Fusion (RRF). This merged list, rich in both lexical and semantic matches, is then passed to the reranker for final precision scoring.
- Key Benefit: The reranker acts as a sophisticated judge, resolving conflicts between lexical and semantic signals to produce a unified, optimal ranking.
- System Design: This is a core pattern in platforms like Elasticsearch with a vector search plugin, where a
knnsearch and abm25query are combined before a rescoring script (the reranker) is applied.
Mitigating Embedding Model Limitations
Dense retrieval can fail on out-of-domain vocabulary, long-tail entities, or exact keyword matches. A first-stage sparse retriever (BM25) guarantees coverage for these cases. The subsequent reranker, which sees the full text, can then down-rank irrelevant keyword matches and up-rank semantically correct results that the dense retriever may have missed.
- Key Benefit: Provides a robustness safety net, ensuring the system doesn't fail completely if the embedding model encounters unfamiliar terminology.
- Example: Searching for 'JVM' in a tech corpus. BM25 retrieves documents containing the acronym. The reranker identifies which documents are actually about the Java Virtual Machine versus those just mentioning 'JVM' in a list.
Computational Efficiency at Scale
The architecture is fundamentally an optimization. Running a heavyweight cross-encoder on every document in a million-document corpus is infeasible. By limiting its application to a small candidate set (e.g., 100 docs), the system achieves near-state-of-the-art accuracy with tractable latency and cost.
- Key Trade-off: The system's upper-bound accuracy is capped by the recall@K of the first stage. If the correct document is not in the initial candidate set, the reranker cannot recover it.
- Performance: Typical latency is dominated by the first-stage ANN search (milliseconds) plus the reranker inference on K documents (tens to hundreds of milliseconds).
Frequently Asked Questions
Two-stage retrieval, or retrieve-and-rerank, is a production-grade architecture for high-accuracy search. It balances the speed of initial candidate fetching with the precision of deep neural reordering. These FAQs address its core mechanisms, trade-offs, and implementation for enterprise RAG systems.
Two-stage retrieval is an information retrieval architecture designed to optimize both recall and precision by separating the search process into two distinct phases. In the first stage (retrieval), a fast, recall-oriented model—such as BM25 for sparse retrieval or a dual encoder for dense retrieval—scans a large corpus to fetch a broad set of candidate documents (e.g., 100-1000). This stage prioritizes speed and ensuring the relevant document is in the candidate pool. In the second stage (reranking), a slower, computationally intensive but highly accurate model—typically a cross-encoder—jointly processes the query with each candidate to produce a refined relevance score. The final list is reordered based on these scores, delivering high-precision top results.
This decoupled design is fundamental to scalable Retrieval-Augmented Generation (RAG), as it allows the system to use an efficient approximate nearest neighbor (ANN) search over millions of vectors initially, then apply a powerful but expensive model only to a manageable subset.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Two-stage retrieval relies on a pipeline of distinct components. These related terms define the core models, algorithms, and infrastructure that make the retrieve-and-rerank architecture function.
Dual Encoder (Bi-Encoder)
A neural network architecture used as the first-stage retriever. It encodes queries and documents independently into fixed-dimensional vector embeddings. This design enables efficient similarity search via a pre-built vector index, as embeddings can be pre-computed and cached. It prioritizes high recall and low latency over perfect precision.
- Key Trait: Encodes inputs separately for fast, approximate retrieval.
- Common Use: Initial candidate fetching in two-stage pipelines.
- Example Model: Models fine-tuned for Dense Passage Retrieval (DPR).
Cross-Encoder
A neural model used as the second-stage reranker. It takes a query-document pair as a single, concatenated input and outputs a precise relevance score through joint processing. This architecture captures deep, cross-attention interactions but is computationally expensive, making it ideal for reordering a small set of candidates (e.g., 100-1000) retrieved by a faster first stage.
- Key Trait: Joint processing of query-document pairs for high-precision scoring.
- Common Use: Reranking in two-stage systems, answer selection.
- Performance: Typically achieves higher accuracy than dual encoders for ranking.
BM25 (Okapi BM25)
A probabilistic ranking function and the dominant algorithm for sparse retrieval. It serves as a common first-stage retriever in hybrid two-stage systems. BM25 scores documents based on term frequency, with built-in term frequency saturation and document length normalization to prevent very long documents from dominating results.
- Key Trait: Lexical, keyword-based matching using bag-of-words statistics.
- Role in Two-Stage: Provides high recall of documents containing query keywords.
- Advantage: Zero-shot effectiveness without training data.
Approximate Nearest Neighbor (ANN) Search
A class of algorithms that enable fast similarity search in high-dimensional vector spaces, critical for the first-stage dense retriever. ANN algorithms trade off exact precision for orders-of-magnitude speed improvements, allowing real-time search over millions or billions of embeddings.
- Common Algorithms: HNSW (Hierarchical Navigable Small World), IVF (Inverted File Index).
- Key Trade-off: Configurable balance between recall@k, query latency, and memory usage.
- Implementation Libraries: Faiss, ScaNN, vector database native indexes.
Reciprocal Rank Fusion (RRF)
A score fusion technique used to combine ranked lists from multiple first-stage retrievers (e.g., BM25 and a dense retriever) into a single list for the reranker. RRF is robust because it operates on ranks rather than raw scores, which can have incompatible distributions. It sums the reciprocal of the ranks from each list.
- Formula:
score(doc) = Σ (1 / (k + rank_i(doc)))across all lists. - Advantage: No need for complex score normalization between different retrievers.
- Use Case: Creating a unified candidate set in hybrid two-stage retrieval.
Learned Retrieval
An umbrella term for retrieval systems where the ranking function or embedding model is trained end-to-end on relevance labels, as opposed to using hand-crafted functions like BM25. In two-stage retrieval, both the first-stage dual encoder and second-stage cross-encoder are examples of learned components.
- Contrast: vs. lexical retrieval (rule-based, like BM25).
- Training Data: Requires query-document relevance pairs (e.g., clicks, human annotations).
- Goal: Optimize the model's parameters directly for the retrieval task.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us