Trending: Crack FAANG with our new JavaScript Interview Mastery!Try Now
Back to Curriculum
AI Prompt EngineeringModuleLesson 01

Understanding Hallucinations

15m
Beginner
+50 XP
0% Done

The Confident Liar

A Hallucination is when an AI model states something that is completely false, but it says it with absolute, 100% confidence.

Because an LLM is essentially a massive autocomplete engine, its only goal is to predict the next word that sounds statistically plausible. It does not "know" if what it is saying is true. If you ask it for the biography of a person who doesn't exist, it might just make up a highly believable biography instead of admitting it doesn't know.

How to Prevent Hallucinations

You can drastically reduce hallucinations by adding explicit constraints to your prompts:

"Base your answer ONLY on the text provided below."

"If you do not know the answer, or if the answer is not in the text, you must say 'I DO NOT KNOW'. Do not guess."

"Provide a citation for every claim you make."