code/+/trust primary logo full color svg

Hallucination

Definition

Hallucination is the failure mode where a large language model generates plausible-sounding but factually incorrect information with apparent confidence. Studies show unmitigated LLMs hallucinate on 15-30% of factual queries, making hallucination mitigation a mandatory engineering requirement -- not a nice-to-have -- for any production AI system that surfaces facts.

LLMs predict the next most-likely token. When a model does not know the answer, it still generates fluent text -- and that text is often wrong. The danger is that hallucinated outputs look identical to correct ones. Users cannot distinguish without an independent check.

Hallucination mitigation strategies

  • RAG -- ground every response in retrieved source documents; cite the source
  • Output validation -- run a second model pass or rule check against known-good data
  • Constrained output -- limit the model to selecting from a verified list rather than free generation
  • Human-in-the-loop -- require human review for high-stakes outputs (medical, legal, financial)

Hallucination and liability

In regulated industries (healthcare, legal, GovCon), AI systems that surface unverified facts create real liability. Every enterprise AI deployment must have an explicit hallucination mitigation plan documented before go-live.

Related terms

Need help implementing this in your business?

Code and Trust translates AI concepts like hallucination into working implementations — starting with a workflow audit that shows exactly where it creates ROI.

Schedule AI Audit →