[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M74YXWT4YN4J0Q0Q2J0ET5QB":3,"skill-same:01M74YXWT4YN4J0Q0Q2J0ET5QB":54},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":35,"ownerHtmlUrl":36,"ownerBlogUrl":37,"ownerDescription":38,"updatedAt":39,"install":40,"resources":53},"01M74YXWT4YN4J0Q0Q2J0ET5QB","llamaguard",null,"Classifies LLM prompts and responses as safe or unsafe using Meta's LlamaGuard (7B v1, 8B v2 and v3) across six categories: violence and hate, sexual content, guns and illegal weapons, regulated substances, suicide and self-harm, and criminal planning. Covers HuggingFace Transformers and vLLM inference, a FastAPI moderation endpoint, Sagemaker deployment, and NeMo Guardrails integration. Use when filtering user prompts before an LLM call, moderating model outputs before display, serving a self-hosted moderation API, or reducing latency and GPU memory of a moderation model with vLLM or quantization. Use when tuning thresholds to cut false positives. For a simpler hosted option, use the OpenAI Moderation API instead.","KalarisLabs\u002Fresearch-agent-skills","KalarisLabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F300878568?v=4","01M74Y7MT23GXXC56VM6TVSXZY","Kalarislabs","01M74Y7MTQM9REXZX4SNXWX95C",132,"MIT","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fllamaguard\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: llamaguard\ndescription: 'Classifies LLM prompts and responses as safe or unsafe using Meta''s LlamaGuard (7B v1, 8B v2 and v3) across six categories: violence and hate, sexual content, guns and illegal weapons, regulated substances, suicide and self-harm, and criminal planning. Covers HuggingFace Transformers and vLLM inference, a FastAPI moderation endpoint, Sagemaker deployment, and NeMo Guardrails integration. Use when filtering user prompts before an LLM call, moderating model outputs before display, serving a self-hosted moderation API, or reducing latency and GPU memory of a moderation model with vLLM or quantization. Use when tuning thresholds to cut false positives. For a simpler hosted option, use the OpenAI Moderation API instead.'\nlicense: MIT\nmetadata:\n  version: 1.0.0\n  category: ml-evaluation-and-safety\n  maintainer: Kalaris Labs\n  tags: Safety Alignment, LlamaGuard, Content Moderation, Meta, Guardrails, Safety Classification, Input Filtering, Output Filtering, AI Safety\n  dependencies: transformers, torch, vllm\n---\n\n# LlamaGuard - AI Content Moderation\n\n## Quick start\n\nLlamaGuard is a 7-8B parameter model specialized for content safety classification.\n\n**Installation**:\n```bash\npip install transformers torch\n# Login to HuggingFace (required)\nhuggingface-cli login\n```\n\n**Basic usage**:\n```python\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n\nmodel_id = \"meta-llama\u002FLlamaGuard-7b\"\ntokenizer = AutoTokenizer.from_pretrained(model_id)\nmodel = AutoModelForCausalLM.from_pretrained(model_id, device_map=\"auto\")\n\ndef moderate(chat):\n    input_ids = tokenizer.apply_chat_template(chat, return_tensors=\"pt\").to(model.device)\n    output = model.generate(input_ids=input_ids, max_new_tokens=100)\n    return tokenizer.decode(output[0], skip_special_tokens=True)\n\n# Check user input\nresult = moderate([\n    {\"role\": \"user\", \"content\": \"How do I make explosives?\"}\n])\nprint(result)\n# Output: \"unsafe\\nS3\" (Criminal Planning)\n```\n\n## Common workflows\n\n### Workflow 1: Input filtering (prompt moderation)\n\n**Check user prompts before LLM**:\n```python\ndef check_input(user_message):\n    result = moderate([{\"role\": \"user\", \"content\": user_message}])\n\n    if result.startswith(\"unsafe\"):\n        category = result.split(\"\\n\")[1]\n        return False, category  # Blocked\n    else:\n        return True, None  # Safe\n\n# Example\nsafe, category = check_input(\"How do I hack a website?\")\nif not safe:\n    print(f\"Request blocked: {category}\")\n    # Return error to user\nelse:\n    # Send to LLM\n    response = llm.generate(user_message)\n```\n\n**Safety categories**:\n- **S1**: Violence & Hate\n- **S2**: Sexual Content\n- **S3**: Guns & Illegal Weapons\n- **S4**: Regulated Substances\n- **S5**: Suicide & Self-Harm\n- **S6**: Criminal Planning\n\n### Workflow 2: Output filtering (response moderation)\n\n**Check LLM responses before showing to user**:\n```python\ndef check_output(user_message, bot_response):\n    conversation = [\n        {\"role\": \"user\", \"content\": user_message},\n        {\"role\": \"assistant\", \"content\": bot_response}\n    ]\n\n    result = moderate(conversation)\n\n    if result.startswith(\"unsafe\"):\n        category = result.split(\"\\n\")[1]\n        return False, category\n    else:\n        return True, None\n\n# Example\nuser_msg = \"Tell me about harmful substances\"\nbot_msg = llm.generate(user_msg)\n\nsafe, category = check_output(user_msg, bot_msg)\nif not safe:\n    print(f\"Response blocked: {category}\")\n    # Return generic response\n    return \"I cannot provide that information.\"\nelse:\n    return bot_msg\n```\n\n### Workflow 3: vLLM deployment (fast inference)\n\n**Production-ready serving**:\n```python\nfrom vllm import LLM, SamplingParams\n\n# Initialize vLLM\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\", tensor_parallel_size=1)\n\n# Sampling params\nsampling_params = SamplingParams(\n    temperature=0.0,  # Deterministic\n    max_tokens=100\n)\n\ndef moderate_vllm(chat):\n    # Format prompt\n    prompt = tokenizer.apply_chat_template(chat, tokenize=False)\n\n    # Generate\n    output = llm.generate([prompt], sampling_params)\n    return output[0].outputs[0].text\n\n# Batch moderation\nchats = [\n    [{\"role\": \"user\", \"content\": \"How to make bombs?\"}],\n    [{\"role\": \"user\", \"content\": \"What's the weather?\"}],\n    [{\"role\": \"user\", \"content\": \"Tell me about drugs\"}]\n]\n\nprompts = [tokenizer.apply_chat_template(c, tokenize=False) for c in chats]\nresults = llm.generate(prompts, sampling_params)\n\nfor i, result in enumerate(results):\n    print(f\"Chat {i}: {result.outputs[0].text}\")\n```\n\n**Throughput**: ~50-100 requests\u002Fsec on single A100\n\n### Workflow 4: API endpoint (FastAPI)\n\n**Serve as moderation API**:\n```python\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom vllm import LLM, SamplingParams\n\napp = FastAPI()\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\")\nsampling_params = SamplingParams(temperature=0.0, max_tokens=100)\n\nclass ModerationRequest(BaseModel):\n    messages: list  # [{\"role\": \"user\", \"content\": \"...\"}]\n\n@app.post(\"\u002Fmoderate\")\ndef moderate_endpoint(request: ModerationRequest):\n    prompt = tokenizer.apply_chat_template(request.messages, tokenize=False)\n    output = llm.generate([prompt], sampling_params)[0]\n\n    result = output.outputs[0].text\n    is_safe = result.startswith(\"safe\")\n    category = None if is_safe else result.split(\"\\n\")[1] if \"\\n\" in result else None\n\n    return {\n        \"safe\": is_safe,\n        \"category\": category,\n        \"full_output\": result\n    }\n\n# Run: uvicorn api:app --host 0.0.0.0 --port 8000\n```\n\n**Usage**:\n```bash\ncurl -X POST http:\u002F\u002Flocalhost:8000\u002Fmoderate \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"messages\": [{\"role\": \"user\", \"content\": \"How to hack?\"}]}'\n\n# Response: {\"safe\": false, \"category\": \"S6\", \"full_output\": \"unsafe\\nS6\"}\n```\n\n### Workflow 5: NeMo Guardrails integration\n\n**Use with NVIDIA Guardrails**:\n```python\nfrom nemoguardrails import RailsConfig, LLMRails\nfrom nemoguardrails.integrations.llama_guard import LlamaGuard\n\n# Configure NeMo Guardrails\nconfig = RailsConfig.from_content(\"\"\"\nmodels:\n  - type: main\n    engine: openai\n    model: gpt-4\n\nrails:\n  input:\n    flows:\n      - llamaguard check input\n  output:\n    flows:\n      - llamaguard check output\n\"\"\")\n\n# Add LlamaGuard integration\nllama_guard = LlamaGuard(model_path=\"meta-llama\u002FLlamaGuard-7b\")\nrails = LLMRails(config)\nrails.register_action(llama_guard.check_input, name=\"llamaguard check input\")\nrails.register_action(llama_guard.check_output, name=\"llamaguard check output\")\n\n# Use with automatic moderation\nresponse = rails.generate(messages=[\n    {\"role\": \"user\", \"content\": \"How do I make weapons?\"}\n])\n# Automatically blocked by LlamaGuard\n```\n\n## When to use vs alternatives\n\n**Use LlamaGuard when**:\n- Need pre-trained moderation model\n- Want high accuracy (94-95%)\n- Have GPU resources (7-8B model)\n- Need detailed safety categories\n- Building production LLM apps\n\n**Model versions**:\n- **LlamaGuard 1** (7B): Original, 6 categories\n- **LlamaGuard 2** (8B): Improved, 6 categories\n- **LlamaGuard 3** (8B): Latest (2024), enhanced\n\n**Use alternatives instead**:\n- **OpenAI Moderation API**: Simpler, API-based, free\n- **Perspective API**: Google's toxicity detection\n- **NeMo Guardrails**: More comprehensive safety framework\n- **Constitutional AI**: Training-time safety\n\n## Common issues\n\n**Issue: Model access denied**\n\nLogin to HuggingFace:\n```bash\nhuggingface-cli login\n# Enter your token\n```\n\nAccept license on model page:\nhttps:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FLlamaGuard-7b\n\n**Issue: High latency (>500ms)**\n\nUse vLLM for 10× speedup:\n```python\nfrom vllm import LLM\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\")\n# Latency: 500ms → 50ms\n```\n\nEnable tensor parallelism:\n```python\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\", tensor_parallel_size=2)\n# 2× faster on 2 GPUs\n```\n\n**Issue: False positives**\n\nUse threshold-based filtering:\n```python\n# Get probability of \"unsafe\" token\nlogits = model(..., return_dict_in_generate=True, output_scores=True)\nunsafe_prob = torch.softmax(logits.scores[0][0], dim=-1)[unsafe_token_id]\n\nif unsafe_prob > 0.9:  # High confidence threshold\n    return \"unsafe\"\nelse:\n    return \"safe\"\n```\n\n**Issue: OOM on GPU**\n\nUse 8-bit quantization:\n```python\nfrom transformers import BitsAndBytesConfig\n\nquantization_config = BitsAndBytesConfig(load_in_8bit=True)\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_id,\n    quantization_config=quantization_config,\n    device_map=\"auto\"\n)\n# Memory: 14GB → 7GB\n```\n\n## Advanced topics\n\n**Custom categories**: See references\u002Fcustom-categories.md for fine-tuning LlamaGuard with domain-specific safety categories.\n\n**Performance benchmarks**: See references\u002Fbenchmarks.md for accuracy comparison with other moderation APIs and latency optimization.\n\n**Deployment guide**: See references\u002Fdeployment.md for Sagemaker, Kubernetes, and scaling strategies.\n\n## Hardware requirements\n\n- **GPU**: NVIDIA T4\u002FA10\u002FA100\n- **VRAM**:\n  - FP16: 14GB (7B model)\n  - INT8: 7GB (quantized)\n  - INT4: 4GB (QLoRA)\n- **CPU**: Possible but slow (10× latency)\n- **Throughput**: 50-100 req\u002Fsec (A100)\n\n**Latency** (single GPU):\n- HuggingFace Transformers: 300-500ms\n- vLLM: 50-100ms\n- Batched (vLLM): 20-50ms per request\n\n## Resources\n\n- HuggingFace:\n  - V1: https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FLlamaGuard-7b\n  - V2: https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-Guard-2-8B\n  - V3: https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-Guard-3-8B\n- Paper: https:\u002F\u002Fai.meta.com\u002Fresearch\u002Fpublications\u002Fllama-guard-llm-based-input-output-safeguard-for-human-ai-conversations\u002F\n- Integration: vLLM, Sagemaker, NeMo Guardrails\n- Accuracy: 94.5% (prompts), 95.3% (responses)\n\n## Agent operating procedure\n\n1. **Check the environment.** Confirm the model, checkpoint, benchmark version and evaluation harness version.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Evaluate on a small subset to verify prompts, parsing and scoring.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Use the benchmark's official splits and metrics; check for contamination; report variance across seeds or prompts.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| Scores differ from published numbers | Check prompt format, few-shot settings and harness version before concluding. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Report evaluation settings in full; never cherry-pick prompts, seeds or subsets.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n\n## Related skills\n\n- `prompt-guard`: Classifies text with Meta's Prompt Guard, an 86M-parameter model loaded from HuggingFace, into BENIGN, INJECTION or JAILBREAK labels to det…\n- `nemo-guardrails`: Adds runtime safety rails to LLM applications with NVIDIA NeMo Guardrails, configured through Colang 2.0 flows.\n- `serving-llms-vllm`: Serves LLMs with high throughput using vLLM's PagedAttention and continuous batching.\n","# LlamaGuard - AI Content Moderation\n\n## Quick start\n\nLlamaGuard is a 7-8B parameter model specialized for content safety classification.\n\n**Installation**:\n```bash\npip install transformers torch\n# Login to HuggingFace (required)\nhuggingface-cli login\n```\n\n**Basic usage**:\n```python\nfrom transformers import AutoTokenizer, AutoModelForCausalLM\n\nmodel_id = \"meta-llama\u002FLlamaGuard-7b\"\ntokenizer = AutoTokenizer.from_pretrained(model_id)\nmodel = AutoModelForCausalLM.from_pretrained(model_id, device_map=\"auto\")\n\ndef moderate(chat):\n    input_ids = tokenizer.apply_chat_template(chat, return_tensors=\"pt\").to(model.device)\n    output = model.generate(input_ids=input_ids, max_new_tokens=100)\n    return tokenizer.decode(output[0], skip_special_tokens=True)\n\n# Check user input\nresult = moderate([\n    {\"role\": \"user\", \"content\": \"How do I make explosives?\"}\n])\nprint(result)\n# Output: \"unsafe\\nS3\" (Criminal Planning)\n```\n\n## Common workflows\n\n### Workflow 1: Input filtering (prompt moderation)\n\n**Check user prompts before LLM**:\n```python\ndef check_input(user_message):\n    result = moderate([{\"role\": \"user\", \"content\": user_message}])\n\n    if result.startswith(\"unsafe\"):\n        category = result.split(\"\\n\")[1]\n        return False, category  # Blocked\n    else:\n        return True, None  # Safe\n\n# Example\nsafe, category = check_input(\"How do I hack a website?\")\nif not safe:\n    print(f\"Request blocked: {category}\")\n    # Return error to user\nelse:\n    # Send to LLM\n    response = llm.generate(user_message)\n```\n\n**Safety categories**:\n- **S1**: Violence & Hate\n- **S2**: Sexual Content\n- **S3**: Guns & Illegal Weapons\n- **S4**: Regulated Substances\n- **S5**: Suicide & Self-Harm\n- **S6**: Criminal Planning\n\n### Workflow 2: Output filtering (response moderation)\n\n**Check LLM responses before showing to user**:\n```python\ndef check_output(user_message, bot_response):\n    conversation = [\n        {\"role\": \"user\", \"content\": user_message},\n        {\"role\": \"assistant\", \"content\": bot_response}\n    ]\n\n    result = moderate(conversation)\n\n    if result.startswith(\"unsafe\"):\n        category = result.split(\"\\n\")[1]\n        return False, category\n    else:\n        return True, None\n\n# Example\nuser_msg = \"Tell me about harmful substances\"\nbot_msg = llm.generate(user_msg)\n\nsafe, category = check_output(user_msg, bot_msg)\nif not safe:\n    print(f\"Response blocked: {category}\")\n    # Return generic response\n    return \"I cannot provide that information.\"\nelse:\n    return bot_msg\n```\n\n### Workflow 3: vLLM deployment (fast inference)\n\n**Production-ready serving**:\n```python\nfrom vllm import LLM, SamplingParams\n\n# Initialize vLLM\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\", tensor_parallel_size=1)\n\n# Sampling params\nsampling_params = SamplingParams(\n    temperature=0.0,  # Deterministic\n    max_tokens=100\n)\n\ndef moderate_vllm(chat):\n    # Format prompt\n    prompt = tokenizer.apply_chat_template(chat, tokenize=False)\n\n    # Generate\n    output = llm.generate([prompt], sampling_params)\n    return output[0].outputs[0].text\n\n# Batch moderation\nchats = [\n    [{\"role\": \"user\", \"content\": \"How to make bombs?\"}],\n    [{\"role\": \"user\", \"content\": \"What's the weather?\"}],\n    [{\"role\": \"user\", \"content\": \"Tell me about drugs\"}]\n]\n\nprompts = [tokenizer.apply_chat_template(c, tokenize=False) for c in chats]\nresults = llm.generate(prompts, sampling_params)\n\nfor i, result in enumerate(results):\n    print(f\"Chat {i}: {result.outputs[0].text}\")\n```\n\n**Throughput**: ~50-100 requests\u002Fsec on single A100\n\n### Workflow 4: API endpoint (FastAPI)\n\n**Serve as moderation API**:\n```python\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\nfrom vllm import LLM, SamplingParams\n\napp = FastAPI()\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\")\nsampling_params = SamplingParams(temperature=0.0, max_tokens=100)\n\nclass ModerationRequest(BaseModel):\n    messages: list  # [{\"role\": \"user\", \"content\": \"...\"}]\n\n@app.post(\"\u002Fmoderate\")\ndef moderate_endpoint(request: ModerationRequest):\n    prompt = tokenizer.apply_chat_template(request.messages, tokenize=False)\n    output = llm.generate([prompt], sampling_params)[0]\n\n    result = output.outputs[0].text\n    is_safe = result.startswith(\"safe\")\n    category = None if is_safe else result.split(\"\\n\")[1] if \"\\n\" in result else None\n\n    return {\n        \"safe\": is_safe,\n        \"category\": category,\n        \"full_output\": result\n    }\n\n# Run: uvicorn api:app --host 0.0.0.0 --port 8000\n```\n\n**Usage**:\n```bash\ncurl -X POST http:\u002F\u002Flocalhost:8000\u002Fmoderate \\\n  -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"messages\": [{\"role\": \"user\", \"content\": \"How to hack?\"}]}'\n\n# Response: {\"safe\": false, \"category\": \"S6\", \"full_output\": \"unsafe\\nS6\"}\n```\n\n### Workflow 5: NeMo Guardrails integration\n\n**Use with NVIDIA Guardrails**:\n```python\nfrom nemoguardrails import RailsConfig, LLMRails\nfrom nemoguardrails.integrations.llama_guard import LlamaGuard\n\n# Configure NeMo Guardrails\nconfig = RailsConfig.from_content(\"\"\"\nmodels:\n  - type: main\n    engine: openai\n    model: gpt-4\n\nrails:\n  input:\n    flows:\n      - llamaguard check input\n  output:\n    flows:\n      - llamaguard check output\n\"\"\")\n\n# Add LlamaGuard integration\nllama_guard = LlamaGuard(model_path=\"meta-llama\u002FLlamaGuard-7b\")\nrails = LLMRails(config)\nrails.register_action(llama_guard.check_input, name=\"llamaguard check input\")\nrails.register_action(llama_guard.check_output, name=\"llamaguard check output\")\n\n# Use with automatic moderation\nresponse = rails.generate(messages=[\n    {\"role\": \"user\", \"content\": \"How do I make weapons?\"}\n])\n# Automatically blocked by LlamaGuard\n```\n\n## When to use vs alternatives\n\n**Use LlamaGuard when**:\n- Need pre-trained moderation model\n- Want high accuracy (94-95%)\n- Have GPU resources (7-8B model)\n- Need detailed safety categories\n- Building production LLM apps\n\n**Model versions**:\n- **LlamaGuard 1** (7B): Original, 6 categories\n- **LlamaGuard 2** (8B): Improved, 6 categories\n- **LlamaGuard 3** (8B): Latest (2024), enhanced\n\n**Use alternatives instead**:\n- **OpenAI Moderation API**: Simpler, API-based, free\n- **Perspective API**: Google's toxicity detection\n- **NeMo Guardrails**: More comprehensive safety framework\n- **Constitutional AI**: Training-time safety\n\n## Common issues\n\n**Issue: Model access denied**\n\nLogin to HuggingFace:\n```bash\nhuggingface-cli login\n# Enter your token\n```\n\nAccept license on model page:\nhttps:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FLlamaGuard-7b\n\n**Issue: High latency (>500ms)**\n\nUse vLLM for 10× speedup:\n```python\nfrom vllm import LLM\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\")\n# Latency: 500ms → 50ms\n```\n\nEnable tensor parallelism:\n```python\nllm = LLM(model=\"meta-llama\u002FLlamaGuard-7b\", tensor_parallel_size=2)\n# 2× faster on 2 GPUs\n```\n\n**Issue: False positives**\n\nUse threshold-based filtering:\n```python\n# Get probability of \"unsafe\" token\nlogits = model(..., return_dict_in_generate=True, output_scores=True)\nunsafe_prob = torch.softmax(logits.scores[0][0], dim=-1)[unsafe_token_id]\n\nif unsafe_prob > 0.9:  # High confidence threshold\n    return \"unsafe\"\nelse:\n    return \"safe\"\n```\n\n**Issue: OOM on GPU**\n\nUse 8-bit quantization:\n```python\nfrom transformers import BitsAndBytesConfig\n\nquantization_config = BitsAndBytesConfig(load_in_8bit=True)\nmodel = AutoModelForCausalLM.from_pretrained(\n    model_id,\n    quantization_config=quantization_config,\n    device_map=\"auto\"\n)\n# Memory: 14GB → 7GB\n```\n\n## Advanced topics\n\n**Custom categories**: See references\u002Fcustom-categories.md for fine-tuning LlamaGuard with domain-specific safety categories.\n\n**Performance benchmarks**: See references\u002Fbenchmarks.md for accuracy comparison with other moderation APIs and latency optimization.\n\n**Deployment guide**: See references\u002Fdeployment.md for Sagemaker, Kubernetes, and scaling strategies.\n\n## Hardware requirements\n\n- **GPU**: NVIDIA T4\u002FA10\u002FA100\n- **VRAM**:\n  - FP16: 14GB (7B model)\n  - INT8: 7GB (quantized)\n  - INT4: 4GB (QLoRA)\n- **CPU**: Possible but slow (10× latency)\n- **Throughput**: 50-100 req\u002Fsec (A100)\n\n**Latency** (single GPU):\n- HuggingFace Transformers: 300-500ms\n- vLLM: 50-100ms\n- Batched (vLLM): 20-50ms per request\n\n## Resources\n\n- HuggingFace:\n  - V1: https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FLlamaGuard-7b\n  - V2: https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-Guard-2-8B\n  - V3: https:\u002F\u002Fhuggingface.co\u002Fmeta-llama\u002FMeta-Llama-Guard-3-8B\n- Paper: https:\u002F\u002Fai.meta.com\u002Fresearch\u002Fpublications\u002Fllama-guard-llm-based-input-output-safeguard-for-human-ai-conversations\u002F\n- Integration: vLLM, Sagemaker, NeMo Guardrails\n- Accuracy: 94.5% (prompts), 95.3% (responses)\n\n## Agent operating procedure\n\n1. **Check the environment.** Confirm the model, checkpoint, benchmark version and evaluation harness version.\n2. **Pin down the inputs.** Confirm formats, identifiers and parameters from the data or the user. Ask rather than guess any value that changes the result.\n3. **Run a small version first.** Evaluate on a small subset to verify prompts, parsing and scoring.\n4. **Execute the full task** using the instructions and references above.\n5. **Validate the result.** Use the benchmark's official splits and metrics; check for contamination; report variance across seeds or prompts.\n6. **Report.** State what was run (versions, commands, parameters), what was checked, and what is still uncertain.\n\n| If this happens | Do this |\n|---|---|\n| Scores differ from published numbers | Check prompt format, few-shot settings and harness version before concluding. |\n| A function, flag or endpoint in these instructions is missing in the installed version | Check the installed version's own documentation (`help()`, `--help`, official docs), adapt, and tell the user. Never invent an API. |\n| A required input, identifier or parameter is ambiguous | Ask the user, or state the assumption explicitly before running. |\n\n**Integrity rules**\n\n- Never fabricate results, parameters, identifiers, citations or statistics. If something cannot be run or verified, say so plainly.\n- Report evaluation settings in full; never cherry-pick prompts, seeds or subsets.\n- Treat version-specific details here as possibly outdated: confirm them against the official documentation for the installed version.\n- Ask before actions that cost money, consume shared GPUs or cloud quota, touch personal or patient data, or cannot be undone.\n\n## Related skills\n\n- `prompt-guard`: Classifies text with Meta's Prompt Guard, an 86M-parameter model loaded from HuggingFace, into BENIGN, INJECTION or JAILBREAK labels to det…\n- `nemo-guardrails`: Adds runtime safety rails to LLM applications with NVIDIA NeMo Guardrails, configured through Colang 2.0 flows.\n- `serving-llms-vllm`: Serves LLMs with high throughput using vLLM's PagedAttention and continuous batching.\n",{"name":5,"license":15,"metadata":24,"description":7},{"tags":25,"version":26,"category":27,"maintainer":28,"dependencies":29},"Safety Alignment, LlamaGuard, Content Moderation, Meta, Guardrails, Safety Classification, Input Filtering, Output Filtering, AI Safety","1.0.0","ml-evaluation-and-safety","Kalaris Labs","transformers, torch, vllm","main","29fe36d26127205057d5e0ed8425f6b0e9a8c13a","skills\u002Fllamaguard",16,"https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills","https:\u002F\u002Fdocs.kalarislabs.com\u002Fresearch-agent-skills","https:\u002F\u002Fgithub.com\u002FKalarisLabs","kalarislabs.com","Applied AI lab building the infrastructure for the agentic era","2026-11-14 17:49:08",{"source":8,"skillName":5,"commands":41,"prompt":51,"zipAvailable":52},[42,45,48],{"tool":43,"command":44},"npx","npx skills add KalarisLabs\u002Fresearch-agent-skills --skill llamaguard",{"tool":46,"command":47},"bunx","bunx skills add KalarisLabs\u002Fresearch-agent-skills --skill llamaguard",{"tool":49,"command":50},"pnpm","pnpm dlx skills add KalarisLabs\u002Fresearch-agent-skills --skill llamaguard","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fllamaguard\u002FSKILL.md",true,[],[55,62,69,76,83,90],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M74Z8MGT305R11SNY5G28QH5","plos","Prepare manuscripts for PLOS journals (PLOS ONE, PLOS Biology, PLOS Computational Biology, PLOS Genetics, PLOS Medicine, PLOS Pathogens, PLOS Neglected Tropical Diseases, PLOS Global Public Health and others), covering structure, abstract and author summary, Vancouver-style references, the mandatory data availability policy, ethics and financial disclosure statements, figure requirements (PACE), the PLOS LaTeX template, reporting guidelines and PLOS ONE's publication criteria. Use when targeting any PLOS journal or checking compliance with PLOS policies.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fplos\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M74Z8CCN9APXYHNQ95V1EBGT","pkpd-modeling","Pharmacokinetic and pharmacodynamic modelling and simulation - non-compartmental analysis, compartmental and population PK, PK\u002FPD and exposure-response, TMDD, PBPK orientation, bioequivalence, allometric scaling and first-in-human dose, drug interaction prediction, and Bayesian therapeutic drug monitoring. Use when analysing concentration-time data, deriving exposure metrics, fitting PK or PD models, or evaluating dosing regimens. Triggers include \"pharmacokinetics\", \"pharmacodynamics\", \"PK\u002FPD\", \"NCA\", \"non-compartmental\", \"AUC\", \"Cmax\", \"lambda z\", \"half-life\", \"clearance\", \"volume of distribution\", \"compartmental model\", \"population PK\", \"popPK\", \"NONMEM\", \"nlmixr2\", \"Pharmpy\", \"Monolix\", \"exposure-response\", \"Emax\", \"EC50\", \"indirect response\", \"effect compartment\", \"TMDD\", \"PBPK\", \"bioequivalence\", \"RSABE\", \"ABEL\", \"allometric scaling\", \"first-in-human\", \"MABEL\", \"drug-drug interaction\", \"DDI\", \"ICH M12\", \"concentration-QTc\", \"therapeutic drug monitoring\", \"MIPD\", and \"dosing regimen\".","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpkpd-modeling\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M74Z86YHJJ1FM3X87BHN76KZ","pinecone","Guides use of Pinecone, a managed serverless vector database, through its Python client and the LangChain and LlamaIndex integrations. Covers creating indexes, upserting and querying vectors, metadata filtering, namespaces, hybrid dense and sparse search, index management, and deleting vectors. Use when building a production RAG system on a hosted vector store, adding semantic search or recommendations without running infrastructure, isolating per-user or per-tenant data with namespaces, combining dense and sparse vectors in one query, or filtering results by metadata. Do not use for self-hosted or local stores (Chroma, Weaviate) or offline similarity search (FAISS).","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpinecone\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M74Z80T6E89SAJ8MYDD0767Q","pi-agent","Build with and use Pi, the minimal terminal coding harness. Use for installing Pi, configuring providers\u002Fmodels\u002Fsettings\u002Fenvironment variables, creating Pi skills\u002Fextensions\u002Fpackages\u002Fthemes\u002Fprompt templates, embedding Pi through the SDK, integrating over RPC or JSON event streams, parsing sessions, running local models through the llama.cpp router, developing custom Pi providers and TUI components, or using ecosystem packages such as pi-subagents (delegation\u002Forchestration), pi-mcp-adapter (MCP servers), pi-interview (interactive forms), and pi-web-access (web search, fetching, video understanding).","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpi-agent\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M74Z7WF1Y8Q3VFAQPPPRAFMV","phoenix-observability","Open-source AI observability platform for LLM tracing, evaluation, and monitoring. Use when debugging LLM applications with detailed traces, running evaluations on datasets, or monitoring production AI systems with real-time insights.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fphoenix-observability\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M74Z7HNEH1A2AVYR3G1X2QV6","peft-fine-tuning","Fine-tunes LLMs with Hugging Face PEFT, using LoRA, QLoRA, IA3, AdaLoRA, prefix tuning, and prompt tuning so that under 1% of parameters are trained. Covers rank, alpha, and target module selection, loading and merging adapters, multi-adapter serving, and integration with TRL SFTTrainer, Axolotl, and vLLM. Use when fine-tuning 7B-70B models on limited GPU memory, when running QLoRA on a single 24GB GPU, when choosing LoRA rank and alpha, when merging or swapping adapters on one base model, or when debugging CUDA OOM or an adapter that does not apply. Not for full fine-tuning of small models under 1B parameters or cases needing all weights updated.","https:\u002F\u002Fgithub.com\u002FKalarisLabs\u002Fresearch-agent-skills\u002Fblob\u002Fmain\u002Fskills\u002Fpeft-fine-tuning\u002FSKILL.md",[],[]]