RAG evaluation is the practice of testing a retrieval-augmented generation (RAG) system in two layers: whether the retriever found the right evidence, and whether the model's answer is correct, complete, and faithful to that evidence. Testing the layers separately shows where a wrong answer started.
A RAG assistant answers questions by searching your documents and passing the best passages to a language model. When it gets one wrong, the screen shows only the final text. The cause could be a document the search missed, a document the model misread, or a claim the model made up, and each one needs a different fix. This guide shows how to score each layer, with a worked example and the formulas, how to read the results together, and how to keep evaluating after launch.
TL;DR
30-second summary
How do you evaluate a RAG system and how do you find where a wrong answer started?
RAG evaluation is the practice of testing a retrieval-augmented generation (RAG) system in two layers: whether the retriever found the right evidence, and whether the model's answer is correct, complete, and faithful to that evidence.
- Build the evaluation set first. Each test question needs the user's own wording, every relevant passage in the knowledge base, and an expert reference answer. Cover multi-document questions, conflicting sources, vague queries, and questions the knowledge base cannot answer, because easy lookups flatter any pipeline.
- Retrieval metrics check whether the system found the right evidence. Hit@k, Recall@k, Precision@k, reciprocal rank, average precision, and nDCG compare returned passages with the ones you labeled as relevant. Report the zero hit rate separately, because those questions give the generator no evidence to work from.
- Generation metrics check whether the model used the evidence well. Correctness, relevance, completeness, and clarity score the answer, while faithfulness checks that every claim traces back to the retrieved passages. A claim from outside your documents is how invented policies appear, even when the claim happens to be true.
- Read both layers together, and scale scoring with calibrated judges. Every question lands in one of four situations, and a good answer from poor retrieval is the suspect case. Reviewers score a sample, an LLM judge scores everything, and you measure how closely the two agree before trusting the judge.
- Change one thing at a time, and keep evaluating after launch. Rerun the full set after each change to chunk size, embedding model, reranker, k, or prompt. Sample production conversations, and add each confirmed failure to the test set.
Bottom line: A RAG system can fail at retrieval, at generation, or in the handoff between them, and a single score hides which. Score the retriever and the answers separately, read the two together, and keep checking after launch.
What RAG evaluation covers
A RAG pipeline has two places where an answer can go wrong, so it gets two sets of scores.

The retriever searches the knowledge base for passages that match the question. The language model then writes an answer from the question and those passages. Retrieval evaluation scores the first step, and generation evaluation scores the second. An end-to-end score blends them, which is why a low result alone cannot say whether to fix the search, the prompt, or the model.
Build the evaluation set first
Every metric in this guide depends on a test set, so build it before you pick tools. For each test question, record three things.
| Part | What to record | Why it matters |
|---|---|---|
| Question | A real user question, in the user's own wording | Real phrasing includes vague wording, abbreviations, and typos that tidy questions hide |
| Relevant passages | Every passage in the knowledge base that helps answer it, not just one | Retrieval metrics compare what the system returned with this list |
| Reference answer | The answer an expert would give, with the passages it rests on | Generation metrics compare the model's answer with it |
Support tickets, search logs, and interviews with subject-matter experts are the best sources of questions. Questions written by the authors of the documents tend to echo the documents' wording, which makes retrieval look easier than it is. This is the same idea as a golden dataset, which is a curated, expert-checked set that you measure against after every change.
Cover the hard categories on purpose, because easy lookups flatter any pipeline:
- Single-fact lookups. The baseline, and the easiest to pass.
- Multi-document questions. The full answer is spread across several passages, so recall matters.
- Conflicting or outdated sources. Near-duplicate and old versions of a policy are common in real knowledge bases.
- Vague and abbreviated queries. Product codes, acronyms, and half-formed questions.
- Questions the knowledge base cannot answer. The correct behavior is to say so.
Label every relevant passage, even when there are several. If only one passage per question is marked, precision and recall stop meaning much, as the pitfalls section explains. Keep the set in version control, and update it whenever the documents change.
Retrieval metrics: Did the system find the right evidence?
Retrieval metrics compare the passages the retriever returned with the passages you marked as relevant. One example runs through this section.
Can I get a refund on an annual plan after 30 days?
Three passages are marked as relevant: the refund policy section for annual plans, a clause on exceptions under regional consumer law, and an FAQ entry on how to submit a refund request. The retriever returns its top five results (k = 5):
- Article on cancelling a monthly plan (not relevant)
- Refund policy for annual plans (relevant)
- Archived pricing page (not relevant)
- FAQ on requesting a refund (relevant)
- Plan comparison page (not relevant)
The exceptions clause was not retrieved at all.
| Metric | Question it answers | How it is computed |
|---|---|---|
| Hit@5 | Did anything relevant appear in the top 5? | 1 if at least one relevant passage is in the top 5, otherwise 0 |
| Recall@5 | How much of the relevant evidence was found? | Relevant passages in the top 5 divided by all relevant passages |
| Precision@5 | How much of what came back is useful? | Relevant passages in the top 5 divided by 5 |
| Reciprocal rank | How early does the first relevant passage appear? | 1 divided by the rank of the first relevant passage |
| Average precision | How well are all relevant passages ranked? | Average of the precision at each rank where a relevant passage appears, with missed passages counting as 0 |
| nDCG@5 | How close is the ranking to the ideal order? | Discounted cumulative gain divided by the best possible value |
The same formulas in compact form, with rank i running from 1 to k:

