Local LLM guardrails compared (October 2026)

Llama Guard, Prompt Guard, NeMo Guardrails, guardrails-ai, and llm-guard: a feature-by-feature comparison of options for adding guardrails to a self-hosted LLM.

Updated November 1, 2026

Anyone running a self-hosted LLM eventually has to decide what it is allowed to say, and what to do when a prompt is malicious or off-topic. Cloud providers resolve this for you; on a self-hosted stack it is your problem. The open-source ecosystem now offers five approaches: purpose-built classifier models (Llama Guard, Llama Prompt Guard), programmable policy engines (NeMo Guardrails, guardrails-ai), and a filter pipeline of pre-trained detectors (ProtectAI llm-guard). They are not interchangeable, the trade-offs are specific, and the licence terms move quickly.

What “guardrails” actually means at a self-hosted LLM

A guardrail is anything that sits between the user prompt and the model’s response, or between the response and the caller. The NeMo Guardrails README defines five main types of guardrails, starting with these two:

“Input rails: applied to the input from the user; an input rail can reject the input, stopping any additional processing, or alter the input (e.g., to mask potentially sensitive data, to rephrase).” “Output rails: applied to the output generated by the LLM; an output rail can reject the output, preventing it from being returned to the user, or alter it (e.g., removing sensitive data).”

NeMo also names three more: dialog rails (steer the conversation itself), retrieval rails (filter RAG chunks), and execution rails (filter tool calls and their results). For a plain chat setup, input and output rails are the core of it, and a classifier such as Llama Guard can check both without a separate framework.

The Llama Guard family: classifiers you can run alongside your model

Meta publishes five safety checkpoints across three model lines on Hugging Face, all under the meta-llama org and all gated: manual (you must accept the licence on HF before downloading). The Hugging Face API’s safetensors.total field is a parameter count, not a byte count; weight sizes below are computed from it at the published precision:

ModelParameters (HF safetensors.total) and weight sizecardData.license / license_nameRoleLast modified
Llama-Guard-3-1B1,498,482,688 params; BF16, about 3.0 GB (2.79 GiB)llama3.2, gated manualPrompt and response classifier (13 hazard categories)2024-09-26
Llama-Guard-3-8B8,030,261,248 params; BF16, about 16.1 GB (14.96 GiB)llama3.1, gated manualPrompt and response classifier (14 categories, adds Code Interpreter Abuse)2024-10-11
Llama-Guard-4-12B12,001,097,216 params; BF16, about 24.0 GB (22.35 GiB)other / llama4, gated manualMultimodal (text and image) prompt and response classifier2025-04-29
Llama-Prompt-Guard-2-86M278,810,882 params; F32, about 1.12 GB (1.04 GiB)other / llama4, gated manualInput-side jailbreak / injection classifier2025-04-29
Llama-Prompt-Guard-2-22M70,830,722 params; F32, about 283 MB (270 MiB)other / llama4, gated manualInput-side, smaller variant2025-04-29

Prompt Guard and Llama Guard do different jobs. Prompt Guard 2 is a small classifier (named 86M and 22M; Hugging Face reports 278.8M and 70.8M parameters in total) that labels an incoming prompt “benign” or “malicious”, covering both prompt injection and jailbreaks. The Llama Guard 3 and 4 models classify both prompts and responses: each generates text saying whether the content is safe or unsafe and, if unsafe, which hazard categories it violates (13 on Llama Guard 3 1B, 14 on the 8B, among them S1 Violent Crimes, S11 Suicide & Self-Harm and S12 Sexual Content).

The catch: every checkpoint in this family is under a Meta Llama community licence, not Apache or MIT. The Llama 4 licence (which Llama-Guard-4-12B and Prompt Guard 2 carry via license_name: llama4) requires a separate licence from Meta only above 700 million monthly active users, but its other terms apply to everyone, including adherence to Meta’s Acceptable Use Policy and prominently displaying “Built with Llama” when redistributing. The Hugging Face cardData.license: other flag is your signal to read the upstream LICENSE file before shipping.

Programmable engines vs filter pipelines

The non-classifier paths are very different animals. Their GitHub metadata, fetched on 2026-11-01:

