AssayAssay
07 / 08

Lesson 07 · Answering · 13 min

Evaluating RAG

A wrong answer from a RAG system has two possible causes, and they need different fixes. Either the right passage was never retrieved, or it was retrieved and the model failed to use it. A single end-to-end score cannot distinguish them, so it cannot tell you what to do next.

Retrieval failureThe answering passage was not in the context. Fix chunking, the query, k, or the embedding model. Nothing about the prompt will help.
Generation failureThe passage was there and the answer is still wrong — ignored, misread, or contradicted by parametric knowledge. Fix grounding, the prompt, or the model.

So evaluate in two stages. Score retrieval against your labelled passages, then score the answer only on the questions where retrieval succeeded. The second number is the one that tells you about the model, and it is usually much better than the end-to-end score suggests.

  • Faithfulness: is every claim supported by a retrieved passage? A judge with the passages in front of it does this well.
  • Answer relevance: does it address the question asked, rather than something adjacent that was retrieved?
  • Attribution: does the cited passage actually contain the claim? Cheap to check and frequently wrong.
  • Abstention correctness: does it decline exactly on the questions nothing answers?

Faithfulness is the one worth building first, because it catches the failure that matters: an answer that reads well, cites a real passage, and states something that passage does not say. That survives casual review in a way an obviously wrong answer does not.

This is the evals course applied to a two-part system. The graders are the same, the datasets are the same, and the only new idea is measuring the components separately before measuring them together.

Checkpoint

Find one retrieval failure and one generation failure, and say which fix each needs.

The easy case: one passage answers it, and retrieval either finds that passage or it does not.

For each question, first check whether the answering passage was retrieved, then judge the answer. Keep the two verdicts separate — that separation is the lesson.

Nothing retrieved yet. Pick a question and press Retrieve — the passages come back with their similarity scores.