Concept guide

Hallucinations and guardrails

Generative AI can say something wrong with total confidence. And if someone pushes it, it can say harmful things too. The first problem is called hallucination, and the safety layers that deal with the second are called guardrails. This guide walks through why hallucinations happen and how to reduce them, what guardrails block and where, and how to handle personal data and attacks.

01

Why models hallucinate

An appliance company has just launched a support chatbot. A customer asks about its new product, the K2 electric kettle, and the chatbot replies with four smooth, confident sentences. In the scene below, check each sentence against the product manual.

Capacity is 1.7 L
Not checked yet
It switches off when it boils
Not checked yet
The warranty is 2 years
Not checked yet
The body is dishwasher-safe
Not checked yet

Question: "Tell me about the K2 electric kettle"

The model's answer looks smooth and confident. Turn on the check against the manual.

When a model states something false or unsupported as if it were fact, that's called a hallucination. There are two kinds. The answer can contradict facts about the world, or it can contradict — or go beyond — the source material you gave it. In the scene, "2-year warranty" contradicts the manual, and "dishwasher-safe" is something the model made up that the manual never says.

The reason lies in how LLMs produce text. An LLM doesn't look facts up before answering. It picks the most plausible words to come next. Descriptions of electric kettles often mention things like "2-year warranty" or "dishwasher-safe", so those phrases feel like a natural fit. The less the model knows — a product it never saw in training, news from after its training ended, a vague question — the more likely it is to fill the gaps with something made up.

Here's what catches people out: a hallucinated sentence sounds exactly as confident as a correct one. You can't tell them apart by tone, so you have to check the answer against a source or have a person review it.

If a question says… → pick this

  • “Generates plausible content that is not true”Hallucination
  • “Contradicts the provided documents, or adds things they don't say”Ungrounded answer (hallucination)
  • “Cites papers or sources that don't exist”Hallucination (fabricated citations)
  • “The answer sounds confident, so it must be right”Wrong — you can't tell from the tone

You can't get rid of hallucinations entirely. So how far can you reduce them?

02

Reducing hallucinations

There's no single fix. You reduce hallucinations by stacking several safeguards on top of each other. In the scene below, add them one at a time.

Wrong answers
28%

Share of wrong answers as you add safeguards to a kettle support chatbot (illustrative)

With no safeguards, the model answers from what it knows and gets about three in ten wrong (28%).

MethodHow it helps
Ground answers with RAGInstead of making up what it doesn't know, the model reads the retrieved material and answers from it
Tell it to say "I don't know"Keeps it from inventing a plausible answer when the material doesn't cover the question
Citations and grounding checksAsk for a source behind each sentence, and automatically flag sentences that don't match the sources
Ask it to think step by stepCuts down on mistakes in multi-step calculations and reasoning
Human reviewA person checks answers that would be dangerous if wrong before they go out

Two misunderstandings come up a lot. First, lowering the temperature makes answers more consistent, not more true. Second, fine-tuning a model to teach it facts isn't a good fix. The model won't always recall those facts accurately, and whenever the information changes you have to train it again. Use RAG to supply facts, and save fine-tuning for style and format.

If a question says… → pick this

  • “Reduce hallucinations by grounding answers in up-to-date company data”RAG (grounding)
  • “Don't make things up when the material has no answer”Instruct it to say "I don't know"
  • “Automatically check that each sentence is backed by the source”Grounding check
  • “Setting temperature to 0 eliminates hallucinations”Wrong
  • “Answers in a field where mistakes are dangerous”Human review (human-in-the-loop)

Hallucination is the model making mistakes on its own. But there's another problem: users who deliberately try to pull harmful answers out of it, and a model saying things it never should.

Pro only

That’s the free part of this guide

The other 5 chapters are open to Pro subscribers. Each one continues with 3D visuals and “if a question says…” tips, and the last chapter lets you check yourself with a short quiz.

  1. 03Guardrails
  2. 04Content filters
  3. 05Protecting personal data
  4. 06Red teaming and monitoring
  5. 07Choosing a safeguard

Advertisement

PasslyExam

You have read the concept. Now test it on exam questions

PasslyExam offers original practice questions, explanations and full mock exams built around each certification’s exam guide. The explanations cover why the right option is right and why the look-alike options are wrong. Sign up to practice for free every day.