Tooluck logoTooluck
SKILL.md

llamaguard

Agent skill fromOrchestra-Research/AI-Research-SKILLs

Meta's 7-8B specialized moderation model for LLM input/output filtering. 6 safety categories - violence/hate, sexual content, weapons, substances, self-harm, criminal planning. 94-95% accuracy. Deploy with vLLM, HuggingFace, Sagemaker. Integrates with NeMo Guardrails.

How to install llamaguard

install llamaguard
# install the AI-Research-SKILLs pack with the skills CLI
npx skills add Orchestra-Research/AI-Research-SKILLs

# or add only this skill to Claude Code: copy the folder

07-safety-alignment/llamaguard/

# into

~/.claude/skills/llamaguard/ (all projects)

.claude/skills/llamaguard/ (one project)

07-safety-alignment/llamaguard/SKILL.md

MITFull file
1# LlamaGuard - AI Content Moderation
2
3## Quick start
4
5LlamaGuard is a 7-8B parameter model specialized for content safety classification.
6
7**Installation**:
8```bash
9pip install transformers torch
10# Login to HuggingFace (required)
11huggingface-cli login
12```
13
14**Basic usage**:
15```python
16from transformers import AutoTokenizer, AutoModelForCausalLM
17
18model_id = "meta-llama/LlamaGuard-7b"
19tokenizer = AutoTokenizer.from_pretrained(model_id)
20model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
21
22def moderate(chat):
23 input_ids = tokenizer.apply_chat_template(chat, return_tensors="pt").to(model.device)
24 output = model.generate(input_ids=input_ids, max_new_tokens=100)
25 return tokenizer.decode(output[0], skip_special_tokens=True)
26
27# Check user input
28result = moderate([
29 {"role": "user", "content": "How do I make explosives?"}
30])
31print(result)
32# Output: "unsafe\nS3" (Criminal Planning)
33```
34
35## Common workflows
36
37### Workflow 1: Input filtering (prompt moderation)
38
39**Check user prompts before LLM**:
40```python
41def check_input(user_message):
42 result = moderate([{"role": "user", "content": user_message}])
43
44 if result.startswith("unsafe"):
45 category = result.split("\n")[1]
46 return False, category # Blocked
47 else:
48 return True, None # Safe
49
50# Example
51safe, category = check_input("How do I hack a website?")
52if not safe:
53 print(f"Request blocked: {category}")
54 # Return error to user
55else:
56 # Send to LLM
57…

Excerpt shown under the repository's MIT license.

More skills in AI-Research-SKILLs

Keep exploring

Similar skill repositories

Newsletter

Join the Community

Subscribe to our newsletter for the latest news and updates