1:1 mentoring with Big Tech AI engineers
System Design

Guardrails & Safety

AI guardrails and safety: content filtering, output validation, safety classifiers, and responsible AI deployment.

Last updated

Production35 min readFirst readSecurity Overview

After this section you can

  • Design the input/output classifier sandwich with a per-stage latency budget
  • Compare toxicity/safety tools on latency, accuracy, and cost
  • Implement a declarative policy engine and a production async safety pipeline
  • Justify a build-vs-buy guardrails stack for a given industry
SD-13

Guardrails & Safety

The production safety stack: input/output classifiers, policy engines, and build-vs-buy decisions with real latency numbers.

Input & Output Classification Pipeline

A production LLM system requires safety checks at two critical points: before the prompt reaches the model (input classification) and after the model generates a response (output classification). These form a "sandwich" architecture that defends against both malicious inputs and harmful outputs.

Input/Output Safety Pipeline (Sandwich Architecture)
User Input
INPUT CLASSIFIERS
PII · Jailbreak · Topic · Injection
Pass?
LLM
or
Reject
LLM
OUTPUT CLASSIFIERS
Toxicity · Factuality · Policy · PII Leak
Pass?
Safe Response
or
Fallback

Related

More in System Design

Get full access to all 74+ sections with code examples, diagrams, and interactive animations.

Unlock Premium