Module 4 of 5 · 45 min

RAG Evaluation & The RAG Triad

Quantify RAG quality using deterministic evaluation metrics: Context Relevance, Groundedness (Faithfulness), and Answer Relevance.

Core concept

By the end

You will be able to

  • Implement the RAG Triad: Context Relevance, Groundedness, and Answer Relevance.
  • Use LLM-as-a-judge patterns with deterministic structured scoring rubrics and logit bias.
  • Identify and diagnose retrieval failure modes vs synthesis hallucination failure modes.
  • Build automated regression testing CI pipelines for enterprise knowledge updates.
01

The Three Core Pillars of RAG Quality

Measuring end-to-end user satisfaction does not tell you why a RAG pipeline failed. The RAG Triad isolates the three failure domains:

1. Context Relevance: Did the retrieval engine fetch chunks that actually answer the query? 2. Groundedness (Faithfulness): Are all claims in the generated response directly supported by the retrieved context? 3. Answer Relevance: Does the generated response directly address the user inquiry without extraneous drift?

Groundedness Verification Judge Prompt
python
GROUNDEDNESS_JUDGE_PROMPT = """You are a rigorous evaluation judge. Evaluate if every statement in the ANSWER is supported by the CONTEXT.

CONTEXT:
{context}

ANSWER:
{answer}

Respond with strict JSON:
{{
  "unsupported_claims": ["list of unsupported statements"],
  "groundedness_score": 0.0 to 1.0,
  "verdict": "PASS" | "FAIL"
}}"""

Practice activity

Implement Automated RAG Triad Regression Test

  1. Create a test fixture with 10 synthetic query-context-answer triples (5 grounded, 5 hallucinated).
  2. Run an automated evaluation harness computing Groundedness and Answer Relevance scores.
  3. Assert that ungrounded answers are flagged with 100% precision.

What to produce

  • Evaluation report JSON with per-metric scores and claim attribution logs.

Reflect before continuing

Why is groundedness scoring critical before deploying automated customer-facing RAG systems?

Evidence

Sources and verification

Knowledge check

Make it stick.

Pass at 80%

Choose the strongest answer for each question. Your attempts become part of your account transcript.

01If a RAG system retrieves irrelevant context but the model hallucinates a correct-sounding response, which metric fails?