← Back to curriculum

Module 7 — GenAI & LLMs

Hallucinations, trust & AI safety

Why models invent facts, grounding strategies, refusal patterns, safety guardrails, and human-in-the-loop review.

~65 min read + exercises

Hallucinations and building trust

Before we begin

A hallucination is when an LLM states something confident but false — fake citations, wrong numbers, invented features.

Why do LLMs hallucinate? They optimize for plausible continuation, not verified truth.


What you will learn

  • Name common hallucination triggers.
  • Apply grounding and evaluation patterns.
  • Design UX that helps users verify answers.

Before this lesson


Why it happens

  1. Training — models absorb myths, outdated facts, fiction.
  2. Pressure to answer — prompts that forbid “I don’t know.”
  3. No retrieval — question about your private doc but model guesses.
  4. High temperature — more random completions.
  5. Long reasoning chains — errors compound.

Mitigations

TechniqueEffect
RAG + cite sourcesGround in text user can check
Low temperature for factsLess random drift
Explicit refusal“Answer only from context”
Tool useCalculator, SQL, search APIs (Module 8)
Human reviewHigh-stakes decisions

Evaluation

Build a golden set of 20–50 questions with known answers from your docs.

Track:

  • Faithfulness — answer supported by retrieved chunk?
  • Citation accuracy — link matches claim?
  • Refusal rate — correct “I don’t know” when info missing?

Re-run when you change prompts, chunk size, or model.


UX trust patterns

  • Show source snippets beside answers.
  • Highlight when confidence is low.
  • Log retrieved chunks for debugging.
  • Never present legal/medical output as professional advice without review.

Checkpoint

Why do LLMs hallucinate?

Answer sketch

They predict likely text, not facts; without grounding they fill gaps with plausible-sounding fiction.


What's next

Module 7 quiz