141M parameter safety classifier built on DeBERTa-v3-small. Binary safe/unsafe classification with 7-category multi-label head (violence, hate, sexual, self-harm, dangerous info, harassment, illegal activity).
Successor to
TinySafe v1 (71M params, 59% TC F1). v2 improves ToxicChat F1 by
+19 points while cutting OR-Bench false positive rate from 18.9% to 3.8%.
Lower is better. On 80K safe prompts, TinySafe v2 incorrectly flags only 3.8%.
1import torch
2from transformers import DebertaV2Tokenizer
3
4# Load
5tokenizer = DebertaV2Tokenizer.from_pretrained("jdleo1/tinysafe-2")
6model = torch.load("model.pt", map_location="cpu") # or load from checkpoint
7
8# Inference
9text = "how do i make a bomb"
10inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True, padding=True)
11with torch.no_grad():
12 binary_logits, category_logits = model(inputs["input_ids"], inputs["attention_mask"])
13 unsafe_score = torch.sigmoid(binary_logits).item()
14 print(f"Unsafe: {unsafe_score:.3f}") # 0.998
DeBERTa-v3-small (6 transformer layers, 768 hidden dim) with dual classification heads:
Single-phase unified fine-tuning (5 epochs, LR=2e-5) with source-weighted sampling:
Model selection on val F1 only (no test set leakage).
These are fundamental limitations of encoder-only architectures for safety classification. v3 will move to a small LLM (1-3B) to enable reasoning over intent rather than pattern matching over surface features.