Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on. You've got this! 🚀
Why LLMs Sometimes Make Mistakes
LLMs sometimes produce confident-sounding but incorrect information. This is called a hallucination. Understanding why it happens helps you use LLMs more safely and effectively.
What is an AI Hallucination?
An AI hallucination is when an LLM generates information that is factually incorrect but stated confidently as if it were true.
Examples of hallucinations:
- Citing a scientific paper that does not exist
- Stating that a famous person did something they never did
- Inventing a law or regulation that does not exist
- Giving wrong calculation results
- Describing a feature of a product that does not exist
The term 'hallucination' is used because the AI is generating content that has no basis in reality, similar to a person seeing something that is not there.
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Why Hallucinations Happen
- LLMs generate the most statistically likely text, not necessarily the most accurate text
- If the training data contains errors, the model may reproduce them
- For topics not well covered in training data, the model interpolates from related patterns
- The model has no way to know when it is uncertain - it generates text at the same confidence level whether it knows or not
- Precise details like specific dates, numbers, and names are particularly prone to hallucination
- The model cannot access the internet to verify facts during inference (unless specifically connected to a search tool)
How to Work with LLMs Safely
- Always verify specific facts, dates, numbers, and statistics from authoritative sources
- Be especially careful with medical, legal, and financial information
- Ask the AI to cite its sources - then verify those sources actually exist and say what the AI claims
- Use AI for drafting and exploration, but apply human judgment before using important outputs
- If something seems surprising or too convenient, it is worth double-checking
Key Takeaways
- LLMs sometimes produce confident-sounding but incorrect information.
- LLMs generate the most statistically likely text, not necessarily the most accurate text
- If the training data contains errors, the model may reproduce them
- For topics not well covered in training data, the model interpolates from related patterns