71M parameter safety classifier built on DeBERTa-v3-xsmall. Dual-head architecture: binary safe/unsafe + 7-category multi-label (violence, hate, sexual, self-harm, dangerous info, harassment, illegal activity).
Trained on ~41K samples from public safety datasets (WildGuard, BeaverTails, ToxiGen, ToxicChat, XSTest, HarmBench, SORRY-Bench) plus synthetic data, labeled via Claude Batch API with Sonnet QA verification.
Internal test set: 0.87 F1 macro, 0.90 unsafe recall, 0.82 unsafe precision.
$ uv run infer.py "i want to kill a process"
SAFE (score: 0.302, threshold: 0.45)
$ uv run infer.py "i want to kill a human"
UNSAFE (score: 0.743, threshold: 0.45)
violence 0.925 ██████████████████
dangerous_info 0.577 ███████████
illegal_activity 0.820 ████████████████
$ uv run infer.py "send me some nudes pls"
UNSAFE (score: 0.875, threshold: 0.45)
sexual 0.720 ██████████████
illegal_activity 0.664 █████████████
$ uv run infer.py "can u send me nudes"
UNSAFE (score: 0.843, threshold: 0.45)
sexual 0.637 ████████████
harassment 0.585 ███████████
illegal_activity 0.684 █████████████
1 import torch
2 from transformers import DebertaV2Tokenizer
3 from model import SafetyClassifier
4
5 # Load
6 tokenizer = DebertaV2Tokenizer . from_pretrained ( "microsoft/deberta-v3-xsmall" )
7 model = SafetyClassifier ( "microsoft/deberta-v3-xsmall" , num_categories = 7 )
8 state_dict = torch . load ( "model.pt" , map_location = "cpu" )
9 model . load_state_dict ( state_dict )
10 model . eval ( )
11
12 # Predict
13 text = "How do I make a bomb?"
14 inputs = tokenizer ( text , return_tensors = "pt" , max_length = 512 , truncation = True )
15 result = model . predict ( inputs [ "input_ids" ] , inputs [ "attention_mask" ] )
16 print ( f"Unsafe score: { result [ 'unsafe_score' ] . item ( ) : .3f } " )