How to Stop AI Chatbots From Hallucinating
Hallucinations are not fixed by a better prompt. Here is the evaluation framework we use to measure and reduce them before launch — and keep them down after every change.
Every team building an AI chatbot eventually hits the same moment: it confidently states something false. The instinct is to fix it with a better prompt — "only answer from the provided context," "say you don’t know if unsure." Those instructions help a little and are nowhere near enough on their own. Hallucinations are a measurement problem before they are a prompting problem: you cannot reliably reduce what you are not measuring, and most teams ship without ever measuring it at all.
Why hallucinations happen even with RAG
Retrieval-augmented generation reduces hallucinations by grounding answers in retrieved passages, but it does not eliminate them, because failure can happen at several points: retrieval returns the wrong or incomplete passages, the model ignores the retrieved context and answers from its own training data anyway, or the model blends retrieved facts with a plausible-sounding but unsupported addition. A prompt instruction addresses none of these mechanically — it just asks the model to behave, which it will do inconsistently under pressure or ambiguity.
Build an evaluation set before you launch
The single highest-leverage step is building a set of real questions — ideally fifty to a few hundred, pulled from actual user queries, support tickets or sales questions — each with a known correct answer and the source it should come from. This becomes your yardstick: every version of the system, every prompt change, every model swap gets run against it before it reaches users, not just reviewed by eye.
What to measure
- Retrieval precision and recall — did the system fetch the passages that actually contain the answer?
- Groundedness — is every claim in the answer supported by the retrieved context, or did the model add something unsupported?
- Citation accuracy — does the cited source actually say what the answer claims it says?
- Refusal rate and correctness — does the system say "I don’t know" when it genuinely does not know, without over-refusing on questions it can actually answer?
Guardrails that reduce hallucinations in production
- Requiring citations for every factual claim, and rejecting answers that cannot cite a source
- A confidence or relevance threshold on retrieval, below which the system declines rather than guesses
- Re-ranking retrieved passages so the most relevant context sits closest to the question in the prompt
- A second pass that checks the draft answer against the retrieved context before it reaches the user
Re-evaluate after every change
This is the step most teams skip once they are live: a prompt tweak, a model upgrade or a new document source can quietly regress hallucination rates even while everything looks fine in a quick manual check. Running the evaluation set as a required step before every release — the same way you would run a test suite before shipping code — is what turns "we think it got better" into a number you can defend.
None of this requires exotic tooling. It requires discipline: a real evaluation set, a repeatable way to score against it, and a rule that nothing ships without clearing it. That evaluation suite is a standard part of every RAG system we build, for exactly this reason.
Frequently asked questions
Can AI hallucinations be eliminated completely?
Not with current techniques, but they can be measured and driven down substantially. The goal is a system that knows when it does not know, cites every claim, and is continuously tested against a real evaluation set — not a guarantee of zero errors.
How many test questions do we need in an evaluation set?
Fifty to a few hundred real questions, covering your common queries and known edge cases, is typically enough to catch meaningful regressions. More matters less than making sure the questions reflect what users actually ask.
Do we need a human to grade every answer?
Human review is important when building the initial evaluation set and spot-checking results, but scoring retrieval accuracy and groundedness can be partly automated, so day-to-day regression checks do not require re-grading everything by hand.
Related services
RAG Solutions
Retrieval-augmented generation (RAG) systems that ground LLM answers in your own documents, databases and APIs — so responses are accurate, current and traceable to a source.
Learn moreAI Agents & LLM Integration
LLM-powered features, AI agents and MCP tool calling embedded directly into your product, automating workflows with your live business data.
Learn moreWant this built for your business?
Book a free consultation — tell us what you want to build and we'll come back within one business day with an approach and next steps. No cost, no commitment.
Book a Free Consultation