llamaguard

Classifies LLM inputs and outputs into six safety categories using Meta's LlamaGuard moderation model.

13.0k|930|Updated Nov 3, 2025
One-click install
npx skills add https://github.com/Orchestra-Research/AI-research-SKILLs --skill llamaguard-orchestra-research
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: llamaguard
Source: https://github.com/Orchestra-Research/AI-research-SKILLs/tree/main/07-safety-alignment/llamaguard
Command: npx skills add https://github.com/Orchestra-Research/AI-research-SKILLs --skill llamaguard-orchestra-research

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires transformers, torch, vllm, and includes references (resource) components.

What problem does it solve? LLM applications need automated content moderation to block unsafe user prompts and filter harmful model responses before they reach end users, without building a classifier from scratch. ## Core Features & Use Cases - Input and Output Filtering: Classifies user prompts and assistant responses as safe or unsafe across six categories (violence/hate, sexual content, weapons, substances, self-harm, criminal planning) with 94-95% accuracy. - Production Deployment: Serves moderation via vLLM for 50-100 requests/sec on a single A100, or exposes a FastAPI endpoint for HTTP-based moderation. - Guardrails Integration: Registers LlamaGuard checks as input/output rails inside NVIDIA NeMo Guardrails pipelines. - Use Case: A chat application checks each user message with LlamaGuard before sending it to the main LLM, and blocks responses flagged as unsafe with a category code like S6. ## Quick Start Use the llamaguard skill to moderate this conversation and tell me whether the user message is safe and which safety category applies if not.

Frequently Asked Questions about llamaguard

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I moderate LLM inputs with LlamaGuard?▼

Load meta-llama/LlamaGuard-7b with transformers, apply the chat template to the user message, and generate a classification. The output starts with "safe" or "unsafe" followed by a category code like S3 for weapons.

What safety categories does LlamaGuard detect?▼

LlamaGuard classifies content into six categories: S1 Violence & Hate, S2 Sexual Content, S3 Guns & Illegal Weapons, S4 Regulated Substances, S5 Suicide & Self-Harm, and S6 Criminal Planning.

LlamaGuard vs OpenAI Moderation API, which should I use?▼

Use LlamaGuard when you need self-hosted moderation with detailed safety categories and have GPU resources. Use the OpenAI Moderation API for a simpler API-based option without infrastructure management.

Does LlamaGuard work with vLLM for faster inference?▼

Yes, vLLM reduces latency from 300-500ms to 50-100ms per request and supports batching for 20-50ms per request. It achieves roughly 50-100 requests per second on a single A100 GPU.

Why do I get model access denied for LlamaGuard on HuggingFace?▼

LlamaGuard is a gated Meta model requiring authentication. Run huggingface-cli login with your token and accept the license on the model page before downloading.

How do I reduce LlamaGuard GPU memory usage?▼

Apply 8-bit quantization with BitsAndBytesConfig to cut VRAM from 14GB to 7GB, or use INT4 quantization for around 4GB. Tensor parallelism across multiple GPUs also distributes the load.