What Hallucinations Are
A hallucination is output that is fluent, confident, and wrong. The model produces a plausible answer when it should produce an uncertain one, an empty one, or a different one. Hallucinations are not a bug in the conventional sense; they are a property of how language models work. The model is trained to predict the next token, and when the underlying knowledge is missing or ambiguous, the token that fits stylistically is not always the token that fits truth. Hallucinations show up in three common patterns:- Fabricated facts. Statistics that do not exist, citations that do not exist, quotes that were never said.
- Confused facts. Real entities mixed up with other real entities; a date that belongs to a different event.
- Plausible inventions. Code that calls functions that do not exist; APIs with the right shape but the wrong parameters.
Grounding In Source Material
The single most effective technique is to give the model the source material and require it to use only that material.Quote First, Then Answer
A useful technique for long document tasks: ask the model to extract the relevant verbatim quotes before producing its answer. This forces the model to anchor its response in the source material and makes verification trivial.Allow The Model To Say “I Don’t Know”
By default, models are biased toward producing an answer rather than admitting uncertainty. Explicitly grant the model permission to abstain.Citations and Confidence
When the model is allowed outside knowledge but the answer must be verifiable, ask for citations and confidence:Verification Loops
For high stakes tasks, run a second prompt that audits the output of the first. The auditor prompt receives both the original task and the generated answer, and is asked to find errors.Controlling Temperature
The temperature parameter controls how often the model picks a less likely token. For factual tasks, set temperature to 0 or close to it. The output becomes deterministic and the model picks the most probable token at each step, which is also usually the most factually grounded one. For creative tasks, higher temperature produces more variety. For factual tasks, higher temperature produces more hallucinations. The trade off is real, and the right setting depends on the task. As a starting point:- Extraction, classification, factual Q and A: temperature 0.0 to 0.2.
- Drafting, editing, summarization: temperature 0.3 to 0.5.
- Creative writing, brainstorming: temperature 0.7 to 1.0.
Detection Patterns
Even with all the above, some hallucinations will get through. Build detection into the workflow:- Spot check. Sample 5 percent of outputs and have a human review them. Track the hallucination rate over time.
- Cross check. Run the same prompt twice with non zero temperature. If the answers diverge on a factual point, at least one is wrong.
- Schema check. If the output should contain certain fields with certain shapes, validate. A hallucinated date often fails an ISO 8601 check.
- Source check. If the model cites a URL or a paper, verify it exists. A surprising fraction of hallucinated citations are caught by a simple URL fetch.
