Skip to content

LearnEvaluate

Precision@k

P@k

The fraction of the top k results that are relevant. Five results with two relevant gives precision@5 = 0.4.

Background conceptGlossary entry

On this page

Precision@k is the fraction of the top k results that are relevant. If the top 5 results for “When does the London office open?” include 2 relevant passages, precision@5 = 2 / 5 = 0.4.

It is the counterpart of recall@k, which divides by the number of relevant passages that exist instead of by k. The same ranked list gives very different pictures:

k Relevant in top k Precision@k Recall@k (4 relevant exist)
1 1 1.00 0.25
5 2 0.40 0.50
10 3 0.30 0.75

Raising k almost always helps recall and hurts precision.

Why it matters for RAG

Every passage in the top k goes into the model’s context. Low precision means the model reads mostly noise: it costs tokens, gives the model more chances to cite the wrong page, and can push the good passage into the middle where models attend to it least (lost in the middle).

The gotcha

The ceiling depends on the question, not the system. A question with only 2 relevant passages caps precision@10 at 0.2 even for a perfect ranking, so averaging precision@10 across questions mixes system quality with how many answers each question happens to have. Compare systems on the same questions, or use nDCG, which normalizes against the best possible ranking.

In DocSlurp

Background concept

DocSlurp’s retrieval evaluations lead with recall-style checks (every premise found within k) rather than precision (core/scripts/retrieval-quality/eval.mjs). Precision matters most for the context a model reads, where irrelevant passages cost tokens.

Sources

Jump to