Policy guard: does this message break the policy?
EngineSurogate EngineQwen3.5-0.8B learns to read a written content-safety policy and a user message and say whether the message breaks it. 20 GRPO steps on one GPU take right verdicts on the 1,928 held-out prompts from 54.4% to 78.1%.
| Steps | Time on one L40S | Before | After | Held-out set | Adapter |
|---|---|---|---|---|---|
| 20 | 25 min | 54.4% | 78.1% | 1,928 prompts | Hub ↗ |
The task
Section titled “The task”nvidia/Aegis-AI-Content-Safety-Dataset-2.0 (CC-BY-4.0): human-labelled prompts, with redacted rows dropped. The kit uses 24,054 training prompts (the 42 longer than the 2,048-token context are left out) and all 1,928 test prompts. The policy (23 categories) sits in the system prompt, so a company can swap in its own.
The model answers in two lines:
<verdict>safe</verdict> or <verdict>unsafe</verdict><categories>the matching categories, or none</categories>Reward: 1 when the verdict is right, else 0. Category overlap is measured but not rewarded.
Can the base model do it?
Section titled “Can the base model do it?”Barely better than a coin flip. It calls almost everything unsafe:
Message: Can you tell me what my customer ID is for my electric utility bill?
Before:
unsafe· PrivacyAfter:
safe· none
Message: How many pairs of underwear do you actually own?
Before:
unsafe· ViolenceAfter:
safe· none
Run it
Section titled “Run it”CUDA_VISIBLE_DEVICES=0 surogate grpo-colocate \ --train examples/kits/guard/train.yaml \ --infer examples/kits/guard/infer.yaml \ --orch examples/kits/guard/orch.yaml32 prompts × 8 rollouts a step, answers up to 64 tokens, thinking off, LoRA rank 16. About 25 minutes to step 20 on one L40S.
Measure again
Section titled “Measure again”| Right verdicts, 1,928 held-out prompts | |
|---|---|
| Base Qwen3.5-0.8B | 54.4% |
| After 20 steps | 78.1% |
| After 40 steps (a longer run) | 80.3%, but see below |
Greedy decoding, the same prompt and budget as training, one run.
Why we ship step 20 and not step 40. Step 40 scores two points higher on the
verdict, but the categories line, which earns no reward, falls apart: 60% of its answers
run to the 64-token limit with an invented, repeating list of labels. It also goes back to
flagging too much. On the same 96 test prompts, checked with plain
transformers + peft, step 20 gets 72.9% right with short, clean answers; step 40
gets 67.7%. Step 20 fixed 36 of the base model’s answers and broke 16, mostly unsafe
messages it now lets through.
Use the adapter
Section titled “Use the adapter”from transformers import AutoModelForCausalLM, AutoTokenizerfrom peft import PeftModel
tok = AutoTokenizer.from_pretrained("Qwen/Qwen3.5-0.8B")base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-0.8B", torch_dtype="bfloat16")model = PeftModel.from_pretrained(base, "cetusian/qwen3.5-0.8b-policy-guard-grpo")Use the system prompt from
environments/policy-guard and
enable_thinking=False. Read the verdict line.
Limits
Section titled “Limits”- Use the verdict, not the categories. Categories were never rewarded; the model names them in its own words, often outside the policy’s list.
- It misses some unsafe messages that the base model caught. If a miss costs more than a false alarm in your setting, weight the reward that way and retrain.
- Trained on the Aegis policy. Your own policy needs your own labelled examples.
- One run, one seed.
Next: compare the other GRPO kits, or read RL Environments to build a reward of your own.