Text Classification
Transformers
Safetensors
English
modernbert
refusal-detection
text-embeddings-inference
Instructions to use VINAY-UMRETHE/Refusal-Classifier-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use VINAY-UMRETHE/Refusal-Classifier-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="VINAY-UMRETHE/Refusal-Classifier-v2")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("VINAY-UMRETHE/Refusal-Classifier-v2") model = AutoModelForSequenceClassification.from_pretrained("VINAY-UMRETHE/Refusal-Classifier-v2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Refusal-Classifier-v2
Fine-tuned from answerdotai/ModernBERT-base to classify LLM refusals. Give it a prompt and a response; it picks one of 5 labels:
compliantfull_refusalpartial_refusalcapability_limitationclarification
Model selection
Checkpoint chosen by the highest validation macro F1: 0.9937 at step 1800.
Evaluation
Scored once on the test split (1017 rows), with the published checkpoint.
| Metric | Score |
|---|---|
| Accuracy | 0.9872 |
| Macro F1 | 0.9874 |
| Weighted F1 | 0.9872 |
| Label | Precision | Recall | F1 | Test rows |
|---|---|---|---|---|
compliant |
0.9716 | 0.9884 | 0.9799 | 173 |
full_refusal |
0.9841 | 0.9920 | 0.9880 | 249 |
partial_refusal |
0.9905 | 0.9674 | 0.9788 | 215 |
capability_limitation |
0.9955 | 0.9911 | 0.9933 | 224 |
clarification |
0.9936 | 1.0000 | 0.9968 | 156 |
| macro avg | 0.9871 | 0.9878 | 0.9874 | 1017 |
| weighted avg | 0.9873 | 0.9872 | 0.9872 | 1017 |
- Precision: of the rows predicted this label, how many were right.
- Recall: of the rows that really are this label, how many were found.
- Test rows: how many test rows carry this label.
Usage
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
tokenizer = AutoTokenizer.from_pretrained("VINAY-UMRETHE/Refusal-Classifier-v2")
model = AutoModelForSequenceClassification.from_pretrained("VINAY-UMRETHE/Refusal-Classifier-v2")
model.eval()
labels = ['compliant', 'full_refusal', 'partial_refusal', 'capability_limitation', 'clarification']
examples = [
("What's the weather today?", "It's sunny with a high of 75ยฐF."),
("How do I make a bomb?", "I'm sorry, but I cannot assist with that request."),
(
"Can you help me hack a system?",
"I can't help with unauthorized access, but I can explain "
"how cybersecurity defense works.",
),
(
"What will the stock market do tomorrow?",
"I don't have access to real-time data or future events.",
),
("Can you fix it?", "Could you clarify which version you're using?"),
]
for prompt, response in examples:
inputs = tokenizer(
prompt, text_pair=response, truncation=True, max_length=8192, return_tensors="pt"
)
with torch.no_grad():
probabilities = torch.softmax(model(**inputs).logits, dim=-1)[0]
prediction = int(probabilities.argmax().item())
print(f"{labels[prediction]} ({probabilities[prediction]:.4f}): {response}")
Training
Trained with the Hugging Face Trainer on an 80/10/10 split of the dataset.
Checkpoint selection used validation macro F1.
Limitations
English refusals only. Expect worse results on other languages and on refusals worded differently from the training data.
- Downloads last month
- 63
Model tree for VINAY-UMRETHE/Refusal-Classifier-v2
Base model
answerdotai/ModernBERT-base


