Hallucination
Hallucination is the LLM failure mode in which the model generates content that is plausible-sounding but factually wrong — invented citations, fabricated quotes, non-existent functions, misremembered statistics. Hallucination is most common on factual questions where the model lacks training data or grounding context.
Hallucination is not a bug — it's an emergent consequence of the LLM's training objective (predict the next token plausibly) combined with the model's lack of knowledge boundaries. The mitigations are well-understood: RAG provides factual grounding, structured outputs constrain what the model can claim, citation requirements force the model to ground claims in source documents, and lower temperature reduces creative invention. None of these eliminate hallucination entirely; production systems combine multiple mitigations and add validation layers (does the cited URL exist? does the quoted text appear in the source?) before exposing the output to users.
Related terms
- Grounding (LLM)
Grounding provides an LLM with authoritative context — retrieved documents, structured data, real-time API responses — and instructs it to base its response on that context rather than its pre-trained knowledge.
- Retrieval-augmented generation (RAG)
Retrieval-augmented generation is the pattern where an LLM is given relevant context retrieved from an external source — typically via semantic search over a vector database — before generating its response.
- Structured output
Structured output is the LLM feature that guarantees the response matches a provided schema (JSON Schema, Zod, Pydantic) — eliminating the parsing failures and format drift that plagued early LLM applications.