Documentation Index
Fetch the complete documentation index at: https://docs.monostate.ai/llms.txt
Use this file to discover all available pages before exploring further.
Entropy, Uncertainty, and Why Models Hallucinate
When training AI models, understanding entropy and uncertainty helps you build more reliable systems. These concepts explain why models sometimes confidently state complete nonsense.For a deeper technical dive into this topic, read our research post: Hallucinations in LLMs: The Entropy Problem and Current Solutions
What is Entropy?
Entropy measures disorder or unpredictability in a system. In AI models, it tells us how “spread out” the probability distribution is over possible next words or tokens.Simple Example
Imagine the model is completing: “The capital of France is…” Low Entropy (Certain):- Paris: 95% probability
- Lyon: 2% probability
- Marseille: 1% probability
- Other: 2% probability
- Paris: 25% probability
- London: 20% probability
- Berlin: 20% probability
- Rome: 20% probability
- Other: 15% probability
Entropy vs Uncertainty
These terms are related but not identical:| Concept | What It Measures | Example |
|---|---|---|
| Entropy | Mathematical disorder in probability distribution | How spread out token probabilities are |
| Uncertainty | Any lack of knowledge or predictability | Model doesn’t know it doesn’t know |
| Epistemic Uncertainty | What the model doesn’t know | Facts outside training data |
| Aleatoric Uncertainty | Inherent randomness | Multiple valid answers exist |
The Entropy Paradox
You might think high entropy equals more hallucinations. Not always true.Why This Happens
High Entropy, Correct
Scenario: Multiple valid options“The weather might be…”
- sunny (30%)
- cloudy (25%)
- rainy (25%)
- snowy (20%)
Low Entropy, Wrong
Scenario: Confident hallucination“The Treaty of Versailles was signed in…”
- 1923 (98%)
- 1919 (1%)
- Other (1%)
Types of Uncertainty in Models
1. Token-Level Uncertainty
The model is unsure about the exact next word:2. Semantic Uncertainty
The model is unsure about meaning, not just words:3. Factual Uncertainty
The model doesn’t know if information is true:Measuring Uncertainty
Traditional Entropy
Shannon entropy formula:- Treats all tokens as independent
- Can’t distinguish between word choice and meaning
- Doesn’t capture epistemic uncertainty
Semantic Entropy
A better approach that measures uncertainty over meanings:- Generate multiple outputs
- Group by semantic equivalence
- Calculate entropy over meaning clusters
Confidence Calibration
Measuring if confidence matches correctness:| Model Says | Confidence | Actually Correct | Calibration |
|---|---|---|---|
| ”Paris is capital of France” | 99% | Yes | Good |
| ”Treaty signed in 1923” | 98% | No | Bad |
| ”Might be Python or Java” | 50% | Uncertain | Good |
| ”Definitely JavaScript” | 95% | No | Bad |
Entropy in Training
During Training
Entropy changes as models learn:Loss Functions and Entropy
Cross-entropy loss directly relates to entropy:Controlling Entropy
Temperature Scaling
Temperature controls randomness in generation:- T < 0.5: Conservative, repetitive
- T = 1.0: Default balance
- T > 1.5: Creative, risky
Top-k and Top-p Sampling
Limit which tokens to consider:Entropy Regularization
Add entropy constraints during training:Advanced Techniques
Entropy-Aware Training
Our approach at Monostate modifies attention mechanisms:Layer-wise Entropy Budgets
Different layers get different entropy allowances:| Layer Type | Entropy Budget | Purpose |
|---|---|---|
| Early | High | Explore possibilities |
| Middle | Medium | Reason about options |
| Final | Low | Commit to answer |
Semantic Entropy Probes
Extract semantic uncertainty from internal states:- 5-10x faster than generating multiple outputs
- Can detect hallucinations before they happen
- Works with any transformer model
Practical Implications
For Training
DO
- Monitor entropy during training
- Use temperature scaling
- Implement entropy regularization
- Track confidence calibration
DON'T
- Assume low entropy = correct
- Ignore semantic uncertainty
- Over-regularize entropy
- Trust confidence scores blindly
For Inference
High-Stakes Applications:- Use lower temperature (0.3-0.7)
- Implement semantic entropy checks
- Require multiple consistent outputs
- Add confidence thresholds
- Use higher temperature (1.0-1.5)
- Allow more entropy
- Embrace variation
- Filter bad outputs later
Connection to Hallucinations
Entropy relates to hallucinations in complex ways:- Not Just High Entropy: Hallucinations occur at all entropy levels
- Confidence ≠ Correctness: Low entropy can mean confident nonsense
- Semantic vs Syntactic: Word uncertainty doesn’t equal meaning uncertainty
- Knowledge Gaps: No entropy signal for “I don’t know this”
Current Research
Semantic Entropy (Oxford/MIT)
Measures uncertainty over meanings rather than tokens. Shows 2-3x better hallucination detection than traditional methods.Conformal Prediction
Provides statistical guarantees:- “With 95% confidence, the answer is in this set”
- If set is too large or empty, admits uncertainty
- Mathematically rigorous approach
Multi-Agent Consensus
Our fuzzy logic approach:- Multiple agents evaluate options
- Consensus through fuzzy scoring
- Disagreement triggers re-evaluation
- Natural uncertainty handling
Best Practices
During Training
-
Track Multiple Metrics:
- Token entropy
- Semantic entropy
- Confidence calibration
- Factual accuracy
-
Use Appropriate Regularization:
- Dropout for uncertainty
- Label smoothing
- Entropy penalties
- Early stopping
-
Validate Uncertainty:
- Test on out-of-distribution data
- Check confidence on known errors
- Measure calibration curves
During Inference
-
Set Appropriate Temperature:
- Match to task requirements
- Lower for facts
- Higher for creativity
-
Implement Safeguards:
- Semantic entropy checks
- Multiple generation consensus
- Confidence thresholds
- Human-in-the-loop for critical decisions
-
Design for Uncertainty:
- Allow “I don’t know” responses
- Show confidence levels
- Provide alternatives
- Flag potential hallucinations
The Bottom Line
Entropy and uncertainty are fundamental to how models work, but they’re not simple predictors of reliability. Understanding these concepts helps you:- Build more reliable models
- Detect potential hallucinations
- Set appropriate generation parameters
- Design better training procedures
Watch: The RL Overfitting Problem
Models trained with reinforcement learning can become overconfident and lose the ability to say “I don’t know.” This video explains why RL-trained models sometimes become worse at handling uncertainty.Further Reading
Hallucinations & Limitations
Practical guide to model limitations
Our Research
Deep dive into entropy and hallucinations