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).