Recall@K is the proportion of the true top-K nearest neighbors, as determined by an exhaustive k-NN search, that are successfully retrieved within the top-K results returned by an approximate nearest neighbor (ANN) algorithm. It is calculated as (Number of true neighbors retrieved) / K. A score of 1.0 (or 100%) indicates perfect retrieval, meaning all true nearest neighbors were found. This metric directly quantifies the trade-off between search speed and accuracy inherent in vector database indexing methods like HNSW or IVF.
Glossary
Recall@K

What is Recall@K?
Recall@K is a core evaluation metric for approximate nearest neighbor (ANN) search systems, measuring the completeness of retrieved results against a ground truth.
In production systems, Recall@K is tuned against Query Latency and Throughput (QPS). Engineers adjust index parameters (e.g., EF Search in HNSW) to achieve a target recall (e.g., 0.95) for a specific K value. It is often evaluated alongside Precision@K, which measures result accuracy. For Filtered Search scenarios, recall can degrade if restrictive Pre-Filtering excludes relevant vectors, making it a critical measure for validating hybrid search pipeline performance.
Key Characteristics of Recall@K
Recall@K is a fundamental evaluation metric for approximate nearest neighbor (ANN) search systems. It quantifies the completeness of retrieval by measuring what proportion of the true top-K nearest neighbors are found in the system's retrieved results.
Core Definition & Formula
Recall@K measures the completeness of a retrieval system's top-K results. It is calculated as the ratio of relevant items retrieved to the total number of relevant items that exist in the entire dataset for that query.
Formula: Recall@K = (Number of true top-K neighbors retrieved) / K
- A value of 1.0 (or 100%) indicates perfect recall: all K true nearest neighbors were found.
- A value of 0.0 indicates none were found.
- It is always calculated by comparing results against a ground truth generated by an exact, exhaustive search (e.g., brute-force K-NN).
Trade-off with Query Latency
Recall@K has a fundamental, inverse relationship with query latency. Higher recall typically requires more computational work, leading to slower searches.
- High-Recall Configurations: Increasing parameters like
ef_searchin HNSW ornprobein IVF expands the search scope, finding more true neighbors at the cost of higher latency. - Low-Latency Configurations: Aggressive approximations (e.g., searching fewer graph connections or IVF cells) speed up queries but miss relevant vectors, lowering recall.
System tuning involves finding the optimal operating point on this trade-off curve for a specific application's latency Service-Level Objective (SLO).
Relationship with Precision@K
Recall@K and Precision@K are complementary metrics that together describe retrieval quality.
- Recall@K: Measures completeness ("Did I find all the relevant items?").
- Precision@K: Measures accuracy ("Are the items I found relevant?").
In ANN search, these metrics often move in opposite directions. For a fixed K:
- Increasing the search scope may retrieve more true positives (boosting recall) but also more false positives (hurting precision).
- A perfectly calibrated system aims for high values in both, but the priority depends on use case: recommendation systems may favor recall, while legal e-discovery may prioritize precision.
Dependence on Index Parameters
Recall@K is not a fixed property of a dataset; it is directly controlled by the configuration of the vector index and search parameters.
Key parameters that influence recall:
- HNSW:
ef_search(higher increases recall),M(higher can improve recall at build time). - IVF (Faiss):
nprobe(searching more Voronoi cells increases recall). - PQ/IVFPQ: Number of centroids (
nlist) and subquantizers.
Engineers perform parameter sweeps, measuring Recall@K across different settings to create performance profiles before deploying to production.
Use in Multi-Stage Retrieval
In production systems, Recall@K is often used to evaluate the first, fast candidate generation stage of a multi-stage retrieval pipeline.
Typical Pipeline:
- Stage 1 (Candidate Generation): A fast, high-recall ANN search (e.g., using IVF) retrieves a large candidate set (e.g., 1000 vectors). The goal is high Recall@1000 to ensure all relevant items are in this pool.
- Stage 2 (Re-ranking): A slower, more precise model (e.g., a cross-encoder, or exact distance calculation) re-ranks the candidate pool to produce the final top-K results.
Here, optimizing Stage 1 for recall is critical; missing a relevant vector in this stage makes it impossible for Stage 2 to retrieve it.
Benchmarking & Evaluation Practice
Proper evaluation of Recall@K requires a rigorous, standardized benchmarking setup.
Essential Components:
- Ground Truth Dataset: A query set with known, pre-computed true top-K neighbors via exhaustive search.
- Fixed Distance Metric: The same metric (e.g., L2, cosine) must be used for ground truth and ANN search.
- Averaging: Results are typically reported as the mean Recall@K across all queries in the evaluation set.
- Latency Measurement: Always reported alongside recall (e.g., "Recall@10 = 0.95 at 2ms P99 latency").
Tools like the ANN Benchmarks framework automate this process, running controlled experiments across different libraries and algorithms.
Calculation and Interpretation
Recall@K is a fundamental evaluation metric for information retrieval and approximate nearest neighbor search systems, quantifying the completeness of results.
Recall@K is an evaluation metric that measures the proportion of the true top-K nearest neighbors, as determined by an exhaustive search, that are successfully retrieved within the top-K results of an approximate search system. It is calculated as (Number of relevant items retrieved) / K, where 'relevant' is defined by the ground truth set. A score of 1.0 indicates perfect retrieval, meaning all true nearest neighbors were found by the approximate algorithm.
In vector database infrastructure, Recall@K is the primary metric for tuning the accuracy-latency trade-off inherent in Approximate Nearest Neighbor (ANN) search. Engineers adjust index parameters like HNSW's ef_search or IVF's nprobe to increase Recall@K, accepting higher query latency for greater result completeness. It is analyzed alongside Precision@K to understand the system's overall retrieval quality and is critical for validating vector query optimization strategies in production.
Recall@K vs. Precision@K
A comparison of two core metrics used to evaluate the performance of approximate nearest neighbor (ANN) search in vector databases.
| Feature | Recall@K | Precision@K |
|---|---|---|
Core Definition | Measures the completeness of the retrieved set. The proportion of the true top-K nearest neighbors found in the retrieved K results. | Measures the accuracy of the retrieved set. The proportion of the retrieved K results that are true top-K nearest neighbors. |
Formula | |Retrieved ∩ True Top-K| / |True Top-K| | |Retrieved ∩ True Top-K| / K |
Focus | Coverage: Did we find all the relevant items? | Purity: Are the items we found actually relevant? |
Ideal Value | 1.0 (100%). All true nearest neighbors are retrieved. | 1.0 (100%). Every retrieved item is a true nearest neighbor. |
Trade-off Relationship | Often in tension. Optimizing for higher Recall@K (e.g., by searching more of the index) can lower Precision@K by retrieving more irrelevant items. | Often in tension. Optimizing for higher Precision@K (e.g., by using stricter search parameters) can lower Recall@K by missing some relevant items. |
Primary Use Case | Critical in recall-oriented applications where missing a relevant result is costly (e.g., legal e-discovery, diagnostic support systems). | Critical in precision-oriented applications where the user's attention is limited and result quality is paramount (e.g., top-5 product recommendations). |
Impact of Index Approximations | Directly measures the cost of the approximation. A primary metric for tuning ANN algorithm parameters (e.g., | Indirectly affected. Low recall will cap maximum possible precision, but high recall does not guarantee high precision. |
Interpretation with Perfect Search | If search is exhaustive (perfect recall), Recall@K is always 1.0. | If search is exhaustive, Precision@K depends on dataset density and K. It may be less than 1.0 if many vectors are nearly equidistant from the query. |
Practical Applications and Tuning
Recall@K is a critical metric for evaluating the completeness of approximate nearest neighbor search results. This section details its practical use in system tuning and validation.
Core Definition and Formula
Recall@K measures the proportion of true top-K nearest neighbors (from an exhaustive search) that are successfully retrieved within the top-K results of an approximate search. The formula is:
Recall@K = (|Retrieved ∩ Relevant|) / |Relevant|WhereRelevantis the set of true K-nearest neighbors, andRetrievedis the set of K results from the approximate search. A score of 1.0 indicates perfect recall, meaning all true nearest neighbors were found.
Trading Recall for Latency
In production vector databases, Recall@K is directly traded against query latency. Increasing recall typically requires more computational work, impacting latency and throughput.
- Lower Recall Targets (e.g., 0.85-0.95): Acceptable for recommendation systems or semantic search where user experience is forgiving. Allows aggressive indexing parameters (e.g., lower
ef_searchin HNSW, fewer IVF probes) for sub-10ms latency. - High Recall Targets (e.g., 0.98-0.99): Mandatory for fraud detection, medical image retrieval, or legal e-discovery. Requires more exhaustive search parameters, often resulting in 20-100ms+ latency. The trade-off is managed via index hyperparameters.
Hyperparameter Tuning Guide
Key index parameters directly control the Recall@K vs. speed trade-off:
- HNSW:
ef_search: The size of the dynamic candidate list during graph traversal. Increasingef_search(e.g., from 32 to 200) improves recall at the cost of linear increases in latency. - IVF:
nprobe: The number of Voronoi cells (clusters) to search. Increasingnprobe(e.g., from 5 to 50) searches a larger fraction of the dataset, boosting recall but increasing latency proportionally. - Composite Indexes (e.g., IVF_PQ): Tuning involves balancing
nprobe(coarse quantizer) and PQ codebook size (fine quantizer). Best Practice: Plot a recall-latency curve by sweeping these parameters on a validation query set to select the optimal operating point for your service-level agreement.
Validation and Ground Truth Generation
Calculating Recall@K requires a ground truth set of true nearest neighbors, generated via an exhaustive search (e.g., brute-force K-NN).
- Process: For a representative sample of query vectors (1000-10k), perform an exact search using the chosen distance metric. Store these
Kresults per query as the ground truth. - Challenge: Exhaustive search is computationally expensive (
O(N*d)per query). Use efficient libraries like Faiss (IndexFlatL2) on a GPU or a sampled subset of the database for validation. - Monitoring: In production, track Recall@K on a held-out query set to detect index degradation over time, signaling the need for re-indexing.
Relationship to Precision@K and R-Precision
Recall@K is one part of the retrieval quality picture and must be interpreted alongside other metrics:
- Precision@K: The fraction of retrieved items that are relevant. A system can have high recall but low precision if it returns many irrelevant items alongside the correct ones.
- R-Precision: Precision calculated at
R, whereRis the number of relevant documents for a query. This aligns precision with recall naturally. - Typical Trade-off: Increasing
Kfor a fixed system generally increases Recall@K (more chances to find relevant items) but decreases Precision@K (more irrelevant items in the larger result set). The optimalKis application-dependent.
Use Case: Multi-Stage Retrieval Pipelines
Recall@K is pivotal in designing multi-stage retrieval systems common in search engines and RAG architectures.
- Stage 1 (Candidate Generation): A fast, high-recall ANN search (e.g., using a compressed IVF index) retrieves a large candidate set (e.g., K=1000) with a target Recall@1000 > 0.95. Speed is critical.
- Stage 2 (Re-ranking): A more expensive, precise model (cross-encoder, exact distance on uncompressed vectors) re-ranks the candidate set. The high first-stage recall ensures the final top results are drawn from a pool containing almost all true nearest neighbors. This architecture optimizes overall system latency while maintaining final result quality.
Frequently Asked Questions
Recall@K is a core evaluation metric for vector search and information retrieval systems. It quantifies the completeness of approximate search results, making it essential for tuning the trade-off between speed and accuracy in production AI applications.
Recall@K is an evaluation metric that measures the proportion of the true top-K nearest neighbors, as determined by an exhaustive (brute-force) search, that are successfully retrieved within the top-K results returned by an approximate search algorithm. It is formally defined as:
Recall@K = (Number of true top-K neighbors retrieved) / K
For example, if the true 10 nearest neighbors for a query are vectors [A, B, C, D, E, F, G, H, I, J], and your approximate search returns [A, C, F, X, Y, Z, B, D, Q, R], then the retrieved true neighbors are {A, B, C, D, F}. Therefore, Recall@10 = 5 / 10 = 0.5 or 50%.
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 quality of an Approximate Nearest Neighbor (ANN) search. Understanding related concepts is essential for tuning the trade-off between search speed (latency) and result completeness (recall).
Precision@K
Precision@K measures the accuracy of the top-K retrieved results. It is calculated as the fraction of items in the retrieved top-K set that are true nearest neighbors (as determined by an exhaustive, ground-truth search).
- Key Contrast with Recall@K: While Recall@K measures completeness ("Did I find all the relevant items?"), Precision@K measures purity ("Are the items I found actually relevant?").
- Trade-off: In ANN systems, increasing recall often comes at the cost of lower precision, as the search broadens to include more candidates.
- Example: If a query's true top-5 neighbors are items [A, B, C, D, E], and your ANN search returns [A, C, F, G, H], then Precision@5 is 2/5 = 0.4 (only A and C are correct).
Mean Reciprocal Rank (MRR)
Mean Reciprocal Rank (MRR) is an evaluation metric for ranking systems that focuses on the position of the first relevant item in the retrieved list. The Reciprocal Rank for a single query is 1/rank, where 'rank' is the position of the first correct answer (or the first true nearest neighbor). MRR is the average of this score across multiple queries.
- Use Case: Particularly important for question-answering or retrieval tasks where the user expects a single, correct result at the top of the list.
- Relationship to Recall@K: A system can have high Recall@K but poor MRR if the true best match is buried deep in the results list.
- Calculation: For queries where the first correct result is at positions 1, 3, and 2, the MRR is (1/1 + 1/3 + 1/2) / 3 ≈ 0.61.
k-NN Search
k-NN Search (k-Nearest Neighbors Search) is the fundamental query operation that Recall@K evaluates. It is a request to a vector database to find the 'k' vectors most similar to a given query vector according to a specified distance metric (e.g., cosine similarity, Euclidean distance).
- Exhaustive k-NN: A brute-force scan that compares the query against every vector in the database. It provides perfect recall but is computationally prohibitive at scale.
- Approximate k-NN (ANN): The practical method used in production, which uses indexing structures like HNSW or IVF to find approximate nearest neighbors much faster, at the cost of potentially missing some true neighbors (lower recall).
- Recall@K as Validation: Recall@K quantifies how well the approximate k-NN results from an ANN index match the ideal results from an exhaustive k-NN search.
Query Latency
Query Latency is the elapsed time between submitting a search query and receiving the complete response. It is the primary performance metric traded off against Recall@K in vector database optimization.
- Inverse Relationship: Increasing recall (e.g., by raising the efSearch parameter in HNSW or searching more IVF clusters) almost always increases query latency, as the system performs more distance computations and explores a larger portion of the index.
- Service-Level Objective (SLO): Production systems define target latencies (e.g., P95 < 50ms) that constrain how much recall can be pursued.
- Optimization Goal: The engineering challenge is to design an index and tune its parameters to achieve the highest possible Recall@K within a strict latency budget.
EF Search (HNSW Parameter)
EF Search ("ef" or "efSearch") is a critical hyperparameter for the Hierarchical Navigable Small World (HNSW) index that directly controls the trade-off between Recall@K and query latency.
- Mechanism: During graph traversal, HNSW maintains a dynamic candidate list of the most promising nodes to explore next. The
efparameter sets the size of this priority queue. - Tuning Effect:
- A higher
efvalue causes the search to explore more candidate nodes, leading to higher recall but slower queries. - A lower
efvalue restricts the search, leading to faster queries but lower recall.
- A higher
- Practical Use:
efis typically set at query time and can be adjusted dynamically based on application needs (e.g., higher for offline batch jobs, lower for real-time APIs).
Ground Truth
Ground Truth, in the context of evaluating Recall@K, refers to the definitive, correct set of results against which approximate search results are compared. It is generated by performing an exhaustive k-NN search (brute-force) over the entire dataset.
- Prerequisite for Measurement: You cannot calculate Recall@K without first establishing the ground truth top-K neighbors for your query set.
- Computational Cost: Generating ground truth is an O(N) operation per query and is typically done once offline on a representative sample of queries.
- Benchmarking: The ground truth dataset serves as the authoritative benchmark for evaluating different ANN algorithms, index parameters, and hardware configurations. A reported Recall@K score is only meaningful relative to a specific ground truth.

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