Average reciprocal rank across all test questions gives mean reciprocal rank (MRR), and average AP gives mean average precision (MAP). For nDCG in the example, the two relevant passages sit at ranks 1 and 4, so the gain is 1/log2(2) + 1/log2(5) = 1.43. The ideal ordering would place all three relevant passages at ranks 1 to 3, which gives 1 + 0.63 + 0.50 = 2.13.
How to read them
- Hit@k is easy to explain and easy to fool. It treats "found one of three" the same as "found all three." Recall@k separates them, and it matters most for questions whose answer is spread across several passages. Here, the missing exceptions clause is the whole recall loss.
- Precision@k measures noise. Irrelevant passages cost tokens and can distract the model. Three of the five results in the example are noise.
- Choose rank-aware metrics when order matters. MRR rewards putting the first good passage high, which suits questions that one passage can answer. MAP and nDCG reward ranking every relevant passage high. nDCG also supports graded labels such as "partly relevant" and "highly relevant."
- Report the zero hit rate on its own line. It is the share of questions whose top k contains nothing relevant, so the generator had no chance of answering from evidence. If 12 of 200 test questions come back with nothing useful, Hit@5 averages 94% and the zero hit rate is 6%.
- Position also matters inside the prompt. Language models tend to use information at the start or end of a long input better than information buried in the middle. A passage that is retrieved but ranked low may still be missed.
Pick k to match the number of passages your prompt actually receives, and report each metric per question category as well as overall.
Generation metrics: Did the model use the evidence well?
The second layer scores the answer. It needs the question, the retrieved passages, and, where you have one, the reference answer. Take the same HR question. The reference answer says up to five days carry over and must be used by March 31, and that employees on approved long-term leave can carry over all unused days under the regional addendum. The assistant replied:
You can carry over up to five unused vacation days. They expire on March 31. Submit the carryover request in the HR portal.
| Metric | Question it asks | Needs | Score on the example |
|---|---|---|---|
| Correctness | Does the answer agree with the reference answer or verified facts? | Reference answer | Partly correct. Five days and March 31 are right, but the answer implies there are no exceptions |
| Relevance | Does it address the question that was asked? | Question | Pass |
| Completeness | Is everything the user needs included? | Reference answer | Fail. The long-term leave exception is missing |
| Clarity | Is it understandable, well organized, and the right length? | Answer | Pass |
| Faithfulness | Is every claim supported by the retrieved passages? | Retrieved passages | 2 of 3 claims supported, 0.67 |
Completeness and correctness failures often start in retrieval. The exceptions are missing because the regional consumer law clause was never retrieved. The generator could not include what it never saw, so the fix is in search, not in the prompt.
Faithfulness catches what the other four miss. Also called groundedness, it checks whether each claim in the answer can be traced to the retrieved passages. The usual method splits the answer into individual statements and checks each one against the context, and the score is the share that are supported. Here the answer makes three claims. The 30-day window and the statement that refunds stop afterward both come from the refund policy. The claim about keeping access until the end of the billing year appears in none of the five retrieved passages. It may even be true, but the model got it from somewhere other than your documents, and that is the behavior that produces invented policies. Because the check compares the answer only with what was retrieved, it needs no reference answer.
For questions the knowledge base cannot answer, add one more check: did the assistant say it does not know, instead of guessing?
Unlike the retrieval metrics, most of these qualities cannot be computed with a formula. People score them, or a second model scores them against a written rubric, or both.
Reading both layers together
Once both layers have scores, every test question falls into one of four situations.

