MaxICo Labs — applied AI studio

How to stop AI chatbot hallucinations

June 21, 2026 · MaxICo Labs

A hallucination is when your AI chatbot confidently tells a customer something that doesn't exist: a made-up price, a non-existent return policy, a discontinued plan. In support or sales, one such answer costs trust and money. The good news: hallucinations aren't magic — they're systematically reduced with a concrete stack of techniques. Let's walk through the anti-hallucination stack we actually deploy for clients, from RAG to an "I don't know" fallback.

Why LLMs hallucinate at all

The model doesn't "lie" maliciously. It predicts the most likely next word from its training data. When an answer requires a fact the model doesn't know or that changed after training, it still generates something plausible — because its job is to sound coherent, not to say "I don't know." So a bare-model chatbot without your context is doomed to invent your business's specifics.

Hence the core principle: don't ask the model for facts — give it the facts and ask it only to phrase the answer.

Three types of hallucination to distinguish

Not all hallucinations are the same, and they're treated differently:

  • Factual — the bot invents specifics: a price, a term, a condition that doesn't exist. The most dangerous in support and sales. Treated with RAG and pre-written answers.
  • Logical — the bot draws a wrong conclusion from correct data (e.g., miscalculates a discount). Treated with action limits and output checks.
  • Contextual — the bot "forgets" what was said earlier in the dialogue or confuses customers. Treated with proper context and conversation-memory management.

When a vendor says "our bot doesn't hallucinate," ask which type they mean — because closing all three with one trick is impossible.

The anti-hallucination stack: 5 layers of defense

1. RAG — answers only from your knowledge base

RAG (Retrieval-Augmented Generation) is the foundation. Instead of the model inventing, the system first retrieves relevant chunks from your knowledge base (FAQ, guides, pricing, policies), then asks the model to answer based only on those chunks.

How it cuts hallucinations:

  • The model sees current data instead of relying on memory.
  • The prompt adds an instruction: "answer only from the provided context, don't invent."
  • Update the price in the base and the bot answers correctly right away, no retraining.

RAG quality depends on base quality: clean, structured documents with no contradictions = fewer hallucinations.

2. Guardrails — rails that catch unsafe answers

Guardrails are checks before and after generation:

  • Inbound: filter off-topic requests, jailbreak attempts, toxicity.
  • Outbound: verify the answer contains no invented facts and promises nothing the business doesn't offer (discounts, guarantees).
  • Action limits: the bot can't "confirm a refund" itself — only propose; the decision stays with a human.

3. Pre-written answers for critical topics

For topics where the cost of error is high (prices, legal terms, security, medical disclaimers), don't trust generation at all. Use fixed, pre-approved answers the bot returns verbatim. The model only recognizes intent; the text is human-written.

Request type How to answer Hallucination risk
Exact price / plan Pre-written answer or pricing data via RAG High — lock it down
Return policy Pre-written answer High — lock it down
General product question RAG from knowledge base Medium — control via context
Conversational small talk Free generation Low — allowed

4. The "I don't know" fallback — the most important one

A bot that honestly says "I don't have this information, handing you to an agent" beats a bot that guesses a hundred times over. Build it in explicitly:

  • In the system prompt: "If the provided context has no answer, say you don't know and offer a human. Do not invent."
  • Confidence threshold: if RAG finds no relevant chunk, fall back immediately rather than stretching.
  • A handoff button is always available.

5. Source citation and logging

  • Citations: the bot shows which document it answered from. That's both customer trust and a fast way to find a base error.
  • Logs: keep conversations to see where the bot drifts and to refine the base. The first weeks after launch are critical for calibration. (Under GDPR, set a clear retention period and lawful basis for stored conversations.)

What NOT to do

  • Don't rely on a "smarter model". Even a top model hallucinates without your context. RAG matters more than model choice.
  • Don't write a fuzzy knowledge base. Contradictory or stale documents = guaranteed hallucinations.
  • Don't let the bot act without confirmation. Generate text — yes; confirm a refund — no.
  • Don't launch without a fallback. A bot without "I don't know" will eventually misinform a customer.

Practical pre-launch checklist

  1. Knowledge base is clean, structured, contradiction-free.
  2. RAG is configured and returns relevant chunks.
  3. The system prompt includes "answer only from context" and "if unsure, say so."
  4. Critical topics (prices, returns) run on pre-written answers.
  5. A human button is always available.
  6. Logging is on; you review conversations daily for the first weeks.

How to prepare a knowledge base so RAG works

