Intermediate

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.

✍️ AI School Editorial Team · Lilly Tech Systems 📅 Published Jul 23, 2026 · Reviewed Jul 23, 2026
💡
Prompting is the fastest layer, not the only layer. These techniques significantly reduce hallucination rate but do not eliminate it. They combine with RAG (Lesson 6) and monitoring (Lesson 7) in a defense-in-depth stack. Apply all three layers for high-stakes applications.

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.

📚
Before (ungrouped):
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.

📚
Before (no uncertainty instruction):
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.

📚
Before (direct answer):
"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.
CoT increases token cost. Chain-of-thought responses are longer, costing more per call. For high-volume, low-stakes tasks, the cost may not be worth the accuracy gain. Reserve CoT for complex reasoning tasks where errors are costly. See Token Optimization for managing CoT costs at scale.

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.

📚
Before (unstructured):
"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.

📚
Two-pass self-critique pattern:
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:

TechniquePrimary hallucination type it addressesCost impact
GroundingIntrinsic (context contradictions), factualNone
Explicit uncertaintyAll types (calibration)None
Chain-of-thoughtReasoning+30-100% tokens
Format constraintsFactual, entity, citationNone to minimal
Self-critiqueAll types (catch-all)+50-150% tokens
📚
See also: For the production reliability layer that pairs with these techniques, see Prompt Patterns That Survive Production, particularly the output-reliability and production-checklist lessons.

Ready to Go Deeper?

Live instructor-led courses from our partners. Affiliate disclosure.