ProjectStarsForksOpen issuesLicense (spdx_id)Last pushArchived?
NVIDIA-NeMo/Guardrails7,404890278NOASSERTION (the GitHub API returns “Other” - see repo LICENSE)2026-10-30No
guardrails-ai/guardrails7,57673057Apache-2.02026-10-31No
protectai/llm-guard3,22047237MIT2026-07-08Yes

NeMo Guardrails is a programmable toolkit: a YAML configuration plus Colang flows describe which rails run and how the conversation may go. The README names built-in features such as jailbreak_detection, content_safety and topic_safety, and it can run as a library, an API server or a CLI server. It is the most flexible of the three and the most involved to configure; rails that prompt an LLM add model calls to each turn.

guardrails-ai takes a validator-first approach: its README describes Input/Output Guards built from validators, many of them pre-built in Guardrails Hub, and a second job of generating structured data from LLMs. The README examples combine validators such as RegexMatch, CompetitorCheck and ToxicLanguage, each with an on_fail action such as raising an exception. A 6 July 2026 notice says validators are moving to standard PyPI packages and that the project is discontinuing its hosted remote inferencing, with a planned cutoff of 25 August 2026. Apache-2.0, with fewer open issues than NeMo.

ProtectAI’s llm-guard is a different shape: a set of prompt scanners and output scanners (among them Anonymize, BanTopics, PromptInjection, Secrets and Toxicity) run on the request and the response. The GitHub API returns "archived": true with a last push on 2026-07-08, and the README now opens with a warning that the project and its Hugging Face models “are no longer under active development or maintained.” The code is MIT-licensed and still installable, but it is not a default choice for new deployments.

When the guard itself is “local” and when it isn’t

Four hosting patterns come up in practice, and all four keep every byte on your machine:

  • Model + classifier on the same box. Llama Guard 3 1B (BF16) and Prompt Guard 2 86M (F32) together are about 4.1 GB (3.83 GiB) of weights at their published precisions, before any quantisation, so they need to be budgeted against the main model’s memory. Llama Guard 4 12B, at about 24 GB in BF16, is too large to load side-by-side with a 70B-class model on a single consumer card.
  • Classifier as a separate HTTP service. Run the guard on a different port (llama-server --port 8081) or container; your application calls it before and after the main LLM.
  • Filter pipeline as a service. llm-guard can be deployed as an API, which its README links a guide for, so scans sit between your app and the LLM.
  • Programmable engine in-process. NeMo Guardrails and guardrails-ai run as Python libraries inside your application (NeMo can also run as its own server). Cloud moderation endpoints like /v1/moderations are out of scope for this page.

Self-host-specific catches that are easy to miss

Three things only bite you on a self-hosted setup:

  1. Latency compounds. A chain of input classifier + main LLM + output classifier adds a full classifier pass before the first token and another after the response. Drop the input classifier if you only need output moderation.
  2. The classifier is itself a model you operate. Llama Guard 3 8B in BF16 is about 16 GB of weights alone; Llama Guard 4 12B is about 24 GB. Running one alongside a 32B-class reasoning model is not practical on a single card.
  3. Gated weights are a deployment gotcha. gated: manual on HF means your container needs an HF token at build time. Once downloaded, weights serve without that token, but air-gapped installs need pre-downloaded mirrors - a separate workflow from Ollama’s default pull.

One misconfiguration to avoid: routing the model’s output through Llama Guard and then sending the Guard’s verdict back through the same model for a “polite rewrite”. The guard is a classifier, not a rewriter - send its verdict to your application code, not back into the LLM.

The Bottom line

Pick by what you actually need:

  • One classifier, no framework. Llama Guard 3 1B on the output, Prompt Guard 2 86M on the input, about 4.1 GB of weights together at published precision. Both are gated on Hugging Face.
  • Programmable topic and tone controls. NeMo Guardrails, accepting the cost of a second LLM call per turn. Note the repo migrated from NVIDIA/NeMo-Guardrails to NVIDIA-NeMo/Guardrails (the GitHub API URL must point at the new location).
  • Structured-output validation around an existing model. guardrails-ai, Apache-2.0, lower open-issue count than NeMo.
  • Scanner pipeline (PII anonymisation, banned topics, prompt-injection detection). llm-guard, MIT, but archived and no longer maintained upstream; treat it as frozen code.

There is no single “best” guardrail. The safe move is to name the role (input vs output vs topic vs structure) before picking the tool.