Back to Blog
How to Stop LLM Hallucinations in Production Apps

How to Stop LLM Hallucinations in Production Apps

Dennis Reinkober2 min read
TL;DR

Hallucinations aren't fixed in the prompt — they're engineered around. Build five layers: ground answers in retrieved sources (RAG), constrain output with schemas and a first-class "not found", show citations users can check, measure accuracy against an evaluation set before launch, and route low-confidence answers to a human. Aim for a known error rate with graceful failure, not zero errors.

An AI feature that confidently invents facts is worse than no AI feature. Here's the architecture we use to keep hallucinations out of user-facing answers.

Why can't you just prompt hallucinations away?

Because hallucination isn't disobedience — it's how these models work. They generate the most plausible continuation, and where the training data or context runs out, "plausible" quietly replaces "true". Adding "never make things up" to the system prompt changes nothing you can measure. Reliability has to come from the system around the model, not from asking nicely.

The five layers, and what each one catches

LayerWhat it catchesEffort
Grounding (RAG)Answers invented from thin airDays–weeks
Constrained outputFree-text drift, invalid valuesHours–days
Checkable citationsPlausible-but-wrong claimsDays
Evaluation setUnknown accuracy, silent regressionsDays, then ongoing
Confidence routingThe residual riskDays

Grounding means the model answers only from documents you retrieved — and "not found in the sources" is a first-class answer, not a failure state. Most hallucinations we see in audits come from letting the model fall back to its own memory when retrieval comes up empty.

Constrained output removes entire error classes. If a field can only be one of five statuses, enforce an enum — the model physically can't invent a sixth. Schemas, allowed values, and an explicit "unknown" option catch drift before your users do.

Citations shift verification to the reader. Every claim links to the source passage it came from. Users forgive a wrong answer they could check; they don't forgive one presented as unverifiable truth.

How do you know your accuracy before launch?

You build an evaluation set: 100–300 real questions with verified answers, run against the pipeline before anything ships. That number — 87%, 92%, 96% — becomes your baseline, and every prompt tweak, retrieval change, or model swap gets regression-tested against it. If you can't name your accuracy number, you have a demo, not a feature.

The honest target: a known error rate

Zero hallucinations is not an achievable spec, and anyone promising it is selling you the demo. The achievable spec: a measured error rate, sources on every answer, and a graceful path when confidence is low — the answer goes to a human instead of the user. A feature with 92% measured accuracy and visible sources beats one with unknown accuracy every single time.

We design and build exactly these guardrails as part of our AI & LLM integration work — and if you're deciding how to ground your model, start with RAG vs. fine-tuning.

Similar Posts

Let's Talk

Automation, AI, infrastructure or a software idea? Leave your phone number and we will call to discuss what you need.

Prefer to contact us directly? Write to us or give us a call.

We use your phone number to handle your callback request. Privacy.

Or call: +49 (0)172 7593488