Guardrails

Guardrails are controls placed around an AI model that check its inputs, outputs or actions against rules, blocking or changing anything that breaks them, separately from whatever safety behaviour the model learned in training.

A language model learns some safety behaviour during training, but that behaviour is probabilistic and can be talked around. Guardrails add checks outside the model. An input guardrail inspects what the user sends before the model sees it, looking for things like jailbreak attempts or personal data. An output guardrail inspects the model's reply before the user sees it. Newer systems also check an agent's tool calls before they run.

NVIDIA's NeMo Guardrails, described in a paper first posted in October 2023, is a well-known open-source example. Developers write "rails" that apply at different stages: input rails, dialog rails that keep a conversation on approved paths, retrieval rails that filter documents pulled in for an answer, execution rails for tool calls, and output rails. The rules sit outside the model, so the same guardrails can wrap models from different providers.

Many guardrails are themselves AI models. Llama Guard, released in December 2023, is a Llama 2 model fine-tuned to classify both user prompts and model responses against a taxonomy of safety risks; its developers released the weights so others could run it. Commercial cloud platforms offer similar filters as a service. A typical customer service bot might use one classifier to block abusive or off-topic requests, a second to stop the bot quoting account numbers, and a hard-coded rule that refuses to discuss competitors.

Guardrails are a layer, not a guarantee. They can be bypassed by the same tricks that defeat a model's training, and strict ones block legitimate requests, which users experience as over-refusal. Every extra check also adds delay and cost. OWASP's guidance on prompt injection recommends filtering inputs and outputs as one of several measures, alongside limiting what the model can access and requiring human approval for risky actions.

In news coverage the word is also used loosely for any rules on AI, including laws and company policies, as in calls for "guardrails on AI". In technical writing it usually means these runtime checks.

Common questions

What are AI guardrails?

AI guardrails are checks that sit around a model and inspect what goes in and what comes out, blocking or altering content that breaks set rules. They can catch things like jailbreak attempts, toxic replies, leaks of personal data or off-topic answers. They work alongside, not instead of, the safety training built into the model.

How do LLM guardrails work?

Most combine simple rules, such as keyword or format checks, with classifier models that score text for categories of risk. Input checks run before the prompt reaches the model and output checks run on its reply. Tools such as NeMo Guardrails let developers define these checks in configuration files, and classifiers such as Llama Guard can be used as one of the checks.

Can guardrails be bypassed?

Yes. Determined users can sometimes phrase requests in ways the checks do not recognise, and classifier guardrails make mistakes in both directions. That is why security guidance treats guardrails as one layer among several, alongside limiting what a model can access and keeping humans in charge of high-risk actions.

What is the difference between guardrails and alignment?

Alignment work tries to shape the model itself so it wants to behave as intended, mainly through training. Guardrails are external checks applied when the model runs, whatever the model has learned. A well-built system usually uses both.

Finding more

Search for "LLM guardrails", "NeMo Guardrails", "Llama Guard" or "input and output filtering for LLMs" to see how the checks are built. Reliable sources include the original research papers on arXiv, documentation from open-source guardrail projects and cloud providers, and security guidance from OWASP and national cyber agencies. Treat vendor claims of near-perfect blocking rates with care and look for independent tests against current jailbreak techniques.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.