Prompting to Prevent Hallucination
The prompt is the fastest intervention point. Five prompting techniques (grounding, explicit uncertainty, chain-of-thought, format constraints, and self-critique) each directly target one or more hallucination root causes from Lesson 3.
Technique 1: Grounding Prompts
Grounding prompts restrict the model to the information supplied in context, preventing it from drawing on its parametric knowledge (which may be wrong). This is the single highest-impact prompting technique for closed-domain tasks.
System: "You are a helpful assistant."
User: "Summarize the key dates in this contract."
After (grounded):
System: "You are a contract analyst. Answer only using information from the document provided by the user. If a date is not explicitly stated in the document, say 'Not specified in document.' Do not infer or extrapolate dates."
User: "Summarize the key dates in this contract: [document text]"
The grounded prompt adds three hallucination-reducing elements: a scope restriction ("only using information from the document"), an explicit fallback instruction ("say Not specified in document"), and a negative constraint ("do not infer or extrapolate"). Each element closes a different route to hallucination.
Technique 2: Explicit Uncertainty Instructions
From Lesson 3: models are miscalibrated toward overconfidence and are fine-tuned to be helpful (which pushes against "I don't know" answers). Explicit uncertainty instructions directly counteract these biases by giving the model permission to acknowledge limits.
System: "Answer the user's questions about pharmaceutical regulations."
Result: The model answers confidently even for jurisdiction-specific edge cases it may not have accurate information about.
After (with uncertainty instruction):
System: "Answer the user's questions about pharmaceutical regulations. If you are uncertain about any specific claim, use language like 'I believe,' 'you should verify,' or 'this may vary by jurisdiction.' If you do not have reliable information to answer a question, say so explicitly rather than guessing. Accuracy matters more than completeness."
Result: The model flags uncertain claims with hedging language, making it far easier for users to identify which answers need verification.
The key phrase "accuracy matters more than completeness" is particularly effective: it reframes the success criterion away from generating a full answer and toward generating a reliable one.
Technique 3: Chain-of-Thought for Reasoning Tasks
Chain-of-thought (CoT) prompting instructs the model to reason step-by-step before producing its final answer. For reasoning hallucinations (Lesson 2, Type 2), CoT reduces errors because the intermediate reasoning steps are visible and can be checked, and because making reasoning explicit tends to catch logical errors the model would otherwise skip over.
"Is the limitation-of-liability clause in this contract enforceable under California law?"
Result: The model returns a yes/no with a brief legal-sounding rationale. The reasoning is opaque.
After (chain-of-thought):
"Analyze whether the limitation-of-liability clause in this contract is enforceable under California law. First, identify the specific text of the clause. Then, list the California legal requirements for enforceability of such clauses. Then, check whether the clause meets each requirement. Finally, give your conclusion and explain which elements you are uncertain about."
Result: The step-by-step output is auditable. A legal reviewer can check each step, catch errors, and identify where the reasoning is uncertain.
Technique 4: Format Constraints
Requiring structured output (JSON, numbered lists, tables, specific field formats) reduces hallucination by narrowing the generation space. Unstructured prose gives the model freedom to add any token that sounds plausible. Structured formats impose constraints that prevent many classes of fabrication.
"Extract the key parties and dates from this contract."
Result: Prose summary with potential for added interpretation, inferred dates, and fabricated details.
After (structured with explicit null handling):
"Extract the key parties and dates from this contract and return them as JSON in this exact format:
{"parties": [{"name": "...", "role": "..."}], "effective_date": "YYYY-MM-DD or null", "expiration_date": "YYYY-MM-DD or null", "execution_date": "YYYY-MM-DD or null"}Use null for any value not explicitly stated in the document."
Result: The JSON schema prevents the model from inventing narrative and forces null for missing values rather than estimates.
The null instruction is critical: without it, models often fill missing fields with plausible-looking values. With it, the model has a sanctioned response for uncertainty.
Technique 5: Self-Critique and Reflection
Self-critique prompts ask the model to review its own output for factual claims that may be unreliable before returning the final answer. This is an internal verification step at the prompt layer.
First pass (generation): "Answer the following question about the history of database technology: [question]"
Second pass (reflection): "Review your answer above. For each specific factual claim (dates, names, events, statistics), indicate whether you are confident it is accurate or whether the user should verify it independently. Mark uncertain claims with [VERIFY]."
Result: The final answer has explicit VERIFY markers on claims the model is less certain about, making it actionable for a human reviewer.
The two-pass pattern adds latency and cost but significantly improves the calibration of the output. For applications where users act on the model's claims, self-critique makes the trust signal explicit rather than requiring users to guess which parts of the answer to check.
Combining the Techniques
These five techniques compose. The most hallucination-resistant prompts use all five where applicable:
| Technique | Primary hallucination type it addresses | Cost impact |
|---|---|---|
| Grounding | Intrinsic (context contradictions), factual | None |
| Explicit uncertainty | All types (calibration) | None |
| Chain-of-thought | Reasoning | +30-100% tokens |
| Format constraints | Factual, entity, citation | None to minimal |
| Self-critique | All types (catch-all) | +50-150% tokens |
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX