All insights

    AI in Production

    How Do You Stop an LLM Hallucinating in a Regulated Product?

    · 8 min read · Anton Babayan, Founder

    You cannot make a language model incapable of being wrong. Anyone selling you that is selling something else. What you can do is stop it answering from nothing, catch the wrong answers before a customer sees them, and make every answer reconstructable afterwards. In a regulated product those three things are the job.

    Give it nowhere to invent from

    Most hallucination in enterprise systems comes from asking a model something your documents do not answer. It will answer anyway, because that is what it was trained to do. So the first control is retrieval: the model sees the relevant passages from your own material and is instructed to work only from them.

    The part teams skip is the refusal path. Retrieval that finds nothing relevant should produce “I don’t have that” and a route to a human, and the system has to be built so that outcome is normal rather than a failure. If there is no way for the model to decline, it will fill the gap, and it will sound just as confident doing it.

    Retrieval reduces the problem a long way. It does not remove it. A model can still misread a passage or stitch two together wrongly, which is why it is a first control rather than the only one.

    Separate what it may say from what it may do

    The consequence of being wrong varies enormously across a single product. Explaining what a fee is costs little if it is slightly off. Telling a customer their transfer limit, confirming a transaction, or saying anything that reads as advice is a different matter.

    So we grade the surfaces. Low-consequence answers go straight to the customer. Anything that commits the business, moves money or resembles advice is drafted by the model and sent by a person. That human review is often described as a temporary measure until the model improves. Treat it as permanent for the highest tier and you will design the queue properly instead of bolting it on.

    Facts come from systems, not from the model

    A model should never be the source of a number. Balances, limits, dates and statuses come from the system that owns them, fetched at answer time and inserted into the response. The model writes the sentence around the number.

    This sounds obvious and is routinely violated, usually because the number appeared in a retrieved document and the model repeated it from there. If a figure can change, it has to be looked up rather than retrieved.

    Make every answer reconstructable

    Assume someone will eventually ask why a customer was told a particular thing on a particular day. Answering that means storing, for every response, the documents retrieved, the prompt as sent, the model and its version, the output, and who reviewed it if anyone did.

    Model versions move underneath you. An answer that was fine in March and wrong in June, with no record of which version produced it, is an investigation with no evidence. Pin versions where the provider allows it and record them where it does not.

    Measure it on your own traffic

    Published benchmarks tell you very little about your product. What tells you something is a set of a few hundred real questions from your own users, answered by the system, graded by someone who knows the domain. That gives a baseline error rate, and it is the only honest basis for deciding which surfaces can go direct to customers.

    Rerun it on every prompt change and every model upgrade. The upgrade that improves nine things and breaks the tenth is common, and without the evaluation set you find out from a complaint.

    The short version

    Ground answers in your own material and let the model refuse. Look numbers up rather than retrieving them. Grade surfaces by what being wrong costs, and keep a person in front of the expensive ones. Log enough to reconstruct any answer, and measure the error rate on your own questions rather than on a leaderboard.

    Frequently asked questions

    Can you stop an LLM from hallucinating entirely?

    No. A language model can always produce a confident wrong answer. What you can control is whether it is allowed to answer without a source, and whether a wrong answer reaches the customer or stops at a human.

    Does retrieval solve hallucination?

    It reduces it substantially and does not remove it. Retrieval gives the model the right material, but the model can still misread that material or fill a gap. Retrieval has to be paired with a refusal path for when nothing relevant is found.

    What does an auditable AI answer look like?

    Every answer carries the documents it was drawn from, the model and version that produced it, the prompt, and the time. A regulator asking why a customer was told something should get a reconstruction, not a shrug.

    Should an AI answer customers directly in a regulated product?

    It depends on the consequence of being wrong. Explaining a fee is low risk. Anything that reads as advice, a decision or a commitment should be drafted by the model and sent by a person, at least until you have measured its error rate on your own traffic.

    Related reading

    Planning something similar?

    We find where AI actually fits, build it, and get it running in production.

    Get in Touch