Testing AI Features: Evals, RAG & Hallucinations · Lesson 4 of 6 · Bonus module

Measuring Hallucination

A hallucination is a confident claim with no support. You can't catch it by reading the answer alone — it sounds right. You catch it by checking every claim against what the model was actually given.

By Shahriyar · Updated

Groundedness is the metric

Break the answer into individual claims. For each, ask: is this supported by the source the model had? An answer where every claim traces back to the context is grounded; one confident sentence that doesn't is the hallucination — and it's usually the most fluent sentence in the paragraph.

LLM-as-a-judge, and its traps

A second model scores groundedness against the source. It scales where humans can't — but it has failure modes you must design around:

Grounded in published practice on groundedness scoring and LLM-as-a-judge

All lessons in Testing AI Features: Evals, RAG & Hallucinations

  1. You Can't assertEqual an LLM
  2. Golden Sets and Offline Evals
  3. Testing RAG: Retrieval vs Generation
  4. Measuring Hallucination
  5. Adversarial Testing: Jailbreaks and Injection
  6. Guardrails, CI, and the Interview Answer