Recall@k is a metric that measures the proportion of the true k nearest neighbors found within the top k results returned by an approximate search algorithm. It is defined as the number of relevant items retrieved divided by k, where a perfect score of 1.0 indicates the algorithm found all ground-truth neighbors. This metric directly quantifies the retrieval accuracy of an index like HNSW or IVF, trading off against query latency in the recall-latency Pareto frontier that governs ANN system design.
Glossary
Recall@k

What is Recall@k?
Recall@k is a core evaluation metric for approximate nearest neighbor (ANN) search systems, quantifying the retrieval accuracy of a vector index by measuring how many of the true nearest neighbors are found in the top results.
In practice, Recall@k is calculated by performing an exact nearest neighbor search to establish the ground-truth set, then comparing it to the approximate search results. It is the primary metric for validating that an index's approximations—introduced by techniques like product quantization or graph traversal heuristics—do not critically compromise result quality. Engineers tune parameters like search beam width or the number of Voronoi cells probed to achieve a target Recall@k while meeting latency service-level agreements for production workloads.
Key Characteristics of Recall@k
Recall@k is a core metric for evaluating the accuracy of an Approximate Nearest Neighbor (ANN) search system. It quantifies the index's ability to retrieve the true nearest neighbors.
Definition & Formula
Recall@k measures the proportion of the true k nearest neighbors (ground truth) that are present in the top k results returned by the approximate search algorithm.
It is calculated as:
Recall@k = (Number of true top-k neighbors found) / k
- A value of 1.0 (or 100%) indicates perfect retrieval: the approximate search found all the exact nearest neighbors.
- A value of 0.0 indicates a complete failure: none of the true top-k neighbors were retrieved.
- In practice, ANN systems trade perfect recall for massive speed gains, targeting high values like 0.95 or 0.99.
Trade-off with Latency & Precision
Recall@k does not exist in isolation; it is part of a fundamental trade-off triangle with search latency and index memory footprint.
- Higher Recall typically requires searching more of the index (e.g., probing more Voronoi cells in IVF, using a larger search beam width in HNSW), which increases query latency.
- To achieve a target recall level (e.g., 95%), engineers tune algorithm parameters, accepting a specific latency cost.
- Precision@k is a related metric that measures the fraction of returned results that are relevant. In ANN evaluation, high recall is often prioritized, with exact re-ranking used to ensure precision among the recalled candidates.
Dependence on Ground Truth
Calculating Recall@k requires knowing the exact k nearest neighbors for each query, which serves as the ground truth for evaluation.
- Obtaining ground truth is computationally expensive, requiring an exact nearest neighbor search (e.g., brute-force) over the entire dataset for a representative set of query vectors.
- This is only feasible for benchmarking and offline evaluation, not during production inference.
- The metric assumes the exact search results are the definitive "correct" answer, against which the approximate index's performance is judged.
Relationship to Index Parameters
Recall@k is directly controlled by the internal parameters of the vector indexing algorithm.
- For HNSW: The
efSearchparameter (size of the dynamic candidate list) is the primary lever. HigherefSearchyields higher recall but slower searches. - For IVF-based indexes: The
nprobeparameter (number of Voronoi cells to search) controls recall. Increasingnprobesearches more partitions. - For IVFPQ: Recall is affected by both
nprobe(coarse quantizer) and the fidelity of the Product Quantization codebooks (fine quantizer). More codebook centroids reduce quantization error and improve recall for a givennprobe.
Use in Benchmarking & Tuning
Recall@k is the primary metric for comparing different ANN algorithms (e.g., HNSW vs. IVF-PQ) and for tuning a single algorithm's operating point.
- Standard benchmarks (e.g., on datasets like SIFT1M or DEEP1B) plot Recall@k curves against Queries Per Second (QPS) to visualize the performance frontier.
- System architects use these curves to select the appropriate algorithm and parameters for their application's accuracy and latency requirements.
- It is often reported alongside the k value used (e.g., Recall@10, Recall@100), as performance can vary significantly with the number of requested neighbors.
Limitations and Complementary Metrics
While crucial, Recall@k has limitations that necessitate other evaluation methods.
- It is agnostic to ranking order within the top k. Returning all true neighbors in any order yields perfect recall.
- It does not measure the distance quality of the returned neighbors. A returned vector could be the 10th true nearest neighbor or the 1000th.
- Therefore, it is often used with:
- Mean Average Precision (mAP): Considers ranking order.
- Distance Ratios: Compare the approximate distance to the true nearest neighbor's distance.
- Throughput/Latency Measurements: Essential for understanding the system's operational cost.
Recall@k vs. Precision@k: A Comparison
A comparison of two core metrics for evaluating the accuracy of an Approximate Nearest Neighbor (ANN) search system, highlighting their complementary roles in measuring retrieval quality.
| Metric & Definition | Recall@k | Precision@k | Interpretation & Use Case |
|---|---|---|---|
Core Definition | Measures the proportion of the true k nearest neighbors found in the retrieved top k results. | Measures the proportion of the retrieved top k results that are among the true k nearest neighbors. | Recall@k quantifies completeness; Precision@k quantifies purity of the result set. |
Mathematical Formula | Recall@k = |{true top k} ∩ {retrieved top k}| / k | Precision@k = |{true top k} ∩ {retrieved top k}| / k | Identical numerator, different conceptual denominator (size of ideal set vs. size of returned set). |
Primary Focus | Retrieval completeness. Answers: 'Did I find all the relevant items?' | Result set relevance. Answers: 'Are my returned items mostly relevant?' | Recall is critical when missing a relevant result is costly (e.g., legal e-discovery). Precision is critical when result list slots are valuable (e.g., search engine top 10). |
Value Range | 0.0 to 1.0 (or 0% to 100%). | 0.0 to 1.0 (or 0% to 100%). | Both are scores where 1.0 represents perfect retrieval accuracy. |
Behavior with Increasing k | Non-decreasing. As k grows, it becomes easier to 'capture' more true neighbors, so recall generally rises. | Can increase or decrease. Adding more results (increasing k) may dilute the proportion of true neighbors, often causing precision to fall. | This divergence is key: optimizing for high recall@100 requires a different index tuning than optimizing for high precision@10. |
Trade-off Relationship | Inversely related to query latency and index build time for a fixed accuracy target. Higher recall often requires searching more graph edges or IVF cells. | Inversely related to recall for a fixed system configuration. Aggressive filtering for high precision can miss relevant items, lowering recall. | Defines the recall-precision curve. System tuning involves selecting an operating point on this curve based on application needs. |
Dependency on Ground Truth | Absolute. Requires knowing the exact, true k nearest neighbors via an exhaustive (slow) search on the full dataset. | Absolute. Same dependency on exhaustive ground truth for calculation. | This makes both metrics expensive to compute at scale, typically done on a representative query benchmark set. |
Typical System Tuning Knob | Search beam width (graph algorithms), nprobe (IVF), or efSearch (HNSW). Increasing these parameters boosts recall at the cost of latency. | Often tuned indirectly via recall targets or by adjusting the distance threshold on a pre-filtered candidate set. Can be boosted by exact re-ranking. | Engineers typically set a minimum recall@k target (e.g., 0.95) and then minimize latency, which implicitly sets a precision@k level. |
Practical Applications of Recall@k
Recall@k is the primary metric for quantifying the retrieval accuracy of an approximate nearest neighbor (ANN) search index. These applications demonstrate its critical role in production system design and validation.
Index Algorithm Selection
Recall@k is the decisive metric for comparing different vector indexing algorithms (e.g., HNSW, IVF, DiskANN) on a specific dataset. Engineers run benchmarks to plot recall-latency trade-off curves, enabling data-driven selection. For example, HNSW may achieve Recall@10 = 0.99 with 2ms latency, while IVF-PQ achieves 0.95 at 0.5ms, guiding the choice based on accuracy requirements.
- Key Use: Quantifying the accuracy cost of faster, more memory-efficient algorithms.
- Decision Framework: Balances Recall@k against index build time, query latency, and memory footprint.
Hyperparameter Tuning
Every ANN index has hyperparameters that directly impact Recall@k. Systematically tuning these parameters against a validation set is essential for production optimization.
- HNSW:
efConstructionandefSearchcontrol graph connectivity and search exploration depth. IncreasingefSearchdirectly improves Recall@k at the cost of latency. - IVF:
nlist(number of Voronoi cells) andnprobe(number of cells searched) are tuned. A highernprobeincreases Recall@k by searching more partitions. - Process: Engineers perform a grid search, measuring Recall@k at target
k(e.g., 10, 100) to find the optimal operating point before deployment.
Production Monitoring & SLOs
In live vector databases, Recall@k serves as a Service Level Objective (SLO) for retrieval quality. A drop in measured Recall@k indicates index degradation, triggering alerts.
- Monitoring Pipeline: A sample of production queries is periodically routed to both the approximate index and a ground-truth exact search (e.g., brute-force). The recall is computed and logged.
- Root Cause Analysis: A recall decline can signal issues like index corruption, data distribution shift since the last rebuild, or resource contention affecting search precision.
- SLO Example: "The system shall maintain Recall@100 >= 0.95 for 99.9% of queries over a 24-hour window."
Evaluating Retrieval-Augmented Generation (RAG)
Recall@k is the foundational metric for the retrieval component of a RAG pipeline. The quality of the generated answer is upper-bounded by the system's ability to retrieve the relevant source documents.
- Workflow: For a set of test questions, the system retrieves
kdocument chunks. Recall@k measures if the chunk containing the correct answer was retrieved. - Impact on LLM: Low Recall@10 means the language model often lacks the necessary context, leading to hallucinations or incomplete answers.
- Optimization Goal: Teams tune their vector search to maximize Recall@5 or Recall@10 to ensure the top-k retrieved chunks have high probability of containing the answer, before optimizing the LLM's synthesis capability.
Benchmarking Search Scalability
As a dataset grows from millions to billions of vectors, maintaining high Recall@k becomes a core scalability challenge. Engineers use Recall@k to validate performance across scale milestones.
- Scalability Test: Measure Recall@k while progressively increasing the dataset size on a fixed hardware profile.
- Identifying Bottlenecks: A sharp recall drop at a certain scale may indicate that index parameters (e.g., HNSW's
M) need adjustment, or that a different algorithm (e.g., switching to DiskANN) is required. - Industry Benchmarking: Public benchmarks like ANN-Benchmarks report Recall@k across algorithms and datasets, providing a baseline for expected performance at scale.
Quantifying Quantization Trade-offs
Recall@k precisely measures the accuracy loss introduced by vector compression techniques like Product Quantization (PQ) or Scalar Quantization, which are used to reduce memory usage.
- Experimental Setup: Compare Recall@k for a full-precision index (baseline) against a quantized index (e.g., IVFPQ).
- Analyzing the Trade-off: A configuration using 8-bit PQ might achieve Recall@100 = 0.92 versus 0.98 for the full-precision baseline, but uses 4x less memory. This quantifies the cost of the compression.
- Informing Architecture: This data allows CTOs to decide if the memory savings justify the recall reduction for their specific application tolerance.
Frequently Asked Questions
Recall@k is a core metric for evaluating the accuracy of an Approximate Nearest Neighbor (ANN) search. These questions address its definition, calculation, and practical role in tuning vector database performance.
Recall@k is an evaluation metric for Approximate Nearest Neighbor Search (ANNS) that measures the proportion of the true k nearest neighbors found within the top k results returned by an approximate search algorithm.
It is calculated as:
codeRecall@k = (Number of true top-k neighbors found by the index) / k
A score of 1.0 (or 100%) indicates perfect retrieval, meaning the approximate search returned the exact same set of vectors as an exhaustive, brute-force search would have. This metric directly quantifies the retrieval accuracy of a vector index, trading off against search latency and memory efficiency.
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
Recall@k is a core metric for evaluating the accuracy of approximate nearest neighbor (ANN) search. The following terms define the algorithms, techniques, and complementary metrics that determine a system's recall performance.
ANNS (Approximate Nearest Neighbor Search)
ANNS (Approximate Nearest Neighbor Search) is the overarching problem that Recall@k measures. It refers to algorithms that trade perfect accuracy for sub-linear search times in high-dimensional spaces. These algorithms, such as HNSW or IVF, do not guarantee the exact nearest neighbors but aim to find a close approximation quickly.
- Trade-off: The fundamental compromise between search speed (latency) and search accuracy (recall).
- Goal: To enable real-time semantic search over billion-scale vector datasets where exact search is computationally prohibitive.
Precision@k
Precision@k is the companion metric to Recall@k, measuring the relevance of the results returned. It is defined as the proportion of the top k retrieved items that are relevant (i.e., part of the true nearest neighbors).
- Formula:
Precision@k = (Number of relevant items in top k) / k - Interpretation: High precision means most returned results are correct, but it doesn't account for missed relevant items. A system can achieve high precision@k with low recall@k by being overly conservative.
- Use Case: Often analyzed alongside recall in a recall-precision curve to holistically evaluate an index's performance.
Mean Average Precision (mAP)
Mean Average Precision (mAP) is a single-figure metric that summarizes ranking quality across multiple queries, incorporating both recall and precision. It is the mean of the Average Precision (AP) scores for a set of queries.
- Calculation: For each query, Average Precision is computed by averaging the precision values at each rank where a relevant item is found.
- Advantage: mAP rewards systems that rank relevant items higher in the results list, providing a more nuanced evaluation than recall@k alone.
- Context: While Recall@k measures retrieval completeness, mAP measures the quality of the ranking order of the retrieved items.
Search Beam Width
Search Beam Width is a critical hyperparameter in graph-based ANN algorithms like HNSW that directly impacts recall and latency. It controls the size of the dynamic candidate list (the "beam") maintained during the greedy graph traversal.
- Mechanism: A larger beam width allows the search algorithm to explore more candidate paths, increasing the probability of finding true nearest neighbors (higher recall) but at the cost of more distance computations (higher latency).
- Tuning: This parameter is a primary lever for operators to balance the recall-latency trade-off specific to their application's requirements.
Multi-Probe Search
Multi-Probe Search is a technique used with inverted file (IVF) indexes to increase recall. Instead of searching only the Voronoi cell whose centroid is nearest to the query, the algorithm probes several additional neighboring cells.
- Purpose: To mitigate the coarse quantization error inherent in the first stage of an IVF index, where a query might be close to the boundary between cells.
- Trade-off: Probing
ncells instead of 1 increases search scope and improves recall but multiplies search work by approximatelyn, increasing latency. - Implementation: A core parameter (
nprobe) in libraries like FAISS that controls this recall-speed trade-off.
Exact Re-ranking
Exact Re-ranking is a two-stage search strategy designed to achieve high recall with manageable cost. An approximate index (e.g., HNSW, IVF) first retrieves a broad candidate set (e.g., top 1000 vectors). This candidate list is then re-scored using exact, full-precision distance calculations to produce the final top-k results.
- Benefit: Combines the speed of ANN search with the accuracy of exact k-NN for the final ranking.
- Impact on Recall: Dramatically improves final Recall@k by ensuring the final list is based on perfect distances, correcting errors from the approximate first stage.
- System Design: A common production pattern where latency budgets allow for the additional computational step of re-ranking a few hundred candidates.

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