Avoiding Hallucinations & Fact-Checking
AI models can state false things with total confidence — this is called a “hallucination”. They predict plausible-sounding text, not verified truth, so a wrong answer can arrive as smoothly as a right one. Knowing this changes how you use AI.
Learn Avoiding Hallucinations & Fact-Checking in our free Prompt Engineering course — a beginner-friendly interactive lesson with worked examples, a practice…
Part of the free Prompt Engineering course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
This lesson explains why models make things up, the prompts that reduce it, and the habit that matters most: verifying anything that counts.
What You'll Learn in This Lesson
1 Why AI makes things up
An AI model generates the most plausible next words — not checked facts. If a wrong answer looks likely, it can come out just as confidently as a true one. There’s no built-in “am I sure?” alarm.
Obscure, precise, and recent — the perfect storm for a confident made-up answer.
You invite honesty and a path to verify, instead of forcing a guess.
2 Which answers to double-check
Risk
Examples
High
Exact dates, statistics, quotes, citations, very recent events, legal/medical/financial claims.
Medium
Obscure names, niche technical details, “who said this” attributions.
Low
Common knowledge, definitions, general explanations, brainstorming.
The more specific, recent, or consequential the fact, the more it deserves a second source.
3 Ask for sources — then verify them
Asking “what’s your source?” is good practice — but models can invent realistic-looking citations and URLs. Treat sources as leads to check, not proof:
- Click through — does the source exist and actually say that?
- Cross-check — does a second, independent source agree?
- Ask for confidence — “How confident are you, and what might make this wrong?”
- Go to a pro — for medical, legal, or financial decisions, confirm with an authoritative source or a professional.
📋 Copy-paste fact-checking template
Common Mistakes (and the fix)
- Trusting a confident tone. — Sounding sure isn’t being right; verify the facts.
- Accepting citations at face value. — Click through; models can invent sources.
- Forcing an exact answer. — Let the AI say “I don’t know” instead of guessing.
- Not verifying high-stakes facts. — Medical, legal, and financial claims need an authoritative check.
Frequently Asked Questions
⏱ Test Yourself — Timed Quiz
10 quick questions, 12 seconds each. Instant feedback — beat the clock!
🎉 Lesson Complete
- ✅ A hallucination is a confident but false answer
- ✅ Models predict plausible text, not verified truth
- ✅ Add “say you don’t know rather than guessing”
- ✅ Verify dates, stats, quotes, and recent events
- ✅ Ask for sources — then check they’re real and say what’s claimed
Practice quiz
What is an AI 'hallucination'?
- A visual glitch
- A type of prompt
- When the model states something false but sounds confident
- A login error
Answer: When the model states something false but sounds confident. A hallucination is a confident-sounding answer that is actually wrong or made up.
Why do AI models sometimes make things up?
- They predict plausible-sounding text, which isn't always true
- They lie on purpose
- They are broken
- They run out of memory
Answer: They predict plausible-sounding text, which isn't always true. Models generate likely text, so a plausible-but-false answer can slip through.
Which prompt reduces made-up facts?
- 'tell me anything'
- 'be creative'
- 'make it up'
- 'If you're not sure, say you don't know rather than guessing'
Answer: 'If you're not sure, say you don't know rather than guessing'. Inviting 'I don't know' gives the model permission not to fabricate.
How should you treat names, dates, and statistics from an AI?
- Trust them fully
- Verify them against a reliable source
- Ignore them
- Assume they are jokes
Answer: Verify them against a reliable source. Specific facts are the most likely to be wrong — always verify them.
Asking the AI for sources is useful because…
- You can check the claim — but verify the sources are real, too
- It looks nice
- It makes answers longer
- It changes nothing
Answer: You can check the claim — but verify the sources are real, too. Sources help you verify, but models can invent citations, so check them.
Can an AI invent a fake citation or URL?
- Never
- Only on purpose
- Yes — made-up references are a known failure
- Only for code
Answer: Yes — made-up references are a known failure. Models can fabricate realistic-looking but nonexistent sources.
For a high-stakes fact (medical, legal, financial), you should…
- Trust the AI alone
- Double-check with an authoritative source or a professional
- Skip checking
- Ask once and move on
Answer: Double-check with an authoritative source or a professional. High-stakes facts warrant verification with an authoritative source.
Which question helps you gauge confidence?
- 'are you a robot'
- 'be louder'
- 'hurry up'
- 'How confident are you, and what might make this wrong?'
Answer: 'How confident are you, and what might make this wrong?'. Asking about confidence and failure modes surfaces shaky answers.
A model is most likely to hallucinate about…
- Common, well-known facts
- Obscure details, very recent events, or precise numbers
- Simple greetings
- Basic math like 2+2
Answer: Obscure details, very recent events, or precise numbers. Niche, recent, or highly specific facts are the riskiest.
Best mindset toward AI answers on facts?
- Blind trust
- Total dismissal
- Treat them as a confident first draft to verify
- They are always wrong
Answer: Treat them as a confident first draft to verify. Useful starting point, but verify before you rely on it.