Papers
Topics
Authors
Recent
Search
2000 character limit reached

LLaMA Guard 3 Safety Framework

Updated 16 January 2026
  • LLaMA Guard 3 is a safety guard architecture for LLMs that leverages Llama 3 backbones to filter inputs and outputs, mitigating unsafe prompt injections across diverse applications.
  • It employs multiclass hazard detection, quantization, and LoRA-based fine-tuning to balance performance and compliance in both datacenter-scale and mobile deployments.
  • The framework supports multilingual and multimodal moderation through tailored datasets, vision-enabled variants, and rigorous empirical benchmarks to optimize inference accuracy.

LLaMA Guard 3 is a system-level safety guard architecture released by Meta for safeguarding LLMs in interactive and agentic applications. Built exclusively atop Llama 3 model backbones, Guard 3 encompasses a family of models—including text-only, multilingual, on-device compressed, and vision-enabled variants—deployed as input/output filters to mitigate unsafe prompt injection, restrict model outputs, and provide robust moderation across languages and modalities. Distinct models and datasets within the ecosystem are tailored to deployment constraints ranging from datacenter-scale to resource-limited mobile devices. Guard 3 models consistently implement multiclass hazard detection, adversarial robustness techniques, and pipelined gating logic, calibrated to minimize both violation rates and false refusals in regulatory and open environments.

1. System Architecture and Variant Landscape

LLaMA Guard 3's canonical architecture consists of an Input Guard and Output Guard, both implemented as classifiers on top of Llama 3 (8B) transformer backbones with an appended two-layer feedforward head (~20M parameters) for safety signal extraction. In deployment, the safety wrapper is interposed between the user and Llama 3 core, mediating both prompts and outputs:

  • User Prompt → Input Guard → Llama 3 → Output Guard → Final Response

Quantized versions use 8-bit weights for low-latency inference. Multimodal extensions (Llama Guard 3 Vision) use the Llama 3.2-Vision 11B backbone with a convolutional vision encoder, patch-wise visual embedding, and a joint vision-text decoder with cross-attention for fusion. Output token space in compressed ("INT4") variants is pruned to 20 moderation tokens, supporting classification of "safe", "unsafe", and hazard categories.

On-device models, exemplified by Llama Guard 3-1B-INT4, leverage block- and neuron-wise structured pruning (reducing layers from 16 to 12 and MLP neurons from 8,192 to 6,400), quantization-aware training (INT4 weights, INT8 activations), groupwise post-hoc embedding quantization, and heavy output-vocabulary pruning, resulting in sub-500 MB footprints with negligible loss in accuracy (Fedorov et al., 2024).

2. Training Methodology and Data Curation

LLaMA Guard 3 text models are trained via supervised cross-entropy on synthetic and human-annotated (prompt, response) pairs labeled as safe/unsafe across a broad taxonomy of 13 MLCommons risk categories and tool-abuse scenarios. Data sources include Llama Guard 2 English datasets (~200k), multilingual sets (German, French, Spanish, Italian, Portuguese, Hindi, Thai), tool-function and code-interpreter abuse sets, and adversarially generated model-in-the-loop prompts (Grattafiori et al., 2024). Human annotation and LLM re-labeling are used to regularize border cases.

