Candidate generation is the first-pass retrieval stage in a multi-stage retrieval architecture, designed to maximize recall at the expense of precision. It employs computationally cheap algorithms—such as approximate nearest neighbor (ANN) search over dense embeddings or BM25 sparse keyword matching—to rapidly scan the entire corpus. The goal is not to find the single best answer but to cast a wide net, ensuring the truly relevant documents survive into the candidate pool for downstream processing.
Glossary
Candidate Generation

What is Candidate Generation?
Candidate generation is the initial, high-recall phase of a retrieval pipeline that efficiently narrows a corpus of millions or billions of documents down to a manageable set of hundreds or thousands of potential matches for subsequent re-ranking.
This stage often leverages ensemble retrieval strategies, combining results from heterogeneous systems like dense passage retrieval (DPR) and learned sparse retrieval to mitigate individual weaknesses. The output is a fused, unranked or coarsely ranked set of candidates, typically using techniques like reciprocal rank fusion (RRF) to merge lists. This candidate set then feeds into a more expensive cross-encoder reranking model, which performs fine-grained relevance scoring to produce the final, high-precision ordering.
Key Characteristics of Candidate Generation
The initial retrieval stage must efficiently scan millions of documents to surface a broad set of potential matches, prioritizing recall over precision to ensure no relevant document is missed before downstream re-ranking.
High Recall, Low Latency
The primary objective is to maximize recall—the fraction of all relevant documents that are retrieved—while maintaining strict latency budgets typically under 100 milliseconds. This stage trades precision for coverage, accepting that many candidates will be irrelevant. Techniques like Approximate Nearest Neighbor (ANN) search and inverted index lookup are employed because they operate in sub-linear time, making them viable for corpus sizes exceeding one billion documents.
Multi-Modal Retrieval Sources
Candidate generation often combines results from heterogeneous retrieval systems to overcome individual weaknesses:
- Dense Vector Search: Captures semantic similarity using embeddings from models like DPR or ColBERT.
- Sparse Lexical Search: Uses BM25 or Learned Sparse Retrieval for exact keyword matching and handling of rare terms.
- Metadata Filtering: Applies structured constraints like date ranges or document types to prune the candidate set before or after vector search. This ensemble approach ensures robustness against vocabulary mismatches and semantic gaps.
Index Structures for Scale
Efficient candidate generation relies on specialized data structures that avoid exhaustive corpus scans:
- Hierarchical Navigable Small World (HNSW): A graph-based ANN index providing logarithmic search complexity by traversing multi-layered proximity graphs.
- Product Quantization (PQ): Compresses high-dimensional vectors into compact codes, dramatically reducing memory footprint for billion-scale indexes.
- Inverted Index: Maps each vocabulary term to a postings list of document IDs, enabling constant-time Boolean and ranked retrieval for sparse representations.
Query Pre-Processing Pipeline
Raw user queries are rarely optimal for direct index lookup. A pre-processing pipeline transforms them to improve match probability:
- Query Rewriting: Expands or reformulates the query into multiple alternative versions to cover different phrasings.
- Intent Classification: Categorizes the query to trigger domain-specific retrieval logic or metadata filters.
- Query Embedding Generation: Encodes the processed query into a dense vector using the same model that indexed the document corpus, ensuring representation alignment.
Fusion and Normalization
When multiple retrieval sources contribute candidates, their raw scores are uncalibrated and cannot be directly compared. Fusion algorithms solve this:
- Reciprocal Rank Fusion (RRF): Merges ranked lists by assigning a score based on the reciprocal of each document's rank position, requiring no score calibration.
- Weighted Sum Fusion: Combines normalized scores using pre-defined weights reflecting each system's trustworthiness.
- Score Calibration: Transforms raw scores into probabilities using techniques like Platt scaling before fusion.
Pre-Filtering vs. Post-Filtering
Metadata constraints can be applied at different stages of the retrieval pipeline, each with distinct trade-offs:
- Pre-Filtering: Applies filters to the index before vector search, ensuring only valid documents are considered. This guarantees results satisfy constraints but can be computationally expensive if filters are highly selective.
- Post-Filtering: Performs ANN search first, then applies filters to the top results. This is faster but risks returning empty result sets if the initial semantic matches do not satisfy the metadata criteria.
Frequently Asked Questions
Clear answers to common questions about the high-recall first stage of modern retrieval pipelines, covering algorithms, architectures, and performance trade-offs.
Candidate generation is the initial, high-recall phase of a retrieval pipeline that efficiently narrows a corpus of millions or billions of documents down to a manageable set of hundreds or thousands of potential matches. Its primary goal is to maximize recall—ensuring that all possibly relevant documents are included in the candidate set—while operating under strict latency constraints. This stage typically uses computationally cheap scoring functions, such as BM25 for sparse lexical matching or approximate nearest neighbor (ANN) search over dense vector embeddings, to avoid the prohibitive cost of applying a precise but expensive model to the entire corpus. The generated candidates are then passed to a series of progressively more expensive re-ranking stages that apply fine-grained relevance scoring to produce the final ordered results.
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.
Candidate Generation vs. Re-ranking
A comparison of the two fundamental stages in a multi-stage retrieval architecture, highlighting their distinct roles, computational profiles, and optimization targets.
| Feature | Candidate Generation | Re-ranking |
|---|---|---|
Primary Goal | High Recall | High Precision |
Corpus Size | Millions to Billions | Hundreds to Thousands |
Model Architecture | Bi-Encoder or Sparse Retriever | Cross-Encoder |
Query-Document Interaction | Independent Encoding | Joint Processing |
Scoring Mechanism | Cosine Similarity or BM25 | Full Attention Relevance Score |
Latency per Document | < 1 ms | 10-50 ms |
Indexing Requirement | Pre-computed Vector Index | None (Real-time Processing) |
Typical Algorithm | HNSW or Inverted Index | BERT-based Cross-Encoder |
Related Terms
Explore the core algorithms and architectural patterns that power the candidate generation phase, from dense vector search to sparse lexical matching and fusion strategies.
BM25
A probabilistic bag-of-words retrieval function that ranks documents by estimating the relevance of term frequencies. It accounts for document length normalization and term saturation.
- Mechanism: Calculates TF-IDF-like scores with non-linear term frequency saturation.
- Key Benefit: Provides a robust, computationally cheap baseline for lexical matching.
- Role: The standard sparse retrieval component in hybrid systems, excelling at exact keyword and rare term matching.
Approximate Nearest Neighbor (ANN)
A class of algorithms that trade a small amount of accuracy for significant speed improvements when finding the closest vectors in high-dimensional embedding spaces.
- HNSW: A graph-based algorithm constructing a multi-layered navigable structure for logarithmic time complexity search.
- Product Quantization (PQ): A compression technique that decomposes vectors into sub-vectors and quantizes them using a learned codebook to reduce memory footprint.
- Role: The computational backbone enabling scalable dense vector candidate generation.
Reciprocal Rank Fusion (RRF)
An algorithm that merges multiple ranked result lists into a single ranking by assigning a score based on the reciprocal of each document's rank position.
- Formula:
score(d) = Σ 1 / (k + rank_i(d))where k is a constant (typically 60). - Key Benefit: Effectively balances contributions from heterogeneous retrieval systems without requiring score calibration.
- Role: The primary fusion method for combining dense and sparse candidate sets into a unified list for re-ranking.
Learned Sparse Retrieval
A technique using neural models to predict term importance weights for vocabulary tokens, generating sparse vector representations.
- Mechanism: Models like SPLADE use MLM-based expansion and logarithmic saturation to predict token weights.
- Key Benefit: Combines the lexical precision of an inverted index with the contextual awareness of deep learning.
- Role: A modern alternative to BM25 that bridges the gap between sparse and dense retrieval.
Multi-Stage Retrieval
A cascading pipeline architecture where an initial, computationally cheap first-pass retrieval stage generates a broad set of candidates, which is then progressively refined.
- Stage 1 (Candidate Generation): High-recall, low-precision retrieval using ANN or BM25 to narrow from billions to hundreds.
- Stage 2 (Re-ranking): Expensive cross-encoder models score the pruned candidate set for high precision.
- Key Benefit: Balances the opposing demands of massive scale and deep semantic understanding.

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