Handling refusals and hallucinations

Day 24 of 30 · 30 Days of AI

Add guardrails for safety and fallback answers


Learning goal

  • Write prompts that allow “I don’t know” and cite uncertainty.
  • Add checks for risky content.

Why it matters

  • Refusals are safer than confident errors.
  • Uncertainty flags guide human QA.

Explanation

  • Include: “If unsure, say ‘Not sure, need X data’.”
  • Forbid: “Do not fabricate data or sources.”
  • Ask for an “uncertainty” line in outputs.

Examples

  • Prompt: “Answer in 3 bullets; if unknown, state unknown and what data is needed; do not invent.”
  • Weak: “Answer everything confidently.”

  • Guided exercise (10–15 min)

    1. Take a factual prompt; add refusal/uncertainty clauses.
    2. Generate output; confirm it flags unknowns.

    Independent exercise (5–10 min)

    Add a short “risk check” line to your QA checklist.


    Self-check

    • Prompt allows “unknown”.
    • No fabricated data.
    • Uncertainty/risk noted.

    Optional deepening