How to Reduce AI Hallucinations With Prompts
Ground the answer in pasted source text, allow "not stated", demand a quote per claim, and lower temperature — the prompt habits that cut invented facts.
Step 5 of 5 · Prompt like a pro
On this page6 sections
A hallucination is the model filling a gap confidently instead of admitting one. You cannot eliminate it with prompting, but the single biggest lever is grounding: give the model the text and forbid anything outside it. Everything below is ordered by how much it actually helps.
1. Source first, question last
<source>
…paste the document here…
</source>
Using only the source above, answer the question. If the answer is not in the
source, reply exactly "not stated in the source". Do not use outside knowledge.
Question: what is the notice period for termination?
Note the order. For long inputs, putting the document above the instruction and question measurably beats the reverse — Anthropic reports up to 30% better responses on complex multi-document prompts when the query comes last.
2. Make “I don’t know” allowed
If you are not certain, say so and list what you would need to be certain.
Models invent because they infer that an answer is mandatory. Explicitly licensing uncertainty removes the pressure that produces the guess.
3. Demand a quote per claim
For each claim, quote the exact sentence from the source that supports it.
Claims with no supporting sentence must be dropped.
Turns verification into something you can skim. A claim whose quote doesn’t exist, or doesn’t say what the claim says, is the fabrication — visible at a glance.
4. Lower the temperature for facts
For extraction, classification and factual Q&A, a low temperature around 0.2 gives steadier output. Keep the higher values for brainstorming, where variety is the point.
5. For agents: read before answering
<investigate_before_answering>
Never speculate about code you have not opened. If the user references a
specific file, you MUST read the file before answering.
</investigate_before_answering>
Anthropic’s own sample instruction for grounding a coding agent. The failure mode with tools is different from chat: the model has the means to check and simply doesn’t, so make checking a rule rather than an option.
6. Verify what matters anyway
Treat names, numbers, dates, quotations, citations and code as draft until checked. Retrieval helps here — RAG keeps the facts external and citable — but retrieval that pulls in untrusted text brings its own risk; see prompt injection defense. For anything repeated, catch regressions with LLM-as-judge evals instead of spot-checking by hand. Source: prompting best practices.