Skip to content

    ← Back to blog

    AI & Automation · 8 min read

    Avoiding Hallucinations: How to Build Chatbots That Stick to the Facts

    A language model can promise a discount that does not exist or cite a device specification it invented, all with complete confidence. These hallucinations are the main reason many companies rightly distrust chatbots. The bad news first: with today’s technology, the risk cannot be brought to zero. The good news: with the right architecture it can be contained far enough that an assistant becomes defensible in customer contact. What it takes is no secret knowledge – but it is several layers, and cheap solutions like to skip every single one of them.

    Why models hallucinate in the first place

    A language model is trained to produce the most probable continuation of an input. It has no built-in concept of true and false, only of plausible and implausible. When the required information is missing, it produces a continuation anyway – and it sounds exactly as assured as a correct answer, because the tone comes from the same patterns.

    This also explains why you cannot “train away” hallucinations by simply telling the model to be honest. The instruction helps at the margins, but it does not change the underlying mechanism. Reliability is not created inside the model; it is created in the architecture around it.

    Layer one: answers only from your content

    The most effective lever is grounding, implemented technically as RAG. The assistant does not answer from its training knowledge; it first searches your approved content – product data, manuals, price lists, resolved tickets – and formulates the answer exclusively from the retrieved passages. The model goes from know-it-all to summarizer with evidence.

    The word “exclusively” matters. A half-hearted RAG setup, where the model gets the passages merely as inspiration and falls back on training knowledge when there are gaps, keeps hallucinating cheerfully – just less often, which makes it harder to notice. The instruction has to be strict: what is not in the retrieved passages does not get claimed.

    How much grounding buys – and where it ends – is shown by two Stanford studies of legal AI tools (2024): general-purpose chatbots got legal test queries wrong in 58 to 82 percent of cases, while RAG-based specialist research tools such as Lexis+ AI still did in a good 17 percent. An enormous difference, but not zero. Which is exactly why the further layers are needed.

    Hallucination rate on legal test queries
    Lexis+ AI (with RAG)over 17%
    Westlaw AI-Assisted Research (with RAG)over 34%
    General-purpose chatbots without grounding58–82%

    Source: Stanford RegLab/HAI, 2024

    Layer two: a source reference on every answer

    Every answer from our assistants points to the document and passage it came from. That has two effects. For the user, the answer becomes checkable – one click and you see the original. For the operator, the system becomes controllable: an answer without a solid source is a warning signal you can intercept automatically before it reaches anyone.

    Source references are also an honest litmus test when comparing vendors. If a chatbot product cannot show sources for its answers, it does not itself know what its answers are based on. That tells you everything, really.

    Layer three: “I don’t know” as a first-class answer

    Hallucinations thrive where the system wants to answer at any cost. We therefore build assistants so that an honest statement about a knowledge gap is a normal, designed outcome: if retrieval finds no sufficiently relevant passages, the assistant says exactly that – and offers handover to a human, transcript included.

    At first glance this feels like a weaker product. It is the opposite. An assistant that answers eighty percent of questions correctly with evidence and hands over the rest cleanly is worth more in daily use than one that answers a hundred percent while mixing in an unknown share of fabrications.

    Layer four: guardrails for what is off-limits

    Some mistakes an assistant should not be able to make at all. Before launch, we therefore define boundaries with each customer that apply regardless of the knowledge base: no price commitments beyond the stored price list, no legal or medical advice, no statements about competitors, no delivery promises without a data source. Such rules are not only written into the prompt but, wherever possible, checked technically before an answer leaves the system.

    What happens without such boundaries was demonstrated by Air Canada in 2024: the airline’s chatbot invented a refund rule for bereavement fares, and a Canadian tribunal ruled the commitment stood anyway – around 812 Canadian dollars for a single invented answer, plus worldwide ridicule. The boundaries themselves are yours to set, and they are not static: if a new risk topic shows up in operation, the guardrail gets moved.

    Layer five: test before launch, watch afterwards

    Whether the layers hold shows up not in the demo but in tests with real questions. Before every go-live, we and the customer run a catalog of genuine everyday questions against the system – including the nasty ones: ambiguous phrasing, questions just outside the knowledge base, trick questions about things it cannot know. Every answer is checked against the expected one. This question catalog stays in place afterwards and runs again on every change to the knowledge base or the model.

    After launch comes the second half of the work: every conversation is reviewable, conspicuous answers get examined regularly, and identified gaps flow back into content and guardrails. Containing hallucinations is not a feature you buy once; it is an operating routine.

    What honestly remains

    Even with all layers in place, residual risk remains: retrieval can rank a wrong passage as relevant, a document in the knowledge base can itself be outdated, and a model can summarize a passage incorrectly. That is why critical statements – commitments, contracts, anything with financial consequences – belong behind human approval, no matter how well the assistant tests. Anyone selling you a chatbot with zero residual risk is selling you a fairy tale. Anyone who names the risks and addresses them layer by layer is selling you a tool.