NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Llama Guard 3-1B-INT4: Compact and Efficient Safeguard for Human-AI Conversations

Igor Fedorov, Kate Plawiak, Lemeng Wu, Tarek Elgamal, Naveen Suda, Eric Smith, Hongyuan Zhan, Jianfeng Chi, Yuriy Hulovatyy, Kimish Patel, Zechun Liu, Changsheng Zhao, Yangyang Shi, Tijmen Blankevoort, Mahesh Pasupuleti, Bilge Soran, Zacharie Delpierre Coudert, Rachad Alao, Raghuraman Krishnamoorthi, Vikas ChandraarXiv 2024

Abstract

This paper presents Llama Guard 3-1B-INT4, a compact and efficient Llama Guard model, which has been open-sourced to the community during Meta Connect 2024. We demonstrate that Llama Guard 3-1B-INT4 can be deployed on resource-constrained devices, achieving a throughput of at least 30 tokens per second and a time-to-first-token of 2.5 seconds or less on a commodity Android mobile CPU. Notably, our experiments show that Llama Guard 3-1B-INT4 attains comparable or superior safety moderation scores to its larger counterpart, Llama Guard 3-1B, despite being approximately 7 times smaller in size (440MB).

Introduction

As Generative AI shifts from large-scale data centers to on-device applications, maintaining safety standards is a critical requirement. Standard safety protocols involve pairing a generative Large Language Model (LLM) with a "guard" model to filter unsafe inputs and outputs. However, existing 1B-parameter guard models often exceed the memory (DRAM) limitations of mobile hardware, where operating systems frequently throttle or terminate applications with high memory footprints. To address this, Llama Guard 3-1B-INT4 was developed to provide a significantly smaller and faster safety solution without compromising the ability to detect nuanced policy violations.

Methods

The development of Llama Guard 3-1B-INT4 involved a multi-stage compression pipeline designed to shrink the Llama 3.2 1B model from its original 2.8GB size to a mobile-friendly 440MB.

The multi-stage compression pipeline showing the reduction in model size from 2.8GB to 0.4GB.
  1. Pruning: The architecture was streamlined by reducing decoder blocks from 16 to 12 and narrowing the MLP hidden dimension. A sensitivity analysis using cosine similarity helped identify components with the lowest contribution to final performance.
  2. Quantization-Aware Training (QAT): Rather than post-training quantization, the model underwent fine-tuning with 4-bit per-channel weight quantization and 8-bit dynamic activation quantization integrated into the training loop.
  3. Unembedding Layer Pruning: Since Llama Guard only requires a small set of output tokens (e.g., "safe," "unsafe"), the output layer was pruned from 128,000 tokens to approximately 20, saving 131MB of space.
  4. Knowledge Distillation: To mitigate accuracy loss from compression, Llama Guard 3-8B served as a teacher model, guiding the smaller student model to replicate its output distributions.
  5. Deployment: The model is optimized for the ExecuTorch runtime using the XNNPACK backend, enabling efficient 4-bit inference on ARM CPUs.

Evaluation and Results

Performance was evaluated using an internal test dataset based on the MLCommons (2024) hazard taxonomy, comparing the INT4 model against Llama Guard 3-1B, 3-8B, and GPT-4.

A comparison of F1 scores and False Positive Rates (FPR) across multiple languages for Llama Guard variants and GPT-4.

Key Findings

  • Efficiency: The model achieved a throughput of ≥ 30 tokens per second on a commodity Android mobile CPU (Moto-Razor), with a time-to-first-token of ≤ 2.5 seconds.
  • Accuracy: Surprisingly, the 1B-INT4 model outperformed the uncompressed 1B model on English safety benchmarks. This suggests that the combination of distillation and QAT may serve as an effective form of regularization.
  • Multilingual Performance: The model remained competitive in 5 out of 8 non-English languages and significantly outperformed zero-shot GPT-4 in safety moderation tasks across nearly all tested languages.

Conclusion

Llama Guard 3-1B-INT4 demonstrates that extreme model compression can be achieved without sacrificing safety performance. By leveraging task-specific optimizations like unembedding pruning and knowledge distillation, it is possible to bring robust AI safety to resource-constrained edge devices. Future work will focus on closing knowledge gaps in complex categories like Intellectual Property and enhancing resilience against sophisticated adversarial prompt injections.

Summary updated

BibTeX
@misc{fedorov2024llama,
  author = {Igor Fedorov and Kate Plawiak and Lemeng Wu and Tarek Elgamal and Naveen Suda and Eric Smith and Hongyuan Zhan and Jianfeng Chi and Yuriy Hulovatyy and Kimish Patel and Zechun Liu and Changsheng Zhao and Yangyang Shi and Tijmen Blankevoort and Mahesh Pasupuleti and Bilge Soran and Zacharie Delpierre Coudert and Rachad Alao and Raghuraman Krishnamoorthi and Vikas Chandra},
  title = {{Llama Guard 3-1B-INT4: Compact and Efficient Safeguard for Human-AI Conversations}},
  year = {2024},
  eprint = {2411.17713},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2411.17713},
}
Figure