How do you reduce LLM hallucinations in production?

Short answer

Reduce LLM hallucinations by giving the model the facts instead of relying on its memory, retrieving only relevant context, constraining outputs with schemas, requiring citations that code can check, allowing the model to say it does not know, and sending high-stakes answers to a person. Hallucinations can be reduced but not eliminated, so design the product to detect and contain the ones that get through.

Written for engineers and product owners running language model features where a confident wrong answer has a real cost.

By , co-founder and CTO of Tellme AIPhD in AI, Queen’s University Belfast · Author of From Model to Product · Updated

Key facts

Definitions

Hallucination
Output that is fluent and confidently stated but false, unsupported by the input, or inconsistent with what the model said earlier. NIST's term for it is confabulation.
Grounding
Supplying the model with the facts it must use, retrieved or decided by the application, and instructing it to answer only from them.
Abstention
A designed response in which the system declines to answer, or says it does not know, when the evidence is missing or confidence is low.
Structured output
A mode in which generation is constrained to a supplied schema, such as JSON with fixed fields and allowed values, so the application can parse and check every field.

Why LLMs hallucinate, and why you cannot eliminate it

A language model generates the most plausible continuation of its input, and plausible is not the same as true. When the input lacks the facts, the model fills the gap with something that sounds right. NIST's Generative AI Profile calls this confabulation and describes it as a natural result of how generative models are designed.

Research explains why it persists. Kalai et al. argue that training and evaluation reward guessing over admitting uncertainty, so models learn to guess, and Xu, Jain and Kankanhalli argue formally that hallucination cannot be eliminated in models used as general problem solvers.

The practical conclusion is to stop aiming for zero and work in layers: make hallucinations rarer, make them detectable, and limit the damage when one gets through.

Ground the model in facts it is given

The biggest single reduction comes from not asking the model to remember. Retrieve the facts or decide them in code, put them in the prompt, and instruct the model to answer only from them. A model explaining a fact it was handed has far less room to invent than one recalling from training.

Chapter 11 of From Model to Product builds this up as a prompt template that locks the decisions the backend has made and forbids invented rules and guessed details, and is candid that this makes behaviour far more predictable without eliminating hallucination. LLM APIs in production walks through that template and the checks around it.

Grounding also means scope. Tell the model what it is for and what to do with questions outside it, because off-topic questions are where it has least to go on.

Retrieval quality sets the ceiling

When retrieval misses the passage that holds the answer, the model fills the gap, so a hallucination in a RAG system is often a retrieval failure in disguise. Measure retrieval on its own before tuning prompts.

Send less, not more. Liu et al. found models use information in the middle of a long context markedly worse than at its start or end, so a few relevant passages beat many loosely related ones.

Four retrieval habits do most of the work; pgvector or a vector database covers storage, and RAG vs fine-tuning covers when retrieval is the right fix at all.

  • Filter before ranking, by tenant, jurisdiction, product version or date, so an answer cannot be built from a document that does not apply.
  • Combine keyword and semantic search and rerank the candidates, so exact terms such as product codes are not lost.
  • Chunk along the document's own structure, keeping headings with their text, so each passage carries its context.
  • Retire stale documents from the index, since a correct quote from an outdated policy is still a wrong answer.

Constrain what the model can say

Every field the model does not write as free text is a field it cannot embellish. Use structured output modes that constrain generation to a JSON schema, enumerations for anything with a fixed set of values, and identifiers chosen from a supplied list rather than names or numbers typed out.

Then check the values in code. A schema guarantees shape, not truth: the model can return a well-formed date that is wrong. Compare every decided value with what the backend knows, confirm each cited document identifier is in the retrieved set, and recompute any figure the model reports.

Dr. Dulan Dias's write-up of building a production-ready prompt engine shows structured output and layered guardrails working together in one system.

Make every claim checkable

Ask for citations, then verify them. Have the model attach a quote or passage identifier to each claim, check in code that each quote appears in the source, and drop or flag any claim without support. Anthropic's guidance on reducing hallucinations recommends the same pattern of retracting claims that lack a supporting quote.

For long-form answers, add a verification pass. Chain-of-Verification has the model draft, plan fact-checking questions, answer them independently of the draft and revise. A cheaper signal is to run the same prompt several times and compare: inconsistent answers can indicate hallucination.

Each check adds latency and cost, so keep model-based verification for outputs where a wrong claim matters, and use code checks everywhere else.

Let the system say it does not know

A model told it may answer only when the evidence supports it, and given a defined way to decline, invents less. Anthropic lists explicit permission to say I don't know as a basic technique, and Dulan's AICON Belfast talk on Tellme AI, the museum guide live at three national museums, reports that giving the model that way out cut invention sharply.

Do not leave abstention to the model alone. When retrieval returns nothing relevant, return a fixed, honest response without calling the model. When a classifier is unsure which item the user means, ask a clarifying question rather than guess.

Track abstention as a metric. A rising rate points to a gap in retrieval or coverage; a rate near zero on hard questions suggests the model is still guessing.

