--- license: other license_name: llama3 license_link: https://huggingface.co/meta-llama/Llama-Guard-3-8B/blob/main/LICENSE base_model: meta-llama/Llama-Guard-3-8B library_name: peft paper: arXiv:2610.18095 tags: - safety - ai-companion - guardrail --- # CompanionGuard CompanionGuard is a companion-specific safety guard introduced in **"CompanionSafe: From Multi-turn Safety Evaluation to Guardrails for AI Companions"**. 📄 **Paper:** [arXiv:2610.18095](https://arxiv.org/abs/2610.18095) It is a LoRA adapter (rank 16, alpha 16, all-linear targets) fine-tuned for one epoch on Llama-Guard-3-8B over turn-localized supervision derived from the CompanionEval benchmark: 17,703 boundary examples (7,142 safe / 10,561 unsafe), split 16,846 / 857 by trajectory group. The guard reads a turn-marked dialogue and answers first with a verdict tag, then a category tag for unsafe verdicts: ``` safe unsafe D8 ``` where D1-D13 index the 13 companion-safety categories of the CompanionSafe taxonomy. ## Usage ```python from peft import PeftModel from transformers import AutoModelForCausalLM, AutoTokenizer base = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-Guard-3-8B", torch_dtype="bfloat16") model = PeftModel.from_pretrained(base, "") tok = AutoTokenizer.from_pretrained("meta-llama/Llama-Guard-3-8B") ``` Prompt format and evaluation code follow `guard/` in the [CompanionSafe repository](https://github.com/AI45Lab/CompanionSafe). On the held-out test set the adapter reaches 73.51 accuracy, 77.46 binary F1, and 68.31 macro-F1 over the 14 output classes. ## Files - `adapter_model.safetensors` — LoRA weights (161 MB) - `adapter_config.json` / `additional_config.json` — PEFT and training configuration