Inferensys

Glossary

Candidate Generation

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.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
HIGH-RECALL RETRIEVAL

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.

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.

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.

HIGH-RECALL RETRIEVAL

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.

01

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.

02

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.
03

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.
04

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.
05

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.
06

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.
CANDIDATE GENERATION

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.

RETRIEVAL PIPELINE STAGES

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.

FeatureCandidate GenerationRe-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

Prasad Kumkar

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.