Learn/LangChain Mastery/Part 9 · 8. Production, Evaluation & Governance
Lesson 65 of 68
SyllabusLangChain Mastery · Part 9

Faithfulness & Relevance

The two pillars of Truth. Did we hallucinate? Did we answer?

Course outline & contents
LangChain Mastery
Async & High-Throughput PatternsLatency & TTFT OptimizationTracing with LangSmithRAG Evaluation BasicsFaithfulness & RelevancePrompt Injection DefenseInput & Output GuardrailsDeployment & API Serving

RAG evaluation usually comes down to checking the relationships between 3 nodes: Query, Context (Docs), and Answer.

We care about two main edges:

  1. Faithfulness: Answer ↔ Context
  2. Relevance: Answer ↔ Query

"Faithfulness" measures: Is the Answer purely derived from the Context? If the Context says "Revenue is 10M"andtheAnswersays"Revenueis10M" and the Answer says "Revenue is 12M", faithfulness is 0. Even if "Revenue is $12M" is true in the real world... if it's not in the context, it is a Faithfulness failure (External Hallucination).

Detection: Ask an evaluator LLM: "List all claims in the Answer. Verify if each claim is supported by the Context."

"Relevance" measures: Does the Answer actually address the Query? Query: "What is the capital of France?" Answer: "France is a beautiful country in Europe." Faithfulness: High (Assuming context supports it). Relevance: Low (Didn't answer the question).

Detection: Ask an evaluator LLM: "Does the Answer resolve the intent of the Query?"

A third metric. Query ↔ Context. Did we retrieve 5 documents about "Pizza" when the user asked about "Burgers"? Low Context Relevance confuses the LLM and lowers Faithfulness.

A good RAG answer is both Faithful (Grounded) and Relevant (Useful). You need high scores on both. One is not enough.

Key Intuition: "Tell the truth (Faithfulness), and tell me what I asked for (Relevance)."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonRAG Evaluation BasicsNext lesson →Prompt Injection Defense