Blog

How to prevent AI chatbot hallucination: a strict-KB grounding guide

SemAgent Team · 2026-07-08 · 6 min read

Short answer: a chatbot "hallucinates" when it makes up an answer that isn't in your knowledge base — usually while trying to be helpful. The reliable way to stop it is to tie every answer to a real source instead of letting the model invent one. That's what strict-KB grounding does.

Why does hallucination happen?

Language models are built to predict text — they put together the answer that sounds most likely, not the one that's actually true. When a customer asks "Do you ship to Germany?", the model has already seen answers from thousands of other online stores, and the fact that yours isn't one of them won't stop it from replying. What you get back is confident, fluent — and wrong.

Why isn't RAG enough on its own?

RAG (retrieval-augmented generation) hands the model relevant documents before it answers. That helps a lot — but when the retrieved document is weak, or the question falls outside what you've covered, the model still tries to fill the gap on its own. The rule that matters is simple: no source, no answer.

Strict-KB grounding: three rules

  1. Answer only from the knowledge base: don't let the model fall back to its general knowledge.
  2. Show the source: under every answer, state which page/document it came from — so both the customer and you can audit it.
  3. "I don't know" below the threshold: if the match is weak, say so honestly and route to a human. A bot that can say "I don't know" always earns more trust than one that answers wrong.

What does it look like in practice?

In the SemAgent widget, this is how it works out of the box: answers come from your knowledge base using hybrid search (keywords + meaning), every message shows where it came from, and when a question falls outside your content the widget hands off to a human instead of guessing. The questions it couldn't answer collect in your dashboard — a ready-made list of what to add next. More detail: RAG Widget · knowledge base guide.

Checklist

If you'd rather try than read

Start a 7-day free trial — card required, test it with your own content in 5 minutes.

Try free
Cancel anytime