Why RAG Evaluation is Hard

Separate retrieval failures from generation failures and pick what to measure.

Last Updated: 27, Nov 2026

Search Tutorials

--Ads--

Module 16 · Lesson 1 of 8 · Intermediate

Why RAG Evaluation is Hard

Separate retrieval failures from generation failures and pick what to measure.

Every lesson in this tutorial has offered a technique that "usually helps". Whether it helps your system, with your documents and your users' questions, is something only evaluation can tell you. Without it, RAG development turns into guesswork: you change the chunk size, try three questions, and hope. This module shows how to measure instead. This first lesson explains what makes RAG evaluation tricky and what to measure.

Why it is hard

  • Two systems in one. A bad answer can come from retrieval (the right passage was never found) or from generation (the passage was found but misused). An end-to-end score cannot tell you which.
  • No single right answer. "Employees get 18 days" and "New staff receive eighteen days of paid leave in year one" are both correct. String matching fails on free text.
  • Correct is not the same as grounded. An answer can be true but unsupported by the sources (the model used its own knowledge), or supported by an outdated source and therefore wrong.
  • "I don't know" is sometimes the right answer. Your test set needs questions that should not be answered.
  • Test data is scarce. Few teams start with labelled question-answer pairs for their own documents.

What to measure

A triangle of question, retrieved context and answer, with context relevance between question and context, faithfulness between context and answer, and answer relevance between question and answer; a reference answer enables correctness.
Figure 1. The three relationships to evaluate, plus correctness when a reference answer exists.
MetricQuestion it answersNeedsLesson
Retrieval recall / hit rateDid we retrieve the evidence?Labelled relevant chunks or evidence stringsRetrieval metrics
Context precisionHow much of what we retrieved is useful?Relevance labels or an LLM judgeGeneration metrics
FaithfulnessIs the answer supported by the context?Context and answer (LLM judge)Generation metrics
Answer relevanceDoes the answer address the question?Question and answer (LLM judge)Generation metrics
CorrectnessDoes it match the reference answer?Reference answersLLM-as-judge
AbstentionDoes it decline when it should?Unanswerable test questionsGolden test sets
Latency and costIs it fast and affordable enough?Timing and token logsCost optimisation

Offline and online evaluation

  • Offline: run a fixed test set through the pipeline before releasing a change. Repeatable and safe; this module focuses on it.
  • Online: measure real usage: user ratings, follow-up rate, escalations to humans. Covered in Feedback Loops and A/B Testing.

Start small, today

You do not need a framework or a thousand questions to begin. Twenty to fifty real questions, each with the evidence that answers it, already let you compare chunking strategies, embedding models and prompts. Log every run so results can be compared later:

run_eval.py
import json
import time
from datetime import datetime, timezone

def run_eval(test_set: list[dict], retrieve, generate, run_name: str, k: int = 5) -> str:
    """retrieve(question, k) -> list of hits with .id and .text; generate(question, hits) -> str"""
    out_path = f"eval_runs/{run_name}-{datetime.now(timezone.utc):%Y%m%d-%H%M%S}.jsonl"
    with open(out_path, "w", encoding="utf-8") as out:
        for case in test_set:
            t0 = time.perf_counter()
            hits = retrieve(case["question"], k)
            t1 = time.perf_counter()
            answer = generate(case["question"], hits)
            t2 = time.perf_counter()
            out.write(json.dumps({
                **case,
                "retrieved_ids": [h.id for h in hits],
                "retrieved_texts": [h.text for h in hits],
                "answer": answer,
                "retrieval_ms": round((t1 - t0) * 1000),
                "generation_ms": round((t2 - t1) * 1000),
            }) + "\n")
    return out_path

The following lessons compute metrics from files like this one. Keeping raw outputs (not just scores) lets you re-score old runs with new metrics and read individual failures.

The most useful habit

Numbers tell you whether something got worse; reading failures tells you why. After every evaluation run, read at least ten failed cases in full: the question, the retrieved chunks and the answer.

Key takeaways

  • Evaluate retrieval and generation separately so you know which part failed.
  • Measure context relevance, faithfulness, answer relevance and, with references, correctness.
  • Include unanswerable questions to test abstention.
  • Start with a small test set and log full outputs for every run.