Guardrails
Layered checks on inputs, outputs and actions, chosen from the harms that matter for this product rather than a generic list.
A guardrail is any control that keeps an LLM feature inside acceptable behaviour. No single layer is reliable, so stack several cheap ones and keep the expensive human review for the highest-risk actions.
| Layer | Examples |
|---|---|
| Input | Authentication and quotas; PII detection and redaction; topic or intent classification; size limits; prompt-injection heuristics on untrusted content |
| Model and prompt | Clear scope in the system prompt; refusal instructions; model choice with appropriate safety behaviour |
| Output | Schema validation; citation checks; toxicity or policy classifiers; blocking secrets and PII in responses |
| Action | Least-privilege tools; authorisation as the user; human approval for irreversible steps; rate limits on side effects |
| Monitoring | Sampling and review of transcripts; alerts on refusal spikes, unusual tool use or cost |
Trade-offs to state
- False positives cost users and revenue; tune thresholds on your eval set, not by intuition.
- Every classifier adds latency; run independent checks in parallel with generation where possible and cancel on failure.
- Logging transcripts helps safety review but raises privacy risk; decide retention and access up front.
The security track goes deeper on prompt injection, data exfiltration and tool permissions.
Practice
Written for this site to drill the lesson. Not reported interview questions.
- Choose guardrails for a public-facing tax-help chatbot. Which layer catches which harm?
- Your output classifier blocks 4% of legitimate answers. How do you decide what to change?
Check yourself
Why layer guardrails?
No single layer is reliable; independent cheap layers catch different failures.
Which actions need human approval?
Irreversible or high-impact ones: payments, sending external messages, deleting data, production changes.
Sources
- Reference OWASP Top 10 for LLM Applications
Saved in this browser.