Views
No views yet
1from transformers import AutoModelForSequenceClassification, AutoTokenizer
2import torch
3
4# Load model
5tokenizer = AutoTokenizer.from_pretrained("vincentoh/wizard101-l0-bouncer")
6model = AutoModelForSequenceClassification.from_pretrained("vincentoh/wizard101-l0-bouncer")
7model.eval()
8
9# Inference
10text = "How do I make a cake?"
11inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
12
13with torch.no_grad():
14 outputs = model(**inputs)
15 probs = torch.softmax(outputs.logits, dim=-1)
16
17 # Index 0 = safe, Index 1 = harmful
18 safe_prob = probs[0][0].item()
19 harmful_prob = probs[0][1].item()
20
21 if harmful_prob > safe_prob:
22 prediction = "harmful"
23 confidence = harmful_prob
24 else:
25 prediction = "safe"
26 confidence = safe_prob
27
28print(f"Prediction: {prediction} ({confidence:.2%})")1# Route to L1 if confidence < 0.9
2needs_l1 = confidence < 0.9
3
4if needs_l1:
5 # Send to GuardReasoner-8B for detailed analysis
6 pass| Dataset | Samples | Accuracy |
|---|---|---|
| JailbreakBench | 200 | 68.0% |
| SG-Bench | 500 | 88.8% |
| StrongREJECT | 313 | 96.8% |
| WildGuardMix | 500 | 96.8% |
User Input
│
▼
┌─────────┐
│ L0 │ ◄── This model (fast filter)
│ Bouncer │
└────┬────┘
│ (uncertain cases)
▼
┌─────────┐
│ L1 │ GuardReasoner-8B
└────┬────┘
│
▼
┌─────────┐
│ L2/L3 │ GPT-OSS reasoning models
└─────────┘