When Models Make Things Up
AI models are powerful, but they’re not perfect. Understanding their limitations helps you train better models and work with them more effectively.What Are Hallucinations?
Hallucination is when an AI model confidently generates information that seems plausible but is actually incorrect. It’s like when someone tries to bluff their way through a conversation about a topic they don’t really know.Why Models Hallucinate
Remember how models predict the next most likely token? Sometimes those predictions create fiction that sounds like fact. Think of models like extremely sophisticated autocomplete:- Phone autocomplete: “The weather is…” → “sunny”
- AI model: “The function to reverse a list is…” → makes up something plausible
Common Hallucination Types
In Code Generation
In Documentation
In Configuration
In Facts and Numbers
- “BERT has exactly 340 million parameters” (it’s actually 110M or 340M depending on version)
- “PyTorch was released in 2014” (actually 2016)
- “The optimal learning rate is always 2e-5” (depends on many factors)
Knowledge Cutoff Issues
Models are trained on data up to a specific date. After that date, they know nothing.Example Knowledge Cutoffs:
- GPT-5: Latest from OpenAI
- Claude Sonnet 4.5: Latest from Anthropic
- Gemini 2.5 Pro: Latest from Google
What This Means
If you ask about:- Libraries released after the cutoff → Wrong or no information
- Recent best practices → Outdated advice
- Current versions → Old version numbers
- New features → Complete fabrication
Other Model Limitations
Mathematical Weakness
Models struggle with precise calculations:Logical Reasoning
Models can fail at simple logic:- “All birds can fly. Penguins are birds. Can penguins fly?” → May say yes
- Counting problems: “How many ‘r’s in ‘strawberry’?” → Often wrong
- Spatial reasoning: “If A is north of B, and B is north of C…” → Gets confused
Consistency Issues
Models may contradict themselves:- Give different answers to the same question
- Change their “opinion” based on how you phrase things
- Agree with you even when you’re wrong
Context Limitations
Models have finite context windows:| Model | Context Window |
|---|---|
| GPT-5 | 400,000 tokens |
| Claude Sonnet 4.5 | 200,000 tokens |
| Gemini 2.5 Pro | 1,000,000 tokens |
- Forget earlier information
- Mix up details
- Generate based on partial understanding
How to Spot Hallucinations
1
Too Perfect
If the answer seems too convenient or exactly what you wanted, verify it.
2
Specific Without Source
Very specific claims without references are often made up.
3
Mixing Concepts
Combining features from different libraries or versions.
4
Confident but Vague
Using lots of words without saying anything concrete.
Verification Strategies
For Code
-
IDE/Compiler Feedback
- Red underlines indicate problems
- Import errors show fake modules
- Type errors reveal incorrect APIs
-
Documentation Check
- Always verify in official docs
- Check version compatibility
- Look up method signatures
-
Run and Test
- Execute the code
- Write unit tests
- Use debugging tools
For Information
-
Cross-Reference
- Check multiple sources
- Verify dates and numbers
- Confirm with official documentation
-
Ask for Sources
- Request specific documentation links
- Ask which version supports a feature
- Get example code from real projects
-
Test Claims
- Verify mathematical calculations
- Check logical conclusions
- Run benchmarks yourself
Working Around Limitations
Prompt Engineering
Make your prompts more specific:Provide Context
Give the model accurate information:Iterative Refinement
Work with the model iteratively:- Get initial suggestion
- Test and identify issues
- Feed errors back to model
- Refine until correct
Use Model Strengths
Models are good at:- Pattern recognition
- Code structure
- Explaining concepts
- Generating boilerplate
- Suggesting approaches
- Latest information
- Precise calculations
- Guaranteeing correctness
- Domain-specific details
- Real-time data
Hallucinations in Training
When training your own models, hallucinations can occur from:Training Data Issues
- Incorrect labels: Model learns wrong patterns
- Outdated information: Old documentation in training set
- Contradictions: Conflicting examples confuse the model
- Sparse data: Model guesses for rare cases
Overfitting
Model memorizes training data instead of learning patterns:- Generates training examples verbatim
- Can’t generalize to new inputs
- Mixes memorized fragments incorrectly
Underfitting
Model hasn’t learned enough:- Makes random guesses
- Generates generic responses
- Misses important patterns
Reducing Hallucinations in Your Models
Data Quality
Clean Your Data
- Remove contradictions
- Fix incorrect labels
- Update outdated info
- Balance categories
Augment Carefully
- Use verified sources
- Synthetic data quality
- Maintain consistency
- Preserve real patterns
Training Strategies
-
Validation Sets
- Hold out test data
- Check for hallucinations
- Measure accuracy carefully
-
Regularization
- Prevent overfitting
- Use dropout
- Early stopping
- Weight decay
-
Temperature Control
- Lower temperature = more conservative
- Higher temperature = more creative (more hallucinations)
- Find the right balance
Post-Training
- Human evaluation: Have experts check outputs
- Automated testing: Build test suites
- Confidence scores: Add uncertainty estimates
- Fallback options: “I don’t know” responses
The Verification Mindset
Key Principle: Every model output is a starting point, not a final answer.
- Question confident assertions
- Test generated code
- Verify claimed facts
- Cross-reference sources
- Understand before using
Living with Limitations
Models are tools, not oracles. They’re incredibly useful despite their flaws:- Speed: Generate solutions in seconds
- Breadth: Know about many topics
- Creativity: Suggest approaches you hadn’t considered
- Tirelessness: Available 24/7
Learn More from Our Research
Hallucinations & Entropy Research
Our main research article on controlling hallucinations through entropy analysis
Test-Time Hallucination Control
Practical techniques for reducing hallucinations at inference time