Glossary

TechnologyEvaluation & Safety

Guardrails

At a glance

Input/output filters that block unsafe, off-topic, or policy-violating content.

Who this is for
Engineers and technical readers learning the terms used in AI systems.
Topics
  • Evaluation & Safety
  • Technology

A model will, given the wrong prompt, leak personal data, drift into topics you never sanctioned, or repeat something toxic back to a customer. Guardrails are the checks you wrap around the model to catch that before it does damage. They run outside the model's own judgment, as separate filters on the way in and the way out, so a single clever prompt cannot talk its way past the rules. The mental model: deterministic controls layered onto a probabilistic system. The model is the engine; the rails are the crash barriers, and they belong to you, not to it.

Input rails and output rails#

Guardrails come in two positions, and the distinction matters because they defend against different failures. Input rails inspect the user's request before it reaches the model: detecting jailbreak and prompt injection attempts, enforcing topic limits ("this assistant does not discuss pricing exceptions"), and masking sensitive data so it never enters the prompt, the KV cache, or your logs. Output rails inspect the model's response before it reaches the user: moderating toxic or unsafe content, redacting any PII the model produced on its own, and validating the answer against policy or schema.

Walk through a bank support assistant. A customer pastes their full card number into a chat message. The input rail recognizes the 16-digit pattern, replaces it with a placeholder token, and only then forwards the prompt; the raw number never touches the model or the trace store. On the way back, the model drifts into informal investment advice, which the bank's policy forbids. The output rail's topic classifier flags it, suppresses the draft, and returns a scripted handoff to a licensed human instead. Either rail can halt the flow; the user sees a safe refusal rather than the violation.

injection check,PII masking, topic limitsmoderation, PII redaction,policy checkrequestinput guardmodeloutput guarduserblock: safe refusalblock, redact, or rewrite

What actually runs inside a rail#

A rail is a pipeline of checks, and they span three cost tiers. The cheap tier is regex and deny-lists: card numbers, known exploit strings, banned terms. These run in microseconds and catch the obvious cases. The middle tier is dedicated classifiers, small models trained to label content against a harm taxonomy; expect tens of milliseconds on a GPU. The heavy tier is an LLM-as-judge evaluating nuanced policy ("is this response giving regulated financial advice?"), which costs hundreds of milliseconds and real tokens per call.

Latency budgeting is the engineering problem. Input rails sit in series before generation, so every millisecond adds directly to time to first token. The common production pattern: run cheap checks sequentially, run the heavier classifier in parallel with generation and cancel the stream if it flags, and buffer streamed output in sentence-sized chunks so the output rail can gate it without forcing the user to wait for the full response.

The tooling in 2026#

Three names dominate, and they occupy different layers. Llama Guard 4 (Meta, April 2025) is a safety classifier: a 12-billion-parameter multimodal model pruned from Llama 4 Scout that labels prompts and responses against the 14-category MLCommons hazard taxonomy and runs on a single 24 GB GPU. Its siblings, Llama Prompt Guard 2 at 86M and 22M parameters, are fast first-pass gates for injection and jailbreak patterns. NVIDIA NeMo Guardrails (v0.22.0 as of May 2026) is an orchestration toolkit: you declare programmable rails, topic boundaries, and dialog policies, and it wires classifiers like Llama Guard into an ordered flow around your model. Guardrails AI (the open-source framework, v0.10.2 as of June 2026) takes a validator approach: composable checks from its Hub covering toxicity, PII, grounding against retrieved context in RAG systems, and schema validation for structured output. For PII specifically, Microsoft Presidio is the standard open-source detector and redactor, combining named-entity recognition with regex and checksums.

The practical stack composes all of these rather than picking one: a 22M-parameter gate first, Presidio for masking, Llama Guard behind it, domain validators on the output, with an orchestrator holding the policy.

Fail closed#

The most important design decision is invisible in the happy path: what happens when a guardrail itself errors or times out? Many implementations quietly pass the request through, choosing availability over safety. That choice converts the guard into decoration, because adverse conditions are exactly when it must hold; an attacker who notices that a 300 ms classifier timeout means "skip the check" will simply send inputs crafted to be slow. Run the math: at 99.9 percent guard availability and a million requests a day, fail-open waves roughly a thousand unchecked requests through daily.

Default to fail-closed: on guard error, block or route to a fallback such as a cached safe response or human escalation. Accept the cost, which is false positives. A rail tuned to block 99 percent of violations will also catch some legitimate requests, so measure both sides: track the block rate and sample blocked traffic for review, just as you track answer quality with evals.

What guardrails cannot do#

Guardrails are pattern matchers with their own failure rates, not a substitute for a well-aligned model or a hardened prompt. A determined adversary treats the rail as one more layer to break, and classifiers can be evaded by the same obfuscation tricks that fool models. So treat rails as one layer in defense in depth: model-level safety training underneath, prompt hardening alongside, red-teaming to measure how often the whole stack actually holds, and observability so every block and every bypass lands in a trace you can audit. The OWASP LLM Top 10 is the standard checklist for which risks the layers must cover.

Practical takeaways#

Put rails on both sides of the model; input and output failures are different attacks. Mask PII before it enters the prompt, not after. Compose cheap gates, classifiers, and validators instead of betting on one check, and budget their latency explicitly. Fail closed and instrument the false-positive cost. Then verify the whole assembly adversarially, because a guardrail only counts if it holds when something goes wrong.

Let's build something that ships.

Tell us what you're building. We'll tell you whether you need an engineer embedded or the whole build led, what's achievable, and where the real bottlenecks are.

Reply within 2h

We store your name, email, company, and message, and email a copy to hello@bigcircle.ai. Read the privacy page and the terms.