Hallucination
Hallucination is when an LLM generates plausible-sounding but factually incorrect information — citing papers that don't exist, inventing API methods, fabricating quotes. It's not a bug; it's a fundamental property of next-token prediction trained on noisy text.
Hallucination correlates inversely with model size and training data quality. Smaller models hallucinate more. Reasoning-tuned models (DeepSeek R1, QwQ, Phi-4 Reasoning) hallucinate slightly less because they fact-check intermediate steps in their visible chain-of-thought.
Mitigations: RAG (ground in real documents), tool use (let the model call calculators/APIs/databases), prompt engineering (ask for citations, acknowledge uncertainty), and avoiding tasks where the model will obviously make things up (asking a 3B model for niche historical facts).
Practical example
An operator deploys a 3B model locally to answer questions about internal API documentation and immediately gets confident, fluent answers referencing methods that don't exist in the actual codebase. Swapping to a 7B model reduces but doesn't eliminate the problem — the real fix is wiring the model into a RAG pipeline that retrieves the actual doc pages and forces the model to answer from provided context rather than its training-data memory. A useful diagnostic: ask the same question with and without retrieved context injected. If the ungrounded answer sounds equally confident but contradicts the grounded one, that's the model pattern-matching on plausible-sounding API conventions rather than recalling anything real — a strong signal to keep retrieval in the loop for any factual, low-tolerance-for-error task.
Related terms
Reviewed by Eruo Fredoline. See our editorial policy.