Zero-Code AI App BuilderZero-Code AI App Builder
AI Foundations

Hallucinations

When AI sounds sure but is wrong

Sometimes an AI gives you an answer that sounds perfect but is completely wrong. This is called a hallucination. Every AI builder needs to know how to spot and reduce them.

What is a hallucination?

Picture a student who didn't study but must answer an exam question. Instead of leaving it blank, they write a confident, well-worded answer that's made up. It looks good. It's still wrong.

An AI hallucination is the same thing:

  • The AI states something false as if it were true.
  • It sounds just as confident as when it's right.
  • It can invent facts, quotes, links, book titles, or code features that don't exist.

Here is an example of a prompt that can trigger one:

Prompt
List 5 research papers about study habits of university
students, with authors, year, and a link to each.

The AI may return five real-looking papers. Some may not exist, or the links may lead nowhere. Always check.

Why it happens

Remember how LLMs write: they predict the most likely next word. They are built to produce text that sounds right, not to check facts.

  • If the AI doesn't know something, it may still produce a likely-sounding answer.
  • If its training data was wrong or old, its answer may be too.
  • If your prompt is vague, it fills the gaps with guesses.
A confident tone is not a sign of a correct answer. The AI sounds the same whether it's right or wrong.

How to reduce hallucinations

Give it sources

Paste the facts you want it to use, and tell it to stick to them.

Prompt
Using ONLY the product list below, recommend a gift under $40
for someone who loves plants. If nothing fits, say so.

[paste product list here]

Let it say "I don't know"

AI tries hard to be helpful. Give it permission to admit when it isn't sure.

Prompt
If you are not sure about something, say "I don't know"
instead of guessing. Mark any part you are unsure about.

Verify important facts

Check names, numbers, dates, quotes, and links in a reliable source. This matters most for anything you publish or share.

Test the code

AI-written code can call features that don't exist or skip a step. Don't just trust it. Run it, click every button, and try it with real inputs.

Ask
clear prompt + sources
→
Read
look for odd claims
→
Verify
check facts, test code
→
Fix
tell the AI what's wrong
A simple habit: ask, check, and fix before you trust an answer.

Common mistakes

Trusting links and citations

Prompt
# Wrong
Give me 5 sources that prove this.

# Right
Here are 3 articles I found [paste them]. Summarize what
each one says about this topic. Quote the exact sentence.
  • Skipping testing because "the AI wrote it, so it must work".
  • Asking about very recent events without web search turned on.
  • Arguing in circles. If the AI keeps repeating a wrong answer, give it the correct info or start a fresh chat.

Practice

Try these exercises to lock in what you just learned.

Quiz
Not started
The AI gives you a list of books with authors and links. Two of the books don't exist. What is this called?
Quiz
Not started
Which prompt is LEAST likely to cause a hallucination?
Quiz
Not started
The AI wrote the code for your app and says it works. What should you do?

What's next?

Different models make different trade-offs between speed, cost, and accuracy. Next, let's learn how to pick the right model for the job.