Downloads · 30 days
4
5% of all-time downloads
tzchen07/rai-gemma4-e2b-5b-safety-dora-r64-fullfix
rai-gemma4-e2b-5b-safety-dora-r64-fullfix is a text generation model from tzchen07. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
Campaign-winning enterprise content safety classifier that hits all three targets: 0.050% Block Rate, 100% Precision (0 false positives), and 22.7% Recall across 13 risk categories. The first model to achieve the trip…
Downloads · 30 days
4
5% of all-time downloads
All-time downloads
74
Public
Parameters
5B
10.5 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors10.5 GB · 99%
From the Hugging Face model README
Campaign-winning enterprise content safety classifier that hits all three targets: 0.050% Block Rate, 100% Precision (0 false positives), and 22.7% Recall across 13 risk categories. The first model to achieve the triple target from a 130+ experiment training campaign.
| Template | Block Rate (FPR) | False Positives |
|---|---|---|
| VerdictReason | 0.050% (3 / 5,896) | 3 |
| CategoryOnly | 0.390% (23 / 5,896) | 23 |
| Template | Precision | Recall | F1 | FP |
|---|---|---|---|---|
| VerdictReason | 1.0000 (0 FP) | 0.2270 (227/1000) | 0.3702 | 0 |
| CategoryOnly | 0.9412 | 0.2560 | 0.4023 | 16 |
| Target | Value | Status |
|---|---|---|
| Block Rate <= 0.200% | 0.050% | HIT |
| Precision >= 99.5% | 100% | HIT |
| Recall >= 20% | 22.7% | HIT |
Single-stage DoRA SFT:
google/gemma-4-E2B-it (5.2B params, multimodal Transformer)q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj (in model.language_model.layers)| Dataset | Rows | Purpose |
|---|---|---|
| v1.6.0_train.jsonl | 9,657 | Base safety classification (Aegis 2.0, HH-RLHF, Dolly, OASST1) |
| v1.6b_train.jsonl | 604 | Supplementary paraphrase/corrections |
| v1.6c_train.jsonl | 2,000 | Violation-heavy supplementary |
| v1.6d_train.jsonl | 1,660 | Balanced supplementary |
| v1.6e_train.jsonl | 2,000 | Violence/Harassment focused |
| v1.6e2_train.jsonl | 2,000 | Misinformation/Illegal/IP focused |
| v1_6e7_FPonly.jsonl | 1,005 | Real FP corrections (all benign) |
| v1_6g_fpfix.jsonl | 300 | Synthetic FP-fix (HR, jailbreak edu, software verbs) |
| v1_6h_ip_fix.jsonl | 100 | IP-specific FP correction (slides, orders, licenses) |
| v1_6i_edu_style_fix.jsonl | 170 | Educational-about-harm + style/tone FP fix |
| v1_6j_pers_tag_fix.jsonl | 80 | [PERS-XXXX] metadata tag FP fix |
Three factors combined to achieve the triple target:
python -m vllm.entrypoints.openai.api_server \
--model tzchen07/rai-gemma4-e2b-5b-safety-dora-r64-fullfix \
--served-model-name rai-classifier \
--port 8180 \
--max-model-len 8192 \
--gpu-memory-utilization 0.85 \
--trust-remote-code \
--dtype bfloat16
Note: Requires vLLM >= 0.22.1 for Gemma 4 support. The merged model includes k_norm weight patching required for vLLM serving.
IMPORTANT: stop=["Reason:"] is required for production use. Without it, the model degenerates into repeated Verdict/Reason loops.
from openai import OpenAI
client = OpenAI(base_url="http://localhost:8180/v1", api_key="unused")
# Input format: system = v3.1 policy, user = {'request': '<query>'}
resp = client.chat.completions.create(
model="rai-classifier",
messages=[
{"role": "system", "content": "<v3.1 safety policy>"},
{"role": "user", "content": "{'request': 'How many story points did our team complete?'}"},
],
max_tokens=50,
temperature=0.0,
stop=["Reason:"], # REQUIRED — prevents degenerate repetition
)
verdict = resp.choices[0].message.content.strip()
# Returns: "Verdict: none" or "Verdict: Self-harm" etc.
Verified output examples:
Benign query → "Verdict: none" (finish_reason: stop)
Self-harm → "Verdict: Self-harm" (finish_reason: stop)
Hate speech → "Verdict: Hate/Discrimination" (finish_reason: stop)
Why stop=["Reason:"] is required:
This model was the breakthrough result from a 130+ experiment campaign across two model families:
| Model | DoRA | r | Block% | P | R | FP | Targets |
|---|---|---|---|---|---|---|---|
| G4-B (this) | Yes | 64 | 0.050% | 100% | 22.7% | 0 | ALL 3 |
| G4-C | Yes | 32 | 0.150% | 99.59% | 24.5% | 1 | ALL 3 |
| G4-D | No | 64 | 0.000% | 99.34% | 30.3% | 2 | B,R |
| G4-A | Yes | 32 | 0.140% | 98.25% | 22.5% | 4 | B,R |
@misc{rai-g4-safety-2026,
title={RAI Safety Classifier: Gemma 4 E2B 5B — Triple Target Achievement},
author={Tony Chen},
year={2026},
publisher={HuggingFace},
url={https://huggingface.co/tzchen07/rai-gemma4-e2b-5b-safety-dora-r64-fullfix}
}