Blog

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

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

Short answer: AI chatbot hallucination is the model producing information that isn't in your knowledge base "to be helpful." The proven way to prevent it is to bind the answer not to generation but to the retrieved source: strict-KB grounding.

Why does hallucination happen?

Large language models are probabilistic text generators: they build the most "plausible-looking" answer to a question. When a customer asks "Do you ship to Germany?", the model's training data holds answers from thousands of e-commerce sites — yours not being among them doesn't stop it. The result: a confident, fluent and wrong answer.

Why isn't RAG enough on its own?

RAG (retrieval-augmented generation) gives the model relevant documents before it answers. This improves accuracy significantly — but if the retrieved document is weak or the question is out of scope, the model still tends to fill the gap. The critical threshold is this: if there is no document, there must be 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 behavior is the default: answers are retrieved from your knowledge base with hybrid search (keyword + vector), the source sits under every message, and on an out-of-scope question the widget routes instead of guessing. Real questions that couldn't be answered pile up in the dashboard — they tell you what to feed your knowledge base with. Detail: RAG Widget · knowledge base guide.

Checklist

If you'd rather try than read

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

Try free
No credit card