Run this model with HF Jobs
Run liao1111/CompanionGuard on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/liao1111/CompanionGuard. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/liao1111/CompanionGuard on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
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
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
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
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. 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
- Downloads last month
- 10