AWS Builder Center
RAG from Basics to Advanced (Part 5): How Do You Know Your RAG System Is Actually Good?

RAG from Basics to Advanced (Part 5): How Do You Know Your RAG System Is Actually Good?

Precision, recall, MRR, faithfulness, and RAGAS the metrics and evaluation loop that turn RAG tuning from guesswork into measurement.

Series: RAG from Basics to Advanced (8 articles)

  1. …
  2. 5
    RAG from Basics to Advanced (Part 5): How Do You Know Your RAG System Is Actually Good? This article
AWS DevOps Engineer | 7+ Yrs Cloud Automation | EKS, ECS, IaC | GenAI & AIOps Expert
This is Part 5 of a series that builds up Retrieval Augmented Generation (RAG) from the ground up.
Every part so far has involved a design decision: chunk size, reranking, hybrid search. Here's the question that actually matters once you start making those decisions in a real project: how do you know if a change made things better? Without an answer to that, RAG development is just guessing with extra steps you're changing chunk size or adding a reranker because it "feels" like it should help, not because you've measured that it did.
This part is about closing that loop.

Why RAG Evaluation Is Harder Than It Looks

In traditional ML, evaluation is often straightforward there's a clear right answer, and you compute accuracy or F1 against it. RAG doesn't have that luxury, because there are really two separate things to evaluate:
  1. Retrieval:- did the system pull the right chunks out of the corpus?
  1. Generation:- did the LLM use those chunks correctly to produce a good, grounded answer?
These are different problems with different failure modes, and they need different metrics.

Part A: Evaluating Retrieval

Here we're only asking one question: did the retriever find the right chunks? Generation isn't part of this yet.

Precision and Recall

Precision:- of the chunks retrieved, how many were actually relevant?
Recall:- of all the relevant chunks that exist in the corpus, how many did we actually retrieve?
The classic trade-off: set top-K very small (K=1) and precision tends to be high (whatever you got back is probably relevant) but recall suffers you're likely missing other relevant chunks. Set top-K very large (K=50) and recall improves, but precision drops as irrelevant chunks get pulled in too.
This is the same tension covered in Part 3 a bi-encoder casting a wide net vs. a cross-encoder narrowing it down for precision. Evaluation is just what makes that tension measurable instead of a matter of feel.

Mean Reciprocal Rank (MRR)

Precision and recall tell you whether the right chunk was retrieved not where it landed in the ranking. A relevant chunk at position 1 and the same chunk at position 8 look identical to precision/recall if both fall within your top-10, but they behave very differently once handed to the LLM (recall the "lost in the middle" effect from Part 3 position matters).
MRR captures this: it's the reciprocal of the rank at which the first relevant result appears. A relevant chunk at position 1 gives an MRR of 1; at position 3, an MRR of 0.33.
The point: MRR tells you not just whether retrieval worked, but how quickly it worked which matters because of positional bias downstream in generation.

NDCG (Normalized Discounted Cumulative Gain)

This goes a step further, for cases where relevance isn't just binary (relevant/not relevant) but graded "highly relevant," "somewhat relevant," "not relevant" and there are multiple relevant chunks to consider. NDCG combines both position and graded relevance into a single score.
This is more useful when you actually have graded relevance labels available common in rigorous evaluation setups, less common in everyday production monitoring.

Part B: Evaluating Generation

This is where things get genuinely harder, because there's rarely a single "correct" answer string to compare against unlike traditional ML. This is why LLM-as-judge using a separate LLM to evaluate the response has become the common approach.

Faithfulness (Groundedness)

The question: did the generated answer rely only on the retrieved context, or did the model draw on its own (possibly outdated or wrong) internal knowledge?
This is hallucination detection, specific to the RAG setting. It typically works by:
  1. Breaking the generated answer into individual claims.
  1. Checking each claim against the retrieved context is it actually supported?
  1. Flagging any claim that isn't supported as "unfaithful."
The point: faithfulness measures whether the model stayed within its leash did it answer using only what was retrieved, or wander into its own parametric memory?

Answer Relevance

The question: does the generated answer actually address the user's question separate from whether it's faithful to the context?
This catches a subtle but real failure mode: an LLM can faithfully summarize the retrieved context while still not properly answering what was actually asked.

Context Precision and Context Recall

These sound like retrieval metrics, and they're related, but they're evaluated in the generation context specifically checking whether the context handed to the LLM was sufficient to answer the query, and how much of it was noise.

RAGAS: A Practical Framework

RAGAS (RAG Assessment) is an open-source framework that automates the metrics above faithfulness, answer relevance, context precision, context recall using an LLM-as-judge approach, and for some metrics, without requiring human-labeled ground truth.
Why this matters practically: manually reviewing every response doesn't scale running hundreds or thousands of test queries through a human reviewer isn't realistic. RAGAS turns these checks into an automated pipeline: you provide your RAG system, a set of test queries, and a judge LLM, and it produces scores.
One caveat worth keeping in mind: an LLM-as-judge isn't perfect it's a proxy, not ground truth. Production teams often maintain a small, human-evaluated "golden set" alongside automated scoring, specifically to periodically sanity-check that the judge LLM's scores are still trustworthy.

Setting Up an Evaluation Loop in Practice

  1. Build a golden dataset representative queries, along with the chunks that should ideally be retrieved and, where possible, expected answers. This takes real upfront effort, but nothing else here means anything without it.
  1. Measure a baseline record the metrics for your current system as it stands (current chunk size, no reranking, whatever the starting point is).
  1. Change one thing add a reranker, adjust chunk size, switch embedding models one variable at a time.
  1. Re-measure and compare against the baseline. A change only counts as an improvement when the metrics say so, not because it feels better.
  1. Repeat this is a continuous loop, not a one-time checklist item.

Summary

Metric
What It Measures
Stage
Precision / Recall
Did retrieval find the right chunks?
Retrieval
MRR
How high did the first relevant chunk rank?
Retrieval
NDCG
Position + graded relevance combined
Retrieval
Faithfulness
Did generation stick to the retrieved context?
Generation
Answer Relevance
Did the answer address the actual question?
Generation
Context Precision/Recall
Was the context sufficient and noise-free?
Generation
The closing point worth remembering:
You can't optimize what you can't measure. RAG has enough moving parts chunk size, retrieval strategy, reranking, prompting that without evaluation, you're not iterating, you're just guessing with extra steps.


Next in this series (Part 6): Advanced RAG patterns query routing, multi-hop retrieval, and agentic/self-RAG, where the model itself decides what and when to retrieve.

Series: RAG from Basics to Advanced (8 articles)

  1. …
  2. 5
    RAG from Basics to Advanced (Part 5): How Do You Know Your RAG System Is Actually Good? This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article