Defending LLMs with Guardrails
Defensive scope: This skill describes runtime defenses for production LLM applications. The example jailbreak/injection payloads exist only to validate that guardrails block them. Test against systems you own or are authorized to assess.
Overview
Large language model (LLM) applications are exposed to adversarial input (jailbreaks, prompt injection, toxic content) and can emit unsafe, biased, or sensitive output. A guardrail is a runtime control that inspects and constrains the data flowing into and out of an LLM. Three production-grade, open-source guardrail systems dominate the ecosystem and are complementary rather than mutually exclusive:
- Llama Guard 3 (Meta) — a Llama-3.1-8B model fine-tuned as a safety classifier. Given a prompt or a response, it emits
safeorunsafeplus the violated MLCommons hazard categories (S1–S14). It is the strongest semantic content-safety classifier of the three and supports prompt classification, response classification, and tool-call/code-interpreter classification across 8 languages. - NeMo Guardrails (NVIDIA) — a programmable dialogue-rail framework. You define
input,output, `…