Hallucination
When the model confidently makes something up: a fake function, a wrong date, a library that doesn't exist.
Last updated
Analogy
A function that returns made-up data with a cheerful status 200. No error, no warning, just wrong.
In an agent
This is why agents need tools and RAG: real data to read, instead of guesses dressed up as facts.
Practice
Flashcards
- What is a hallucination?Confident but made-up output.
- Interview: how do you reduce hallucinations?Ground with RAG and tools, allow "I don't know", ask for citations, use low temperature, and test with evals.
Interview questions
- How do you handle hallucinations?
- Ground answers with RAG and tools.
- Instruct the model to say "I don't know" when the context lacks the answer, and ask for citations.
- Use a low temperature and test with evals.
Questions people ask
Why do LLMs hallucinate?
The model predicts text that sounds right, not text it has checked. When it does not know something, like your private data or a recent change, it still produces a confident answer. Nothing in the model flags the gap. That is why it can invent a function, a date or a library that does not exist.
How do I reduce hallucinations in an agent?
Give the model real data to read. Use tools for live facts and RAG for your documents, tell it to answer only from that context and to say I don't know otherwise, keep temperature low, and ask for sources. Then measure the result with evals, so you know whether a change helped.