RAG Retriever Eval Calculator: Precision@k, Recall@k, MRR & MAP

Paste the ranked chunks your retriever returned for each test question, marked relevant or not, and get Precision@k, Recall@k, hit rate, MRR and MAP averaged over queries, plus the smallest top-k that still captures the recall.

Last updatedHow we build & check our tools
Results will appear here once you enter your values.

The four metrics, and what each one tells a RAG builder

A RAG pipeline answers a question in two steps: a retriever picks chunks from your corpus, then a language model writes an answer from them. If the first step fails, nothing the model does can save the answer. These four numbers describe how well the first step works, using a small set of test questions where you already know which chunks are relevant.

  • Precision@k = relevant chunks in the top k, divided by k. It is the share of your context window that is useful. A Precision@5 of 0.4 means two of every five chunks you pay tokens for are relevant, and three are noise.
  • Recall@k = relevant chunks in the top k, divided by all relevant chunks that exist. It is the share of the evidence the model gets to see. If recall is low, the answer is missing facts no matter how good the model is.
  • Hit rate@k = the share of queries with at least one relevant chunk in the top k. It is a forgiving version of recall for questions that need only one supporting chunk.
  • MRR (mean reciprocal rank) = the average of 1 divided by the rank of the first relevant chunk, counting 0 when none is returned. Rank 1 scores 1.0, rank 2 scores 0.5, rank 4 scores 0.25. It rewards putting the answer at the very top.
  • MAP (mean average precision) = for each query, add up the precision at every rank where a relevant chunk appears and divide by the total number of relevant chunks, then average across queries. It rewards ranking all the relevant chunks early and charges you for any that were never retrieved.

Precision, recall and hit rate are measured at a cutoff k. MRR and MAP are measured over the whole list you paste for each query, so pasting a longer list can raise them.

These are the standard definitions from information retrieval: see Manning, Raghavan and Schütze, Introduction to Information Retrieval (Cambridge University Press, 2008), chapter 8 on evaluation in ranked retrieval, and the reciprocal rank definition from the TREC-8 question answering track (Voorhees, 1999).

Worked example: one query, step by step

Take the line 1 0 1 0 1 | 4. The retriever returned five chunks. Chunks at ranks 1, 3 and 5 are relevant, and four relevant chunks exist in total, so one was never retrieved.

  • Precision@3 = 2 relevant in the top 3, divided by 3 = 0.667.
  • Recall@3 = 2 found, divided by 4 that exist = 0.500.
  • Reciprocal rank = the first relevant chunk is at rank 1, so 1 / 1 = 1.0.
  • Average precision = (1/1 + 2/3 + 3/5) divided by 4 = (1 + 0.667 + 0.6) / 4 = 0.567. Dividing by 4 rather than 3 is what charges the retriever for the chunk it missed. Had the total been 3, the same ranking would score 0.756.

Notice that MRR gives this query full marks because the top chunk is relevant, while average precision does not. That gap is why you should look at both: MRR tells you whether the best evidence is first, MAP tells you whether all of it made it in and how early.

Choosing top-k: recall against token cost

Top-k is the number of chunks you paste into the prompt, and it pulls two ways. Raising k can only keep recall the same or raise it, since the top 8 always contains the top 5. But precision usually falls as k grows, because later ranks are less likely to be relevant, and every extra chunk costs input tokens and gives the model more irrelevant text to be distracted by.

The suggestion box finds the smallest k that reaches 95% of the best recall your lists allow, and shows the precision and the average number of noise chunks at that point. Read it as a plateau detector: if recall is 0.90 at k = 4 and 0.92 at k = 10, six extra chunks bought two points of recall.

  • Recall still climbing at your k: raise k, or improve the ranking so relevant chunks come sooner.
  • Recall flat but precision low: lower k and save tokens. Check what a chunk costs with the LLM context window calculator and price the difference with the AI token cost calculator.
  • Recall low at every k: the right chunks are not being retrieved at all. Look at chunking, the embedding model, and query rewriting before tuning k. The embedding similarity playground shows how close a question and a chunk really are, and the AI embedding cost calculator prices a re-embed if you change models.

Common mistakes when evaluating a retriever

  • Leaving out the relevant total. Without it, recall only counts what the retriever found, so it can never show a miss. Always record how many relevant chunks exist, even if you have to estimate it from a labelled sample.
  • Testing on questions you tuned on. If you picked the chunk size by looking at these same queries, the scores are optimistic. Keep a held-out set.
  • Too few queries. With 10 queries, one failure moves MRR by up to 0.1. Aim for at least 30, and for the mix of easy and hard questions real users ask.
  • Judging relevance by topic instead of by answer. A chunk that is on the same subject but does not contain the fact is not relevant for this purpose. Label what is needed to answer.
  • Treating duplicates as separate hits. If three near-identical chunks all contain the answer, count them as relevant only if you really have three distinct relevant chunks; otherwise precision looks better than the context really is.
  • Stopping at retrieval. Good retrieval does not guarantee a grounded answer. Pair these numbers with the RAG answer grounding checker, and use the local RAG playground if you want to see retrieval and answering together on a few documents.

How this differs from NDCG, precision-recall curves and confusion matrices

Several tools on this site use the words precision and recall, but they answer different questions.

  • The NDCG calculator scores one ranked list with graded relevance (for example 0 to 3) and discounts lower ranks logarithmically. Use it when some chunks are better answers than others.
  • The precision-recall curve calculator takes scored examples from a binary classifier and sweeps a score threshold. There are no ranks per query and no top-k; it is for classifiers, not retrievers.
  • The confusion matrix calculator turns true and false positive and negative counts into classification precision and recall. It has no notion of rank position or a cutoff.
  • This calculator works per query on rank positions with binary labels and then averages across queries, which is exactly the shape of a RAG eval set.

Frequently Asked Questions

Common questions about the RAG Retriever Eval Calculator: Precision@k, Recall@k, MRR & MAP

Collect 30 to 100 real questions your users would ask, and for each one note which chunks in your corpus actually answer it. Run each question through your retriever, then write one line per question: a 1 for every returned chunk that is relevant and a 0 for every one that is not, in rank order, followed by | and the total number of relevant chunks that exist. For example, 1 0 1 0 0 | 3 means the retriever returned five chunks, found two of the three relevant ones, and ranked them first and third. Fewer than about 30 queries makes the averages jumpy, because one query moves MRR by several points.
From the same team

Stop paying per token — route AI requests to your own GPU

Wide Area AI is a local-first AI gateway: repeated requests hit an edge cache, the rest run free on your own hardware, and the cloud is only a failover. OpenAI-compatible endpoint, free tier.

Start routing — free

Sources & References

Evaluation of ranked retrieval results (Introduction to Information Retrieval, ch. 8.4)

Manning, Raghavan and Schütze's textbook definitions used by this calculator.
- Precision at k, and MAP as the mean over queries of average precision.
- Average precision divides by the number of relevant documents for the query; a relevant document never retrieved contributes a precision of 0.

trec_eval: the TREC evaluation tool

NIST's reference implementation of ranked retrieval measures.
- P_k divides by k even when fewer than k documents are returned (missing ranks count as non-relevant): 4 relevant in 15 retrieved gives P20 = 0.2.
- map and recip_rank match the AP and reciprocal rank computed here.

The TREC-8 Question Answering Track Report

Voorhees's definition of mean reciprocal rank.
- Each question scores 1 divided by the rank of the first correct response, or 0 if none is returned; MRR is the mean over questions.