All articles

Precision and Recall Explained

Precision measures how much of your search output is relevant; recall measures how much relevant material you found. Learn the formulas, explore interactive examples, and avoid common evaluation mistakes.

A blue scoop gathers a mixture of relevant green diamonds and irrelevant pale discs, while several green diamonds remain outside its reach.

A search engine returns five documents. Three answer the question; two waste the reader's time. That describes the quality of the results you can see. It says nothing about the useful documents the engine missed.

Precision measures the fraction of retrieved documents that are relevant. Recall measures the fraction of all relevant documents that were retrieved. Together, they separate unwanted results from missing results. Improving search starts with knowing which failure you have, and what counts as relevant for the task. These are the standard information retrieval definitions.

What do precision and recall measure?

Suppose an engineer searches for instructions to rotate a production API key. A document is relevant if it explains the supported rotation procedure for that service. A page about creating an unrelated key is irrelevant, even if it shares the same vocabulary. Define relevance against the information need, as the Stanford IR textbook recommends.

For a fully judged collection of 12 documents, assume six are relevant. The engine returns five: three relevant and two irrelevant. The confusion matrix accounts for every document:

Relevant Irrelevant
Returned 3 true positives (TP) 2 false positives (FP)
Not returned 3 false negatives (FN) 4 true negatives (TN)
Precision = TP / (TP + FP) = 3 / 5 = 60%
Recall    = TP / (TP + FN) = 3 / 6 = 50%

Precision asks, "Of what I got, how much was useful?" Recall asks, "Of what I needed, how much did I get?" True negatives appear in neither formula. Correctly excluding millions of irrelevant documents doesn't compensate for missing the one procedure the engineer needs.

In this worked example, documents A, B, D, G, I and L are relevant. Toggle a document to return or exclude it. Removing an irrelevant result improves precision without changing recall; adding a missed relevant document improves recall and can improve precision too.

In a fully judged collection of 12 documents, A, B, D, G, I and L are relevant. Returning A, B, C, D and E gives 3 true positives, 2 false positives and 3 false negatives: precision 60%, recall 50%. Excluding C raises precision to 75% while recall stays 50%. Adding G to that result set raises precision to 80% and recall to 66.7%.

Worked example, not a benchmark. Each tile is one document; relevance stays fixed. Toggle whether a document is returned to see the counts and denominators change. Controls require JavaScript.

Returning the entire collection gives 100% recall and 50% precision. Returning only A gives 100% precision and 16.7% recall. Neither extreme is automatically useful. If nothing is returned, precision has a zero denominator and is undefined. Recall is likewise undefined for a query with no relevant documents. Evaluation software provides configurable reporting conventions; document yours.

How do precision@k and recall@k change with result depth?

Precision@k is the fraction of the first k results that are relevant. Recall@k is the fraction of all relevant documents found in those first k results. Both evaluate a ranked list at a specified cutoff, so comparisons require the same k and the same relevance judgments. See ranked retrieval evaluation.

For our collection, keep the ranking A through L fixed. At k = 5, P@5 is 60% and R@5 is 50%. The sixth result, F, is irrelevant: P@6 falls to 50%, and R@6 stays 50%. The seventh result, G, is relevant: P@7 rises to 57.1%, and R@7 rises to 66.7%. Move the cutoff to see both cases.

The fixed ranking is A through L, with relevant documents at ranks 1, 2, 4, 7, 9 and 12. At k = 5, precision is 60% and recall is 50%. At k = 6, both are 50%. At k = 7, precision rises to 57.1% and recall rises to 66.7%. At k = 12, precision is 50% and recall is 100%.

One fixed ranking of the same 12 fully judged documents. The cutoff selects a prefix; it does not rerank results. Bars use a fixed 0–100% scale. This example always has at least k available results. Controls require JavaScript.

