Inferensys

Glossary

Recall@K

Recall@K is an evaluation metric measuring the fraction of true nearest neighbors retrieved within the top K results, quantifying the accuracy loss introduced by approximate search algorithms.
Developer reviewing semantic search engine results on laptop, relevance scores visible, technical search demo.
EVALUATION METRIC

What is Recall@K?

Recall@K is a standard evaluation metric for information retrieval and approximate nearest neighbor search that measures the fraction of relevant items successfully retrieved within the top K results.

Recall@K is defined as the ratio of true nearest neighbors found in the top K retrieved results to the total number of true nearest neighbors in the ground truth set. It quantifies the accuracy loss introduced by approximate nearest neighbor (ANN) algorithms compared to exact brute-force search, where a score of 1.0 indicates perfect retrieval of all relevant items.

This metric is critical for tuning the recall-speed tradeoff in vector indexes like HNSW or IVF, where higher K values or relaxed search parameters increase recall at the cost of latency. Unlike precision, Recall@K ignores irrelevant results, focusing solely on completeness—making it the primary metric for ensuring a re-ranking pipeline receives all necessary candidates.

EVALUATION METRIC

Key Characteristics of Recall@K

Recall@K is the primary metric for quantifying the accuracy loss introduced by approximate search. It measures the fraction of true nearest neighbors captured within the top K retrieved results.

01

Core Definition

Recall@K = |Retrieved True Neighbors ∩ Top-K Results| / |All True Neighbors|

  • K is the number of results returned to the user or downstream system
  • True Neighbors are the ground-truth results from an exact brute-force search
  • A score of 1.0 means perfect recall—all true neighbors were found
  • A score of 0.8 at K=10 means 2 out of 10 true neighbors were missed
02

Why It Matters for ANN

Approximate Nearest Neighbor algorithms trade accuracy for speed. Recall@K quantifies this tradeoff directly.

  • Without Recall@K, you cannot objectively compare HNSW vs. IVF vs. DiskANN
  • A 10x speedup is worthless if Recall@10 drops from 0.99 to 0.65
  • Production systems typically target Recall@10 > 0.95 for semantic search
  • The metric exposes regression bugs when re-indexing or tuning hyperparameters
03

Recall vs. Latency Tradeoff

The fundamental engineering tension in vector search:

  • Higher recall requires searching more graph edges or Voronoi cells
  • Lower latency requires aggressive pruning and smaller search scopes
  • Typical tuning parameters that affect this balance:
    • ef_search in HNSW: larger values increase recall but slow search
    • nprobe in IVF: more probes increase recall linearly with compute
  • Plotting a recall-latency curve is standard practice for index selection
04

K-Dependent Behavior

Recall@K is highly sensitive to the choice of K:

  • Recall@1: Measures whether the single most relevant item was found. Critical for question-answering systems.
  • Recall@10: Standard benchmark for search result pages. Balances precision and recall.
  • Recall@100: Used for re-ranking pipelines where a coarse filter feeds a precise downstream model.
  • Recall@1000: Relevant for exhaustive retrieval tasks like e-discovery or deduplication.

Always report Recall@K at multiple K values to fully characterize an index.

05

Ground Truth Generation

Computing Recall@K requires exact nearest neighbors as ground truth:

  • Run brute-force k-NN search over the entire dataset using the same distance metric
  • For billion-scale datasets, this is computationally prohibitive
  • Sampling strategies: evaluate recall on a representative query subset
  • Approximate ground truth: use a highly-accurate but slow ANN config (e.g., HNSW with very high ef_search) as a proxy
  • Mismatched distance metrics between ground truth and ANN index invalidate the measurement
06

Common Pitfalls

Avoid these errors when measuring Recall@K:

  • Ignoring tied distances: vectors at identical distances can cause non-deterministic ordering, inflating or deflating recall
  • Measuring on training queries: always use a held-out query set to avoid overfitting
  • Single K reporting: Recall@10 alone hides poor Recall@1 performance
  • Ignoring filtered ANN: recall with metadata filters is a distinct, harder problem requiring separate measurement
  • Confusing Recall@K with Precision@K: recall measures completeness; precision measures relevance ratio
RECALL@K EXPLAINED

Frequently Asked Questions

Clear, technical answers to the most common questions about the Recall@K evaluation metric, its calculation, and its role in benchmarking approximate nearest neighbor search systems.

Recall@K is a standard evaluation metric that measures the fraction of true nearest neighbors successfully retrieved within the top K results returned by an approximate search algorithm. It quantifies the accuracy loss introduced by trading exact computation for speed. The metric works by comparing the set of K items returned by an Approximate Nearest Neighbor (ANN) index against the ground truth set of true nearest neighbors, typically pre-computed via brute-force search. If a query has 10 true nearest neighbors and the ANN index returns 8 of them in its top-10 results, the Recall@10 is 0.8. This metric is the primary gauge of index quality, directly measuring how much recall is sacrificed to achieve lower latency and memory consumption.

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.