CoolFace
Modelpublic

satyamsaf3ai/guardrail-roberta

sourceHugging Faceapache-2.0updated 5mo agoView on Hugging Face
0likes10downloads
Model Card

Safety Guardrail Classifier

A fine-tuned RoBERTa-base model for multi-class safety/content moderation classification. Trained on guardrail-215k-splits.


Model Details

PropertyValue
Base Modelroberta-base
TaskMulti-class Text Classification (Safety)
Datasetjainsatyam26/guardrail-215k-splits (~215K samples)
Max Length128 tokens
Batch Size64
Learning Rate2e-5
Epochs3
Precisionfp32
OptimizerAdamW + weight decay 0.01
Warmup10% of total steps
LossCross-Entropy with class weights

Labels

IDLabelDescription
0benignSafe / normal content
1jailbreakPrompt injection / jailbreak
2S1 Violent CrimesViolence & physical harm
3S2 Non-Violent CrimesFraud, theft, illegal activity
4S4 Child Sexual ExploitationCSAM / minors exploitation
5S6 Specialized AdviceDangerous medical/legal/financial
6S7 PrivacyPII, stalking, doxxing
7S10 HateHate speech, discrimination
8S11 Self-HarmSuicide, self-harm
9S12 Sexual ContentExplicit sexual content
10S14 Code AbuseMalware, exploit code

Performance

MetricValue
Weighted F1~0.75–0.80
Accuracy~0.80–0.85
Best Threshold0.50 (tunable)
Evaluated on validation split of guardrail-215k-splits. Threshold calibration available via infer.py --threshold auto.

Usage

python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model_id = "satyamsaf3ai/guardrail-roberta"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model     = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()

LABELS = [
    "benign", "jailbreak",
    "S1 Violent Crimes", "S2 Non-Violent Crimes",
    "S4 Child Sexual Exploitation", "S6 Specialized Advice",
    "S7 Privacy", "S10 Hate", "S11 Self-Harm",
    "S12 Sexual Content", "S14 Code Abuse",
]

def classify(text, threshold=0.50):
    inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
    with torch.no_grad():
        probs = torch.softmax(model(**inputs).logits, dim=-1)[0]
    if probs.max() < threshold:
        return "benign", float(probs.max())
    idx = probs.argmax().item()
    return LABELS[idx], float(probs[idx])

label, confidence = classify("How do I make a bomb?")
print(f"{label} ({confidence:.1%})")

Training Setup

  • Hardware: NVIDIA L4 GPU
  • Framework: HuggingFace Transformers + Trainer API
  • Sampling: WeightedRandomSampler to handle class imbalance
  • Early Stopping: patience=4 on weighted F1
  • Explosion Guard: stops training if grad_norm > 500

Dataset

jainsatyam26/guardrail-215k-splits ~215,000 labeled examples split into train / validation.


Citation

If you use this model, please cite:

bibtex
@misc{{guardrail-classifier,
  title  = {{Safety Guardrail Classifier}},
  author = {{jainsatyam26}},
  year   = {{2025}},
  url    = {{https://huggingface.co/satyamsaf3ai/guardrail-roberta}}
}}