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.”
- Take a factual prompt; add refusal/uncertainty clauses.
- Generate output; confirm it flags unknowns.
- Prompt allows “unknown”.
- No fabricated data.
- Uncertainty/risk noted.
- Safety prompts: https://platform.openai.com/docs/guides/safety-best-practices
Guided exercise (10–15 min)
Independent exercise (5–10 min)
Add a short “risk check” line to your QA checklist.