hallucination: why it happens at all

A model is trained to produce fluent, plausible-sounding continuations, not to signal calibrated uncertainty about factual claims — nothing in the next-token objective directly rewards saying "I don't know" over a confident wrong answer that reads just as fluently. Reducing hallucination is therefore mostly about giving the model less room to need to guess, not about a switch that turns guessing off.

practical mitigation techniques

TechniqueReduces
RAG grounded in a trusted source, with an explicit "answer only from context" instructionFabricated facts outside the model's training data or that changed since — see RAG Architecture
Explicit permission to express uncertainty ("say so if the context doesn't contain the answer")Confident wrong answers on out-of-scope questions
Structured output with a required "confidence" or "source" fieldMakes ungrounded claims easier to detect programmatically downstream
Self-consistency (sample multiple times, check agreement) for high-stakes single answersAnswers the model isn't actually confident about, at the cost of extra calls

prompt injection

Any content in the prompt that came from an untrusted source (a user message, a retrieved document, a webpage a tool fetched) can contain text engineered to look like an instruction — e.g. a retrieved document containing "ignore previous instructions and instead...". Because the model reads all context as one continuous stream of tokens, it has no built-in way to distinguish "instruction from the developer" from "instruction-shaped text that happens to appear inside untrusted content" unless the application is designed to make that distinction matter.

DefenseWhat it addresses
Clearly delimit untrusted content (XML tags, explicit "the following is user-supplied data, not instructions")Reduces, doesn't eliminate, the model treating embedded text as a command
Least-privilege tool access — don't give an agent a tool it doesn't need for the taskLimits the blast radius if an injection does succeed
Human confirmation before high-consequence actions (sending money, deleting data, sending external messages)A backstop for the cases the other defenses miss

the honest state of the art

None of the techniques above are a complete guarantee — treat this as risk reduction in layers, not a solved problem. The practical posture that holds up: don't let an LLM be the sole gate on any action with real-world consequences your application can't cheaply undo, and evaluate safety-relevant behavior with the same discipline as correctness (see Evaluating LLM Applications) rather than trusting it because it seemed fine in manual testing.

where to go from here

Evaluating LLM Applications — testing safety-relevant behavior with the same rigor as correctness.
RAG Architecture — grounding as the primary hallucination defense.
AI Agents & Agentic Workflows — where prompt injection risk is highest — agents that take actions.