What problem does it solve?
LlamaGuard helps you prevent unsafe or policy-violating content from entering or leaving your LLM application by classifying both user prompts and model responses across common harm categories.
Core Features & Use Cases
- Input moderation (prompt filtering): Classify a user message before it reaches the main LLM and block or redirect unsafe requests.
- Output moderation (response filtering): Re-check the generated response and suppress or replace unsafe answers before displaying them to users.
- Production deployment options: Run the model with HuggingFace Transformers, accelerate inference with vLLM, and integrate it into NeMo Guardrails workflows.
Use case example: Before answering, an agent asks LlamaGuard to classify a user request about weapons; if flagged, the system blocks the request and returns a safe refusal, instead of passing it to the core model.
Quick Start
Run a single moderation check by loading Meta’s LlamaGuard-7b with HuggingFace Transformers and classifying the chat messages (user input or user+assistant response) to obtain a safe/unsafe label and category.