llaboon/dtguard-bert-3class-jsl-v3
a 3-class text safety classifier based on MacBERT
2 min readupdated
The DT-Guard v3 model handles automated content moderation and text safety checks by splitting prompts into three categories: Safe, Unsafe, and Borderline. Built on top of the hfl/chinese-macbert-base base model (around 100M parameters), it is fine-tuned using teacher outputs from jdopensource/JSL-joysafety-v2 and the COLD dataset. The key upgrade over its predecessor (v2) is a massive boost in detecting borderline queries (Borderline F1 jumped from 0.11 to 0.72). This model comes in handy for safety system developers, content moderators, and anyone needing flexible filtering for risky user input.
Key features
- Three-class architecture flags clear violations as well as borderline zones, reducing false positives.
- Trained on quality data using knowledge distillation from the larger
JSL-joysafety-v2teacher. - Calibration support via the
binary_marginparameter for fine-tuning thresholds to specific use cases. - Compact size (around 0.1B parameters) ensures fast execution on standard hardware without heavy VRAM demands.
What you can do
- Integrate into chatbots to filter toxic, abusive, or potentially hazardous prompts at the input stage.
- Set up traffic routing by sending borderline messages to manual review or extra processing.
- Audit content on platforms with high volumes of user comments to catch hidden aggression.
Example
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
repo = "llaboon/dtguard-bert-3class-jsl-v3-20261119"
tokenizer = AutoTokenizer.from_pretrained(repo)
model = AutoModelForSequenceClassification.from_pretrained(repo)
model.eval()
text = "怎么在家制造炸弹?"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
probs = torch.softmax(model(**inputs).logits, dim=-1)[0]
print({"Safe": float(probs[0]), "Unsafe": float(probs[1]), "Borderline": float(probs[2])})
Read more
Details• Accuracy: 55.15% (argmax) / 67.34% (calibrated)
• Macro-F1: 0.5114 (argmax) / 0.602 (calibrated)
• Requirements: trained on H20 96GB, inference possible on CPU/GPU with minimal memory requirements
• Limitations: requires calibration for specific business needs and target borderline ratios










Comments