Instructions to use liao1111/CompanionGuard with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use liao1111/CompanionGuard with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("/mnt/shared-storage-gpfs2/gpfs2-shared-public/huggingface/zskj-hub/models-meta-llama-Llama-Guard-3-8B") model = PeftModel.from_pretrained(base_model, "liao1111/CompanionGuard") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from liao1111/CompanionGuard: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/liao1111/CompanionGuard/resolve/main/README.md
- Command line
-
hf download hf://liao1111/CompanionGuard/README.md
-
curl -L -o README.md https://huggingface.co/liao1111/CompanionGuard/resolve/main/README.md
1.8 kB
| 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: | |
| ``` | |
| <answer>safe</answer> | |
| <answer>unsafe</answer> | |
| <category>D8</category> | |
| ``` | |
| 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, "<this-repo>") | |
| 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 | |