MRR vs Recall@k vs Precision@k
From the publisher’s feed, collected in the ZeroLabs newsroom.
When to use which, with their pros and cons!Content Created by Author!If you’ve ever built a search engine, a recommendation system, or a RAG (Retrieval-Augmented Generation) pipeline for an LLM, you’ve probably hit this wall:“My retriever works… but how do I actually measure if it’s good?”You can’t just eyeball results for 10,000 queries a day. You need numbers. And the three most common numbers thrown around in interviews, papers, and dashboards are MRR, Recall@k, and Precision@k.The problem? Most tutorials explain the formulas but not the intuition — so people pick the wrong metric, optimize for it, and end up with a system that scores great on paper but feels broken to real users.This blog fixes that. By the end, you’ll know exactly which metric to use, when, why — and what each one silently hides from you.Let’s dive in. 🚀🧠 First, Let’s Set the Stage with an Analogy!Imagine you’re a librarian. Someone walks in and asks: “Do you have any books on dinosaurs?”You hand them a stack of 10 books. Here’s the thing:Precision@k asks: “Out of the 10 books you handed me, how many are actually about dinosaurs?” (Quality of what you gave)Recall@k asks: “Out of ALL the dinosaur books in the library, how many did you manage to hand me?”(Completeness of what you gave)MRR asks: “How quickly did I find the FIRST good dinosaur book in your stack?” (Speed to the first win)Same stack of books. Three completely different questions. And depending on what the user actually needs — a quick answer vs. exhaustive research — a different metric matters more.Keep this librarian analogy in your head. We’ll come back to it.📐 The Formulas (Simple, No Fear)Let’s define the building blocks once, clearly.k = the cutoff — how many top results you're looking at (e.g., top 5, top 10)“Relevant” = ground-truth labeled as correct/useful for that queryPrecision@kOut of the top-k items you retrieved, what fraction are actually relevant?Precision@k measures the proportion of the relevant documents in the top k retrieved results, and you should use this when accuracy matters more than completeness for you.Precision@k = (Number of relevant items in top k) / kPrecision@k Formula — Image generated by Author!Recall@kOut of ALL the relevant items that exist, what fraction did you manage to retrieve in your top-k?Recall@k measures the proportion of all relevant documents that the system retrieved in the top k results, and it’s critical when missing information is costly.Recall@k = (Number of relevant items in top k) / (Total number of relevant items)Recall@k Formula — Image generated by Author!MRR (Mean Reciprocal Rank)How early does the FIRST relevant item show up, averaged across all your queries?Mean Reciprocal Rank measures the rank position of the first relevant document — it’s the average of reciprocal ranks across queries, where rank 1 scores 1.0, rank 2 scores 0.5, and so on.MRR Formula — Image generated by Author!where |Q| is the number of queries and rank_i is the position of the first relevant result for query i.🔢 A Worked Example (So It Actually Clicks)Say you search “best running shoes” and your system returns 5 results. Ground truth says 5 items in the whole catalog are truly relevant.Your retrieved list (✅ = relevant, ❌ = not relevant):Rank 1: ❌Rank 2: ✅Rank 3: ✅Rank 4: ❌Rank 5: ✅Precision@5 = 3 relevant / 5 retrieved = 0.6Recall@5 = 3 relevant found / 5 total relevant that exist = 0.6Reciprocal Rank for this query = 1 / 2 (first relevant hit was at rank 2) = 0.5If you average this across many queries, you get MRR.Notice something? Precision and Recall can be numerically similar in isolated examples, but they measure fundamentally different things and diverge wildly depending on how many relevant items exist in total vs. how many you returned.🎯 When to Use Precision@kProsGreat for “quality over quantity” scenarios. If a user only ever looks at the top 3–5 results (think Google’s first page, or a chatbot showing 3 sources), precision@k tells you if what they SEE is trustworthy.Easy to explain to stakeholders. “7 out of 10 results are relevant” is intuitive even for non-technical teams.Penalizes noisy retrieval. If your system is retrieving junk, precision drops fast — visibly.ConsBlind to what you’re missing. A system could have 99% precision@3 while completely missing 500 other relevant documents it never surfaced. The redis.io guide notes: Precision@K divides relevant documents in your top-K results by K total results — if you retrieve 10 chunks and 7 are relevant, that’s 0.7 precision. But that says nothing about the 3 relevant chunks you never retrieved at all.Sensitive to k choice. Precision@1 vs Precision@10 can tell very different stories.Best used when:Building search autocomplete, top-N recommendations, or chatbot citations where only a handful of results are ever shown to the user.You care more about not showing garbage than about finding everything.🎯 When to Use Recall@kProsMeasures completeness/coverage. Essential when missing even one relevant item is a real cost — legal discovery, medical literature search, fraud detection.Directly ties to the “can the system even find the answer” question in RAG pipelines. One arXiv paper on retrieval evaluation states: Recall@k measures the fraction of relevant passages recovered in the top-k retrieved results, and is the most directly actionable metric for RAG, since it measures how much of the retrievable answer pool is actually surfaced to the generator.Sets an upper bound for downstream systems. If your RAG retriever doesn’t recall the right chunk, no LLM — however smart — can generate a correct answer. Retriever evaluation measures how effectively the system identifies and ranks relevant documents, and retrieval performance sets the upper bound for final answer quality.ConsDoesn’t care about order. A system that buries the one relevant document at rank 20 (within top-25) scores the same Recall@25 as one that puts it at rank 1. Users don’t read rank 20.Can be gamed by increasing k. Retrieve everything (k = total corpus size) and recall becomes 1.0 — but that’s useless in practice since no one reads 10,000 documents.Needs a complete ground-truth label set, which is expensive/hard to build for large corpora.Best used when:Evaluating the retriever stage of a RAG pipeline before re-ranking — you want to know “is the answer even in the candidate pool?”High-stakes completeness scenarios: legal search, academic literature review, compliance checks.A practical target cited in production systems: Recall@k is the fraction of relevant chunks that appear in top-k, and many teams aim for 0.8+ at k=20 on broad datasets.🎯 When to Use MRRProsPerfect for “single right answer” tasks. Factoid Q&A, “find the one relevant document,” FAQ matching, autocomplete’s first suggestion.Rewards getting it right EARLY, not just eventually. Best for factoid questions where the first correct result suffices.Differentiates systems that recall-tie. Two retrievers might have identical Recall@10, but if one consistently puts the right chunk at rank 1 and the other at rank 9, MRR exposes that gap clearly. This is explicitly called out in recent RAG research: MRR is informative because in single-answer retrieval tasks, placing the correct passage at rank 1 versus rank 5 has a large impact on generator quality even when both configurations yield the same Recall@10.Especially useful for evaluating re-rankers, since MRR is particularly well-suited for assessing re-ranking strategies in RAG systems, as it emphasizes placing relevant information as close to the top of the ranked list as possible.ConsIgnores everything after the first hit. If there are 5 relevant documents and your system finds the first one at rank 1 but completely misses the other 4, MRR = 1.0 — a seemingly perfect score hiding a mediocre system.Not suitable when multiple relevant items matter. For e-commerce recommendations where a user might buy 3 different products, MRR undersells systems that surface many good options. As one guide notes: Mean Average Precision (MAP) measures comprehensive ranking quality across queries and is more sensitive than MRR when multiple relevant documents exist per query.Harder to interpret at scale. An MRR of 0.65 doesn’t tell you how many queries failed entirely vs. how many were just slightly delayed.Best used when:Your task has one (or a small number of) “correct” answers per query — think factoid QA, FAQ bots, “find this specific document.”You’re tuning or comparing re-rankers, since reranking is specifically about reordering, and MRR is the most sensitive metric to reordering.Rule of thumb from production use: An MRR above 0.8 indicates most queries return relevant results in the top 1–2 positions, though actual targets vary by domain and query complexity.⚖️ Side-by-Side Comparison TableContent Created by Author!🔍 Real-World Scenario: Building a RAG ChatbotLet’s ground this in something you’re probably actually building right now — a RAG-based chatbot.Your pipeline: Query → Retriever fetches top-k chunks → LLM generates answer using those chunks.Here’s how the three metrics map onto this pipeline:Step 1 — Is the retriever even capable of finding the answer?Use Recall@k. If the correct chunk isn’t in the top-k candidates at all, the LLM has zero chance of answering correctly, no matter how good it is. This is why this metric is particularly important for RAG systems since it calculates the chance the ground truth context is included among the retrieved top candidates.Step 2 — Is the re-ranker placing the best chunk near the top?Use MRR. After retrieval, you often apply a re-ranker (like a cross-encoder) to reorder candidates. MRR tells you whether the re-ranker is doing its job — putting the gold chunk at position 1 instead of position 8.Step 3 — Are the top-3 chunks you feed the LLM mostly relevant (not noisy)?Use Precision@k (often k = 3 to 5, matching your context window budget). This matters because stuffing irrelevant chunks into the LLM’s context can distract it and cause hallucinations, even if the right answer is technically “in there somewhere.”This three-stage view is echoed in recent evaluation literature too — teams don’t pick just one metric, they use metrics like Recall@k, MRR, or nDCG to see whether relevant results are returned and ranked well, applying each at the stage where it’s most diagnostic.🧩 The Metric Nobody Told You About: F1@k and NDCGPrecision and Recall often trade off against each other — you can boost one by sacrificing the other (retrieve more → recall ↑ but precision ↓, and vice versa). To balance them:F1@k: Harmonic mean of Precision@k and Recall@k, balancing the trade-off between precision and recall. Use this when you don’t want to over-index on either quality or completeness alone.NDCG@k (Normalized Discounted Cumulative Gain): Goes a step further than Recall or MRR by considering graded relevance (not just relevant/irrelevant, but “very relevant” vs “somewhat relevant”) and penalizing relevant items that appear lower in the ranking. In fact, recent benchmarking work treats it as the primary metric: nDCG@10 applies a log discount to graded relevance scores, penalizing models that place relevant passages at lower ranks within the top 10, and is the standard metric on BEIR, allowing direct comparison with published baselines.Think of NDCG as “Recall@k + MRR’s sensitivity to order, combined, with a smarter penalty curve.” It’s more complex to compute but gives you the most complete picture — which is why heavy-duty retrieval benchmarks default to it.💻 Let’s Code It (Python, No Libraries Needed)Here’s a clean, from-scratch implementation so you understand exactly what’s happening under the hood — no black-box library magic.https://medium.com/media/5c486ffdc3d2ec7153935b1491328e63/hrefOutput:Precision@5: 0.6Recall@5: 0.6Reciprocal Rank: 0.5For MRR across a whole evaluation set, you’d call mean_reciprocal_rank() with lists of relevant-sets and retrieved-lists for every query in your test set.# Simulating MRR over 3 queriesrelevant_sets = [{"a1"}, {"b3"}, {"c5"}]retrieved_lists = [ ["x", "a1", "y"], # hit at rank 2 → RR = 0.5 ["b3", "z", "w"], # hit at rank 1 → RR = 1.0 ["m", "n", "o"], # no hit → RR = 0.0]print("MRR:", mean_reciprocal_rank(relevant_sets, retrieved_lists))# (0.5 + 1.0 + 0.0) / 3 = 0.5🚨 Common Mistakes People MakeUsing only Precision@k for RAG retrievers. This hides the fact that your system might be missing the ONE chunk that actually answers the question. Always pair it with Recall@k.Using Recall@k alone to judge ranking quality. Recall doesn’t care about order — pair it with MRR or NDCG if rank position matters to your users.Picking an arbitrary k. Precision@100 is meaningless if your users only ever see the top 3 results. Match k to your actual UI/UX or LLM context window size.Forgetting that MRR collapses with multiple relevant answers. If your dataset has many valid answers per query (think: e-commerce, multi-document QA), MRR is too coarse — use MAP or NDCG instead, since MAP is more sensitive than MRR when multiple relevant documents exist per query.Not tracking all stages separately. As highlighted by recent RAG evaluation guides, it’s easy for a pipeline to score faithfulness and answer relevance well on the dashboard while context recall silently drops, because the model is good at sounding grounded even on incomplete context. Metric blindness at one stage can hide failure at another.🏁 Quick Decision Cheat SheetAsk yourself these questions:“Do I care about not showing junk?” → Precision@k“Do I care about not missing anything important?” → Recall@k“Do I care about how fast the user/system finds the first good answer?” → MRR“Do I care about both quality AND completeness equally?” → F1@k“Do I care about relevance AND exact position of every result (not just the first)?” → NDCG or MAPAnd in almost every real production system (search engines, recommenders, RAG pipelines), you won’t use just ONE of these. You’ll track a combination — Recall@k for the retriever, MRR or NDCG for the ranker, and Precision@k for what finally gets shown to the user.⭐️ Final takeawayPrecision@k, Recall@k, and MRR aren’t competitors — they’re complementary lenses looking at the same ranked list from different angles: quality, completeness, and speed-to-first-answer.Precision@k protects your users from noise — use it when what’s SHOWN matters most.Recall@k protects you from missing the truth entirely — use it when completeness is non-negotiable (RAG retrieval, legal/medical search).MRR protects the user’s time & attention — use it when there’s one right answer and it needs to appear FAST (factoid QA, re-ranker tuning).Never evaluate a retrieval or ranking system with just one metric. Like a doctor who only checks your temperature and ignores your blood pressure, a single metric can give you a dangerously incomplete diagnosis.When in doubt, map metrics to pipeline stages: Recall@k for “can we find it?”, MRR/NDCG for “did we rank it well?”, Precision@k for “is what we show actually good?”✨ Where to go from here!You have come this far, which really means a lot. The further steps are as follows:🎊 Appreciate yourself for deciding to read this blog, which has exponentially enhanced your knowledge.🎉 Follow me on Medium (It’s free) & opt in for email notifications to stay updated with my latest articles on multi-tech (Complete AIOPS).🎯 Follow me on LinkedIn (It’s free) to get the latest tech dose & tips & tricks.💬 I’d love to hear your thoughts! Drop a comment below or connect with me on LinkedIn/Twitter to discuss and exchange ideas.MRR vs Recall@k vs Precision@k was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.