RAG
Advanced 14 min read RAG

Evaluating RAG Systems

Three scorecards, one dashboard

RAG evaluation is three metrics, not one: retrieval quality (recall), groundedness (are claims supported), and answer quality (is it useful). Measured together, they direct every optimization.

RAG evalretrieval recallgroundednessanswer qualitygolden set
Before we start

What you will learn

  • Define retrieval, groundedness and answer metrics
  • Build a golden set without leaking
  • Use eval splits to direct fixes
Introduction

What is this?

A RAG system can fail retrieving the right chunks, generating unsupported claims, or being unhelpful despite correct facts. Evaluation must measure all three separately: retrieval recall@k, groundedness (citation/containment rate), and answer quality (faithfulness + usefulness on context). Jointly they tell you WHICH stage to fix — the highest-leverage RAG decision.

Motivation

Why do you need it?

  • Retrieval metrics alone hide answer-quality problems and vice versa.
  • A component scorecard prevents 'improved' rounds that made grounding worse.
  • Golden sets build a regression net for the whole pipeline.
  • Evidence-based tuning beats team intuition — especially as RAG gains complexity.
Think about it

Mental model

Imagine

A relay race with three timers

Think of

RAG evaluation

Which leg lost the race? Only per-leg timing tells you: retrieval (the baton handoff), grounding (not dropping facts), generation quality (not fumbling the finish). Timing one leg call it a 'race problem' hides where the actual fix lives.

Mechanics

How it works

  • Golden set: (query, expected chunks) + high/medium/low reference answers.
  • Retrieval eval: recall@k, MRR on expected chunks.
  • Groundedness eval: claims ↔ chunk containment/citation validity.
  • Answer eval: LLM-judge or human labels on faithfulness + helpfulness.
  • Regression runs: same pipeline diff on each config change.

Three RAG scorecards.

Retrieval
Groundedness
Answer
Act
Real world

In production

  • Release gates: any config change must not regress the three scores.
  • Fraction-of-error dashboard: '70% of bad answers trace to retrieval'.
  • Live-to-eval loop: sample traffic into golden sets for continuous coverage.
Guidelines

Best practices

  • Keep golden sets versioned, small, and representative (not just easy queries).
  • Separate the eval for chunks (retrieval) from eval of final answers.
  • Track a drift alert per stage — each has its own failure signature.
  • Sample real user questions into goldens on a schedule.
Watch out

Common mistakes

  • Scoring only final answers — stuck not knowing which of three stages regressed.
  • Evaluating on the training/tuning queries (leak).
  • Asserting 'better answer' without grounding numbers worsening.
  • Golden set stale while corpus grows.
Root cause analysis

Common issues

Error
Eval flips while prod doesn't change
Root cause

LLM-judge variance

Fix

Aggregate multiple runs, use deterministic references, and swap to human spot-checks periodically.

Error
Golden queries too easy
Root cause

Sample bias

Fix

Pull real traffic, add adversarial/hard cases, keep distributions fresh.

When things break

Debugging tips

  • Grounding score down, retrieval fine → generation stage: prompts, rerank feed, refusal logic.
  • Retrieval down but answer decent → lucky top-k; fix chunks/retriever, don't celebrate.
  • Answer quality 'better' but grounding worse → likely overfitting the judge or prompt tweaks.
Interviews

Interview checkpoint

Practice

Hands-on lab

Score a RAG Pipeline's Three Axes
40 min · intermediate
In progress
Objectives
  • Compute retrieval recall@k on golden chunks
  • Score groundedness by containment
  • Report a three-axis scorecard

Score a RAG Pipeline's Three Axes

40 min · intermediate

0/4 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

Retrieval evaluation measures…

2

High answer quality implies the system is grounded.

Go deeper

Official documentation