Match the safeguards to the stakes

The right level of protection depends on what a wrong answer costs, not only on how often the model is wrong. In Moffatt v. Air Canada (February 2024), British Columbia's Civil Resolution Tribunal found the airline responsible for its chatbot's wrong fare advice, saying it made no difference whether information came from a static page or a chatbot.

OWASP's LLM09:2025 Misinformation entry recommends the same mix as below: trusted retrieval, automatic validation, human oversight and clear communication of limits.

StakesExampleSafeguards
LowDrafting internal text that a person editsGrounding, a response format and spot checks of samples
MediumCustomer-facing answers about products or policiesRetrieval from approved sources, verified citations, abstention, monitoring and an easy route to a person
HighAdvice or decisions with legal, medical or financial consequencesAll of the above, plus human review before anything reaches the user or triggers an action, and an audit log of sources and versions

Monitor hallucinations in production

Hallucination rates move whenever anything around the model moves: a new model version, a prompt edit, new documents or a new kind of question. Monitor them like any other quality metric.

  • Run a faithfulness judge on a sample of live answers against the context each one was given.
  • Chart citation-check failures, abstentions, user corrections and hand-offs to people, and alert on sudden shifts.
  • Re-run the evaluation set after every model, prompt or index change; how to evaluate an LLM application covers building one.
  • Log the sources, prompt version and model version behind every answer, so a reported error can be traced to its cause.
  • Add each confirmed hallucination to the evaluation set so the fix stays fixed.

Frequently asked questions

Can you completely eliminate LLM hallucinations?

No. Formal work argues hallucination cannot be eliminated in language models used as general problem solvers, and NIST describes confabulation as a natural result of how generative models work. What you can do is make it much rarer through grounding and retrieval, detect it with citation checks and verification, and contain it with abstention, human review and limits on what the model's output can trigger.

Does RAG stop hallucinations?

It reduces them but does not stop them. Retrieval gives the model facts to work from, yet the model can still misread a passage, merge two passages wrongly, or answer from memory when retrieval returns nothing useful. Pair RAG with an instruction to answer only from the context, citations checked in code, and a fixed response when no relevant passage is found.

Which LLM hallucinates the least?

There is no stable answer. Rankings change with each model release and differ by task, domain and language, so a leaderboard result from one month says little about your use case the next. Shortlist a few models, run them on your own evaluation set with your retrieval and prompts, and compare faithfulness and abstention directly. Repeat the comparison whenever you consider switching.

How do you detect hallucinations automatically?

Combine checks by cost. Code can confirm that quoted text appears in the source, that cited documents were actually retrieved, and that numbers and names match your records. A judge model can rate whether each claim is supported by the supplied context. Sampling the same question several times and flagging disagreement adds another signal. None is perfect, so route flagged answers to a fallback or a person.

Are companies responsible for what their AI chatbot says?

In at least one decided case, yes. In Moffatt v. Air Canada (2024), a Canadian tribunal held the airline responsible for wrong fare information from its website chatbot, saying it made no difference whether information came from a static page or a chatbot. Laws differ between countries and this is not legal advice, but plan as if your organisation owns every answer its assistant gives.

Why does my RAG chatbot still make things up?

Usually because retrieval failed silently. The right passage was missing from the index, ranked too low, split by chunking or out of date, so the model answered from memory. Other causes are prompts that do not forbid going beyond the context, too much loosely related context, and no fallback when nothing relevant is found. Check retrieval for the failing questions before changing the prompt or the model.

Does lowering the temperature reduce hallucinations?

Not in the way people hope. A lower temperature makes output less random and more repeatable, which helps testing, but it does not give the model facts it lacks: a model that confidently misremembers will repeat the same error every time. Grounding, retrieval, schemas and verification address the cause, so treat temperature as a consistency setting rather than an accuracy one.

Sources

  1. NIST AI 600-1, Artificial Intelligence Risk Management Framework: Generative Artificial Intelligence Profile (July 2024)
  2. Xu, Jain and Kankanhalli, Hallucination is Inevitable: An Innate Limitation of Large Language Models (arXiv 2401.11817)
  3. Kalai et al., Why Language Models Hallucinate (arXiv 2509.04664)
  4. Liu et al., Lost in the Middle: How Language Models Use Long Contexts (arXiv 2307.03172)
  5. Dhuliawala et al., Chain-of-Verification Reduces Hallucination in Large Language Models (arXiv 2309.11495)
  6. Anthropic: Reduce hallucinations
  7. OWASP Top 10 for LLM Applications: LLM09:2025 Misinformation
  8. Civil Resolution Tribunal of British Columbia: Moffatt v. Air Canada, 2024 BCCRT 149
Dr. Dulan Dias

About the author

Dr. Dulan Dias is co-founder and Chief Technology Officer of Tellme AI in Belfast; founder of EchonLabs, grown from 2017 to more than 60 people before its acquisition in 2026; holder of a PhD in AI and data science from Queen’s University Belfast; and the author of From Model to Product.

Who is Dr. Dulan Dias?

All answers