0%
Foundations of LLMs11 min

Hallucinations and Reliability

Hallucinations — confident, fluent, wrong outputs — are the defining reliability challenge of LLMs. Understanding why they happen enables you to build systems that mitigate them.

Why LLMs hallucinate

LLMs generate the statistically likely continuation of a prompt. They have no "fact checking" mechanism — they do not look things up or verify claims against a ground truth. When the correct answer is uncertain or the model lacks relevant training data, it still generates a fluent, confident-seeming response — because that is what the training objective rewards.

Types of hallucination

  • Factual hallucinations — wrong dates, statistics, quotes, and citations
  • Confabulation — plausible-sounding but invented details (non-existent studies, cases, people)
  • Sycophantic hallucination — agreeing with incorrect statements in the prompt to be accommodating
  • Instruction hallucination — claiming to have done something it did not (especially in tool use)

Mitigation strategies

Grounding with retrieved context. Providing relevant documents in the prompt reduces hallucination dramatically — the model can quote sources rather than recall from training.

Uncertainty calibration. Instructing the model to express uncertainty ("if you are not confident, say so") helps surface low-confidence responses for human review.

Output validation. For structured outputs, validate against expected schemas or fact-check critical claims programmatically.

Asking the model to cite sources. If sources are provided in context, requiring citations forces the model to ground claims in the provided material.

Hallucinations cannot be eliminated — they are a fundamental property of generative models. System design should assume they will occur and build appropriate verification and fallback mechanisms.

Check your understanding

3 questions, 70% to pass
1. Why do LLMs hallucinate?
2. What is sycophantic hallucination?
3. Which strategy dramatically reduces hallucination?