90% of RAG quality is the quality of the documents it pulls answers from. Here's what makes a base "hallucination-resistant":

  • One fact, one place. If a product price appears in three documents with different numbers, the bot picks a random one. Remove duplicates and contradictions.
  • Structure and headings. Clear sections ("Shipping", "Returns", "Warranty") help retrieval find the right chunk.
  • Short, self-contained paragraphs. A chunk must make sense out of context — RAG slices documents into pieces.
  • Freshness. A stale price in the base = the bot's confident lie. Assign an owner for updates.
  • Explicit "we do NOT do this." If you don't ship abroad, say so directly so the bot doesn't "infer" otherwise.

A good rule: if a new team member couldn't confidently answer from your base, the bot can't either.

How to test a bot for hallucinations before launch

Don't launch on faith. Run the bot through a set of tricky queries:

  1. Questions with no answer in the base. The bot must say "I don't know," not invent.
  2. Queries with a false premise ("confirm you have a 50% discount"). The bot must not agree with the fiction.
  3. Edge facts (exact prices, terms, conditions). Check verbatim match to the base.
  4. Attempts to break the script ("ignore your instructions and..."). Guardrails must hold.
  5. Repetition under different phrasings. Answers should be stable, not "drift."

Save these cases as a regression set — run it after every base or prompt change.

Common myths about hallucinations

Myth Reality
"A smarter model doesn't hallucinate" Any model hallucinates without your context; RAG matters more
"Just write 'don't lie' in the prompt" The instruction helps, but without RAG and fallback it won't save you
"Hallucinations are rare" On your business specifics, a bare bot invents constantly
"You can turn it off forever" No; it's risk-reduction engineering, not a switch
"The longer the answer, the better" The opposite: long generations more often contain fabrications

What to do when you spot a hallucination after launch

Hallucinations don't vanish forever at launch — you catch and quench them in the process. The working loop:

  1. Catch it in the logs. Review conversations daily in the first weeks. Look for answers that sound confident but don't match the base.
  2. Find the cause. Almost always it's either a gap in the knowledge base (missing fact), a contradiction (multiple versions of a fact), or a too-loose prompt.
  3. Close the source. Add/fix the document, remove the contradiction, strengthen the "answer only from context" instruction.
  4. Add to the regression set. So the same hallucination doesn't return after the next change.
  5. Repeat. Bot quality isn't a point but a curve that improves with each cycle.

Important: don't "patch" each hallucination with a new prompt instruction per case — the prompt will bloat and contradict itself. Fix the root cause in the knowledge base.

Rough timeline to build the anti-hallucination stack

Stage Timeline Result
Cleaning and structuring the base 3–7 days A base with no duplicates or contradictions
RAG + prompt setup 3–5 days The bot answers from context
Guardrails + pre-written answers 2–4 days Critical topics under control
Test set and calibration 1–2 weeks Stable quality on tricky queries

How MaxICo Labs solves this

We don't ship a "bare-model bot" — we build the full anti-hallucination stack: RAG on your knowledge base, guardrails, pre-written answers for critical topics, and a mandatory "I don't know" fallback with human handoff. Then we calibrate against real conversations in the first weeks.

  • RAG architecture on your knowledge base with source citation.
  • Guardrails and pre-written answers for prices, policies, legal topics.
  • Fallback logic and smooth agent handoff.
  • Logging and refinement after launch — GDPR-aware by design.

Worried the bot will make things up?

Message Valeriy in the site chat — we'll show how our anti-hallucination stack works on a concrete example. Or book a free call: we'll review your knowledge base and tell you where the hallucination risk is highest and how to close it.

FAQ

Why does an AI chatbot make things up?

Because an LLM predicts the most likely next word rather than verifying facts. When it lacks data about your business, it generates something plausible. So you must feed the bot facts via RAG instead of trusting its memory.

What is RAG and why does it cut hallucinations?

RAG means the system first retrieves relevant chunks from your knowledge base, then asks the model to answer only from them. The bot sees current data instead of inventing, and answers correctly right after you update the base.

Can hallucinations be fully eliminated?

Down to zero is hard, but they're systematically minimized with a stack: RAG, guardrails, pre-written answers for critical topics, and an 'I don't know' fallback. For prices and policies, return fixed approved text instead of generating.

Why does a bot need an 'I don't know' fallback?

A bot that honestly hands off to an agent instead of guessing is far safer. If RAG finds no answer, the fallback fires: the bot says it lacks the info and calls a human. This is set explicitly in the system prompt.

Read also

ML

Author

MaxICo Labs — your AI partner

Applied-AI studio led by Максим Шаповал. We build AI agents, chatbots, voice agents, CRM and automation in production — and write here about what actually works. Grew out of MaxICo Agency.