<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ketan Pandey on Medium]]></title>
        <description><![CDATA[Stories by Ketan Pandey on Medium]]></description>
        <link>https://medium.com/@pandeyketan111?source=rss-54658f0c5cfc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*exO-HVVrBqk_FdA3uOM48A.jpeg</url>
            <title>Stories by Ketan Pandey on Medium</title>
            <link>https://medium.com/@pandeyketan111?source=rss-54658f0c5cfc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 14:35:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pandeyketan111/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond Top-K: How to Evaluate Retrieval Quality in RAG]]></title>
            <link>https://medium.com/@pandeyketan111/beyond-top-k-how-to-evaluate-retrieval-quality-in-rag-4998c0c0ca07?source=rss-54658f0c5cfc------2</link>
            <guid isPermaLink="false">https://medium.com/p/4998c0c0ca07</guid>
            <category><![CDATA[rag-evaluation]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm-evaluation]]></category>
            <dc:creator><![CDATA[Ketan Pandey]]></dc:creator>
            <pubDate>Wed, 30 Sep 2026 11:45:08 GMT</pubDate>
            <atom:updated>2026-09-30T13:42:47.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FsSzq2_D6JRxvqtmHvf1sw.png" /></figure><p>You built a RAG system.</p><p>The LLM generates good-looking answers, the vector search returns results, and everything seems to work.</p><p>But there is one important question:</p><blockquote>Did the retriever actually retrieve the evidence required to answer the question?</blockquote><p>A wrong RAG answer is not always an LLM problem. The issue can be much earlier in the pipeline:</p><p><strong>Relevant chunk was never retrieved</strong></p><p><strong>Relevant chunk was ranked too low</strong></p><p><strong>Too much irrelevant context was retrieved</strong></p><p><strong>Query rewriting changed the original intent</strong></p><p><strong>Metadata filtering removed the correct document</strong></p><p><strong>Conflicting or outdated chunks were retrieved</strong></p><p>That is why retrieval evaluation should happen before optimizing the LLM.</p><blockquote><strong>1. Build a Golden Dataset</strong></blockquote><h3>Start with a small evaluation dataset containing:</h3><p>{</p><p>“question”: “Can a nonresident partner participate in a composite return?”,</p><p>“relevant_chunks”: [“chunk_142”, “chunk_587”],</p><p>“reference_answer”: “…”,</p><p>“jurisdiction”: “CA”,</p><p>“tax_year”: “2026”</p><p>} <br>For every question:</p><ol><li>Run the retriever</li></ol><p>2. Collect top-K chunks</p><p>3. Compare them with expected evidence</p><p>4. Calculate retrieval metrics</p><p>5. Analyze failed cases</p><p>Now you can measure retrieval instead of judging the final answer manually.</p><blockquote><strong>2. Recall@K — Did We Find the Evidence?</strong></blockquote><p>Recall@K measures how much of the relevant information was retrieved.</p><p>For example, if there are 5 relevant chunks and the top-10 retrieval contains 4:</p><blockquote>Recall@10 = 4 / 5 = 0.80</blockquote><p>Formula:</p><p>Recall@K =</p><p>Relevant chunks retrieved in top-K</p><p>— — — — — — — — — — — — — — — — — -</p><p>Total relevant chunks</p><p>Low recall means your retriever is missing evidence.</p><p>Increasing the LLM context size won’t fix information that was never retrieved.</p><blockquote><strong>3. Precision@K — How Much Noise Did We Retrieve?</strong></blockquote><p>Precision measures how much of the retrieved context is actually relevant.</p><p>If 6 of your top 10 chunks are relevant:</p><p>Precision@10 = 6 / 10 = 0.60</p><p>High recall with very low precision can create another problem:</p><p>More chunks</p><p>↓</p><p>More irrelevant context</p><p>↓</p><p>More tokens + more noise</p><p>↓</p><p>Potentially worse generation</p><p>So the goal isn’t simply to retrieve more chunks.</p><p>It’s to retrieve enough relevant evidence with minimum noise.</p><blockquote>4. MRR — How Early Did We Find Relevant Information?</blockquote><p>Mean Reciprocal Rank focuses on the position of the first relevant result.</p><p>Relevant at #1 → 1.00</p><p>Relevant at #2 → 0.50</p><p>Relevant at #5 → 0.20</p><p>For multiple queries:</p><blockquote>MRR = Average(1 / rank of first relevant result)</blockquote><p>MRR is useful when getting relevant information early is important.</p><p>But MRR has a limitation:</p><blockquote>It mainly cares about the first relevant result.</blockquote><p>What if answering a question requires multiple pieces of evidence?</p><p>That’s where nDCG becomes useful.</p><blockquote>5. nDCG — Is Relevant Evidence Ranked Well?</blockquote><p>nDCG evaluates the ranking and distribution of relevant results.</p><p>For example:</p><blockquote>Rank: 1 2 3 4 5</blockquote><blockquote>Relevance: 3 2 0 1 0</blockquote><p>A highly relevant result at rank 1 should contribute more than the same result at rank 5.</p><p>The standard formula is:</p><p>DCG@K = Σ (2^relᵢ — 1) / log₂(i + 1)</p><p>nDCG@K = DCG@K / IDCG@K</p><p>The score ranges from 0 to 1.</p><p>Higher nDCG means relevant evidence is generally appearing higher in the ranking.</p><blockquote>6. One More Metric: Context Sufficiency</blockquote><p>Traditional retrieval metrics don’t always answer the most important production question:</p><blockquote>Is the retrieved context sufficient to answer the user’s question?</blockquote><p>For example, a question may require three pieces of evidence:</p><p>Required:</p><p>✓ Eligibility rule</p><p>✓ State-specific exception</p><p>✓ Tax-year requirement</p><p>Retrieved:</p><p>✓ Eligibility rule</p><p>✓ State-specific exception</p><p>✗ Tax-year requirement</p><p>The retrieved chunks may have good precision and ranking, but the context is still incomplete.</p><p>A simple dataset-level metric can be:</p><p>Context Sufficiency =</p><p>Questions with sufficient evidence</p><p>— — — — — — — — — — — — — — — — — -</p><p>Total evaluated questions</p><p>This is especially useful for multi-hop and complex domain-specific RAG.</p><blockquote>7. Evaluate Different Top-K Values</blockquote><p>Don’t choose `top_k=5` just because it feels reasonable.</p><blockquote>Recall@K Precision@K nDCG@K</blockquote><blockquote>Top-3 0.72 0.90 0.76</blockquote><blockquote>Top-5 0.84 0.79 0.83</blockquote><blockquote>Top-10 0.94 0.58 0.81</blockquote><p>Increasing K usually improves recall, but can reduce precision.</p><p>The goal is not:</p><blockquote>“Use the largest K.”</blockquote><p>The goal is:</p><blockquote>“Find the smallest K that provides sufficient evidence without excessive noise.”</blockquote><blockquote>8. Diagnose the Failure, Not Just the Score</blockquote><p>When retrieval fails, classify the failure.</p><blockquote>Retrieval Failure:</blockquote><blockquote>Missing Ranking Wrong</blockquote><blockquote>Evidence Failure Context</blockquote><p>Examples:</p><p><strong>Missing evidence</strong></p><p>The required chunk was never retrieved.</p><p>→ Check chunking, embeddings, indexing, metadata filters.</p><p><strong>Ranking failure</strong></p><p>The correct chunk exists but appears too low.</p><p>→ Check retrieval strategy and reranking.</p><p><strong>Wrong context</strong></p><p>Conflicting, outdated, or wrong-jurisdiction chunks were retrieved.</p><p>→ Check metadata and filtering.</p><p>This makes evaluation actionable instead of just producing a score.</p><blockquote>Final Takeaway</blockquote><p>A production RAG system should not be evaluated only by asking:</p><blockquote>“Was the final answer correct?”</blockquote><p>Also ask:</p><blockquote>“Did we retrieve the right evidence?”</blockquote><p><strong>A practical baseline is:</strong></p><p>Recall@K</p><p>Precision@K</p><p>MRR</p><p>nDCG@K</p><p>Context Sufficiency</p><p><strong>Then evaluate the LLM separately for:</strong></p><p>Faithfulness</p><p>Correctness</p><p>Answer Relevance</p><p>Citation Accuracy</p><p><strong>Because ultimately:</strong></p><p>Good RAG = Good Retrieval + Sufficient Context + Correct Generation</p><p>Don’t just evaluate the answer. Evaluate the evidence that produced it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4998c0c0ca07" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>