Increasing k cannot reduce recall in a fixed ranking. Precision can rise or fall, depending on the next document. The familiar "precision versus recall tradeoff" is therefore not a rule that every recall gain must hurt precision. A better ranker can recover more relevant documents at the same cutoff, improving both.

A score threshold chooses results differently: return everything scoring at least a specified value. Lowering the threshold expands the set on fixed scores, with tied scores entering together. Recall cannot decrease; precision need not move monotonically. A precision-recall curve plots these operating points with recall horizontally and precision vertically. Scores need not be probabilities.

Neither P@k nor R@k distinguishes a relevant document at rank one from the same document at rank k. If early placement matters, add a rank-sensitive measure such as average precision or NDCG. Also report how you handle queries that return fewer than k results.

When should you use F1 or favor one metric?

F1 is the harmonic mean of precision and recall. It provides one score that falls when either component is low, but it does not encode the cost of a missed document or an unwanted result. Report the two components alongside F1 so the same aggregate score cannot hide different failures. The F1 definition gives:

F1 = 2 × precision × recall / (precision + recall)
   = 2TP / (2TP + FP + FN)
   = 6 / 11 ≈ 54.5% in our initial example

Choose an operating point from the task's requirements. These are evaluation priorities, not universal target percentages:

Task Priority What else to check
Find a known troubleshooting page Relevant results near the top Rank of the first useful result
Gather evidence for a complete investigation Recover the relevant material Review effort and missed evidence
Retrieve candidates for a reranker Preserve relevant candidates Candidate count and retrieval latency
Supply context to an answering model Sufficient, useful evidence Grounded answer quality and token budget

A reranker can reorder its candidates, but cannot recover a document absent from that candidate set. A downstream answering model adds another boundary: finding relevant passages does not establish that the final answer used them correctly. Our retrieval-to-answer evaluation guide examines that distinction.

Be explicit about the word "recall" in vector benchmarks. A common ANN recall@k definition measures overlap with exact top-k neighbors under the same embedding and distance function, divided by k. That evaluates approximation fidelity, not usefulness to a person. Faiss documents multiple recall criteria; check the benchmark's actual definition before comparing numbers.

How do you measure retrieval quality reliably?

Recall needs a denominator: the relevant documents for each query. Our toy collection has complete labels. Real collections rarely do. Pooling gathers results from multiple systems for judgment, but relevant documents can remain outside that pool. Report recall against the judged relevant set and disclose that limitation. An unjudged document is not known to be irrelevant.

Aggregation also changes the question. Macro averaging gives each query equal weight by averaging its metric. Micro averaging pools TP, FP and FN across query-document pairs before calculating the metric. Under these definitions, queries with more relevant documents contribute more to micro recall. State the averaging method, and compute macro F1 from per-query F1 scores rather than from averaged precision and recall.

Use this evaluation checklist before accepting a retrieval change:

  1. Freeze the evaluation set. Keep queries, corpus snapshot, access rules and relevance criteria consistent. Define the retrieval unit: documents, passages or products.
  2. Judge beyond one system's output. Pool competing runs, inspect new unjudged results, and track judgment coverage.
  3. Compare at matching cutoffs. Report P@k and R@k together. Record latency and candidate count when varying depth.
  4. Expose edge cases. Specify empty-result and zero-relevance policies; break out query groups that an average could hide.
  5. Choose on validation data. Keep a separate held-out test set for the final comparison, and evaluate the downstream task as well as retrieval.

Key takeaways

  • Precision counts relevant results among returned results; recall counts recovered results among all relevant documents.
  • Increasing result depth cannot lower recall in a fixed ranking. Precision can rise or fall.
  • F1 summarizes both metrics, but the task determines which errors matter most.
  • Cutoffs, relevance labels, averaging and empty-set policies are part of the metric definition.
  • Exact-neighbor recall and human relevance recall answer different questions.

Cookie settings

Optional tracking stays off until you choose it. Your choice applies to this browser for 180 days. Read the details.

Essential storage keeps you signed in, protects forms, and remembers this choice. It is always available.