The "CultureGuard" pipeline [Editor's term] extends this by constructing Nemotron-Content-Safety-Dataset-Multilingual-v1 via:

  • (a) Cultural data segregation using Llama-3.1-Nemotron-70B-Instruct and GPT-4o adjudication (95.32% agreement)
  • (b) Cultural adaptation (Mixtral-8x22B) for localization of idioms, named entities, festivals, and societal markers, preserving original safety profiles
  • (c) Machine translation into Arabic, German, Spanish, French, Hindi, Japanese, Thai, and Chinese (Google Cloud Translation)
  • (d) Back-translation and consistency filtering, along with FAITH filtering for fluency and accuracy

Synthetic jailbreak (adversarial) data is generated, translated, and strictly filtered, yielding over 386,000 samples distributed across nine languages (Joshi et al., 3 Aug 2025).

Fine-tuning combines LoRA-based projection-only adaptation (rank r=8, scaling α=32) with all other parameters frozen. Optimization uses AdamW with linear warmup, cosine decay, and cross-entropy loss; L2 regularization is enforced on the classifier head (Grattafiori et al., 2024).

3. Safety Moderation, Gating Pipelines, and Quantization

Input and Output Guards are sigmoid-based classifiers:

  • Input Guard: punsafein=σ(Winx+bin)p_{\text{unsafe}}^{\text{in}} = \sigma(W_{\text{in}}x + b_{\text{in}}); block if punsafein>Ï„inp_{\text{unsafe}}^{\text{in}} > \tau_{\text{in}}
  • Output Guard: punsafeout=σ(Wouth+bout)p_{\text{unsafe}}^{\text{out}} = \sigma(W_{\text{out}}h + b_{\text{out}}); block if punsafeout>Ï„outp_{\text{unsafe}}^{\text{out}} > \tau_{\text{out}} with typical thresholds Ï„in≈0.50\tau_{\text{in}}\approx 0.50, Ï„out≈0.45\tau_{\text{out}}\approx 0.45, adjusted for Violation Rate (VR) versus False Refusal Rate (FRR).

If a block is triggered, standardized refusals are returned ("I’m sorry, I can’t help with that."). System prompts prevent further unauthorized generation.

On-device quantized variants utilize channelwise INT4 weight quantization (group size 256), INT8 activations, and straight-through estimation for gradient flow. Embedding quantization (group size 32) is performed post-hoc (Fedorov et al., 2024).

Unembedding (output layer) sparsity reduces 128k-token softmax to ~20 moderation tokens, substantially lowering memory footprint and computation.

4. Multilingual and Multimodal Moderation

Guard 3 supports English and seven major non-English languages. In multilingual benchmarks, models trained solely on English (e.g., Nemotron-Safety-Guard-V2) see sharp F1 drops when tested on low-resource languages such as Hindi and Japanese, with score declines up to 30 percentage points. Only specific models employing cultural adaptation, like CultureGuard, approach parity across languages (e.g., harmful-F1 average 82.37; +30.2% vs. English-only, +1.3% vs. PolyGuard-Qwen trained on much larger datasets) (Joshi et al., 3 Aug 2025).

Vision-enabled Guard 3 variants (Llama Guard 3 Vision) utilize a patch-based vision encoder (input images are split into four 560×560 patches), joint sequence modeling, and multi-label safety detection over text + image interactions. Classification heads read final hidden representations to predict "safe"/"unsafe" and assign violated hazard codes. Augmentation strategies include random category drop, index shuffling, and dummy images for format-agnostic training (Chi et al., 2024).

5. Empirical Benchmarks, Performance, and Trade-Offs

LLaMA Guard 3 models are evaluated primarily using Violation Rate (VR), False Refusal Rate (FRR), F1 (overall and on harmful class), and False Positive Rate (FPR) across benchmark sets:

  • Internal benchmarks span 4,000 prompts in 13+ hazard categories and tool/code interpreter abuse cases.
  • Category-specific VR reductions of 86–100% are observed in categories such as Defamation, Hate, and Sex Content using both input and output guards (Grattafiori et al., 2024).
  • CultureGuard (Llama-3.1-Nemotron-Safety-Guard-Multilingual-8B-v1) achieves harmful-F1 of 82.37 on five multilingual benchmarks, outperforming models trained on larger datasets and establishing commercial-use openness (Joshi et al., 3 Aug 2025).

Table: F1 / FPR scores for Llama Guard 3 text-only variants (excerpt from (Fedorov et al., 2024)):

Model English F1 / FPR Hindi F1 / FPR Size (GB)
Llama Guard 3-8B 0.939 / 0.040 0.871 / 0.050 14.9
Llama Guard 3-1B 0.899 / 0.090 0.815 / 0.088 2.8
Llama Guard 3-1B-INT4 0.904 / 0.084 0.782 / 0.104 0.4
GPT-4 (zero-shot) 0.805 / 0.152 0.709 / 0.206 —

Llama Guard 3-1B-INT4, despite a 7× reduction in size compared to its fp16 counterpart, consistently matches or slightly outperforms in English F1 (+0.5pp), with comparable performance in most other languages and real-time throughput (≥30 tokens/s, ≤2.5s TTFT) on mobile CPUs.

Llama Guard 3 Vision evaluation on MLCommons taxonomy indicates precision, recall, and F1 for prompt/response classification (F1 = 0.733/0.938; FPR = 0.052/0.016), sharply outperforming GPT-4o zero-shot baselines (Chi et al., 2024). Image and text adversarial attacks reveal greater robustness in response-level classification compared to prompt-level, supporting a dual-guard deployment strategy.

6. Limitations, Threat Models, and Future Research

Known failure modes include sophisticated multi-turn jailbreaks, prompt injections hidden in retrieved non-user text, and reduced performance on covert, culturally encoded attacks in low-resource languages. High thresholds for safety detection increase false refusals in ambiguous contexts.

Limitations in pretraining restrict coverage for categories like defamation, intellectual property, and election-related harms without external knowledge integration. Adversarial vulnerability (prompt-injection, GCG attacks) remains a challenge for both text and multimodal variants.

Planned and suggested future work:

  • Integration of retrieval/knowledge augmentation pipelines for fact-sensitive hazard detection.
  • Extension of hazard taxonomy and better coverage of low-resource languages.
  • Exploration of dynamic, context-aware thresholding and certified defenses against prompt-injection attacks.
  • Expansion to covered risk categories (privacy inference, disinformation) and development of continuous red-teaming workflows for rapid adaptation (Grattafiori et al., 2024, Joshi et al., 3 Aug 2025).

A notable lesson is that a fully synthetic, LLM-driven data pipeline can generate culturally aligned safety data at scale, aiding coverage in low-resource settings without costly human annotation (Joshi et al., 3 Aug 2025).

7. Significance and Deployment Considerations

LLaMA Guard 3 defines the state-of-the-art in open-licensed safety moderation for LLMs at multiple scales. The architecture balances modular input/output filtering, multiclass hazard recognition, aggressive model compression, and multimodal extensibility. Deployments benefit from low latency, quantized variants for edge devices, and robust empirical validation across benchmarks and adversarial scenarios. The Guard 3 framework underscores the increased surface area for unsafe content in multilingual and vision-enabled systems, presenting benchmarked effective mitigations but highlighting ongoing attack vectors and the evolving requirements of safety assurance in LLMs (Grattafiori et al., 2024, Fedorov et al., 2024, Chi et al., 2024, Joshi et al., 3 Aug 2025).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to LLaMA Guard 3.