Check the suspect case first. A good answer from poor retrieval looks like a pass, but it cannot be traced to your documents and may stop being right the day a policy changes. End-to-end results still matter, because they reflect what users see. They are most useful when every low score can be traced to one of these four situations.
Make RAG quality something you can measure
TestDevLab's QA engineers build evaluation sets, score retrieval and answers separately, and track the results across releases. You get clear evidence of where your RAG system fails and whether each change helps.
Scoring at scale: Reviewers, LLM judges, and calibration
Human review is the reference standard, but it is slow. An LLM judge scales it. The practical setup uses both: reviewers score a sample, the judge scores everything, and you check that the two agree.
| Approach | Strengths | Limits | Use it for |
|---|---|---|---|
| Human reviewers | Understand domain nuance, and set the reference for calibration | Slow and costly, and inconsistent between people without a rubric | The first scores, calibrating judges, and high-risk question categories |
| LLM judge with a rubric | Fast, cheap per answer, and easy to rerun on every release | Known biases and limited reasoning, so it needs calibration | Scoring every answer in the evaluation set |
| Rule-based checks | Exact and repeatable | Cover only what can be written as a rule | Cheap guards on every answer, such as "the assistant declined when the question was unanswerable" |
Judges are useful but not neutral. They can favor the answer shown first (position bias), longer answers (verbosity bias), and answers written by their own model family (self-enhancement bias), and they can reason poorly about hard questions. Whether a judge agrees with your reviewers on RAG answers is something to measure on your own questions, not to assume.
Calibrate a judge in five steps:
- Write the rubric. One prompt per metric, with a definition and a description of what a pass looks like.
- Build a reference sample. Have two reviewers score the same answers and resolve their disagreements.
- Compare the judge with the reference. Measure agreement per metric, and revise the rubric until the two are consistently close.
- Repeat the judgment. Score the same answer several times and look at the spread. Unstable verdicts mean the rubric needs to be tighter.
- Re-check on every change. Repeat the comparison whenever the judge model, the rubric, or the knowledge base changes.
To reduce bias, use a judge from a different vendor than the model that wrote the answers, and randomize answer order when you compare two. TestDevLab's article on evaluating AI meeting summaries with LLM-as-a-judge shows one way to put this into practice, and our guide on how to test an AI chatbot covers judge scoring for conversational answers.
Pitfalls, safe changes, and evaluation after launch
Common pitfalls
| Pitfall | Why it misleads | Fix |
|---|---|---|
| One labeled passage per question | Precision@k can never exceed 1/k, and Recall@k carries the same information as Hit@k, so the numbers look more exact than they are | Label every relevant passage |
| Reporting only averages | A change can lift the overall score while breaking every multi-document question | Report per question category, and list the questions that got worse |
| A stale test set | Documents change, and labels end up pointing at passages that moved or no longer exist | Review the labels whenever the documents change |
| Testing only answerable questions | An assistant that always guesses looks perfect | Include unanswerable questions and score whether it says it does not know |
| Accepting a good answer from poor retrieval | The model may have answered from its training data, so the answer cannot be traced to your documents and may be wrong tomorrow | Flag these questions for review |
| Never checking the judge | Biases and drift go unnoticed | Calibrate against reviewers, and repeat the check after changes |
Change one thing at a time
Chunk size, the embedding model, the reranker, k, the prompt, and the generator settings all interact. Change one, rerun the whole evaluation set, and compare both layers' scores with the previous run. Log the question, the retrieved passages with their ranks, the final prompt, and the answer, along with the configuration that produced them: model versions, chunking settings, k, and prompt version. Without those records, a low score cannot be investigated later. Keep the questions that failed before as a regression set, and see our regression testing guide for how to decide what to rerun.
Keep evaluating after launch
An offline test set cannot cover real usage. Real questions are messier than test questions, and the documents keep changing, so a RAG system has to be evaluated while it runs, not only before launch.
Sample production conversations, score them with the same criteria as the test set, and add each confirmed failure to the test set as a new question. Track the zero hit rate, recall, and faithfulness over time, because they drift as documents are added, edited, and retired. The offline set and production sampling then feed each other. For any product that keeps changing after release, this loop is a core part of AI testing.
The bottom line
A RAG system can fail at retrieval, at generation, or in the handoff between them, and a single score hides which. Build a labeled evaluation set, score the retriever and the answers with separate metrics, read the two together, and keep checking after launch. The setup takes effort, and its automated parts still need human review. In return, every change to the pipeline gets a measurable result, and every wrong answer becomes something you can fix.
To test the assistant as a whole, see our guides to how to test an AI chatbot and how to test LLM apps, and our AI chatbot testing service.
FAQ
Most common questions
What is RAG evaluation?
RAG evaluation is the practice of testing a retrieval-augmented generation system in two layers: whether the retriever found the right evidence, and whether the model's answer is correct, complete, and faithful to that evidence. Testing the layers separately shows where a wrong answer started. A missed document needs a search fix, a misread document needs a prompt or model fix, and an invented claim needs a faithfulness fix. An end-to-end score alone cannot say which one to choose.
What metrics should you use to evaluate RAG retrieval?
Retrieval metrics compare the passages the retriever returned with the passages you marked as relevant. Hit@k shows whether anything relevant appeared, Recall@k shows how much of the relevant evidence was found, and Precision@k shows how much of what came back is useful. Reciprocal rank, average precision, and nDCG reward ranking relevant passages higher. Also report the zero hit rate, which is the share of questions with nothing relevant in the top k, and break every metric down by question category.
What is faithfulness in RAG evaluation?
Faithfulness, also called groundedness, checks whether each claim in an answer can be traced to the retrieved passages. The usual method splits the answer into individual statements, checks each one against the retrieved context, and scores the share that are supported. A claim that appears in none of the retrieved passages counts against the answer, even if it is true, because the model took it from somewhere other than your documents. Faithfulness needs no reference answer, since it compares the answer only with what was retrieved.
How do you build a RAG evaluation set?
For each test question, record a real user question in the user's own wording, every passage in the knowledge base that helps answer it, and an expert reference answer with the passages it rests on. Support tickets, search logs, and subject-matter expert interviews are the best sources. Cover single-fact lookups, multi-document questions, conflicting or outdated sources, vague queries, and questions the knowledge base cannot answer. Keep the set in version control and update it whenever the documents change.
How do you use an LLM judge to score RAG answers?
Reviewers score a sample, the judge scores everything, and you check that the two agree. Write one rubric per metric, have two reviewers score the same answers and resolve disagreements, then measure the judge's agreement with that reference. Score the same answer several times to check stability, and repeat the comparison whenever the judge model, rubric, or knowledge base changes. Use a judge from a different vendor than the model that wrote the answers, and randomize answer order to reduce bias.
Know where your RAG system fails before your users do
TestDevLab combines ISTQB-certified engineers with automated evaluation suites that score retrieval and answers on every release. You see which change helped and which one broke a question category.





