Guardrails

13 min read

An LLM tries to answer anything it is sent. It can also say things you never meant it to say. Guardrails are checks you put around the model. They watch what goes in, what comes out, and what the model may do. One check is never enough, so you use several layers.

New words

Guardrail
A check outside the model that can block or fix traffic.
PII
Personal data, such as a card number, phone number or email.
Redaction
Hiding private parts of the text, for example with stars.
Classifier
A small model that puts text into a category.
Threshold
The score above which a message is blocked.
False positive
A normal message that is blocked by mistake.
Defence in depth
Many layers of checks, so one failure is not a disaster.

What you will learn

  1. The problem: the model says yes to everything
  2. How it works: checks on three sides of the model
  3. Three ways to build a guard
  4. Try it: run messages through the guards
  5. Trade-offs and failure modes
  6. Production practices
  7. In code
  8. In a real system
  9. Interview tip
  10. Key takeaways

10 quiz questions at the end.

Start this lesson

The full lesson, with interactive demos and the quiz, opens after you sign in with Google. It is free.

All lessons · Back to the roadmap