Downloads · 30 days
11
15% of all-time downloads
hgLeo12/RoTRAG_roberta_routing_classifier
RoTRAG_roberta_routing_classifier is a text classification model from hgLeo12. Use it when you need a label for a piece of text. It is set up for transformers.
This model is the routing classifier used in RoTRAG: Retrieval-Augmented Rule-of-Thumb Reasoning for Conversation Harm Detection.
Downloads · 30 days
11
15% of all-time downloads
All-time downloads
73
Public
Parameters
355M
2.8 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.4 GB · 100%
From the Hugging Face model README
This model is the routing classifier used in RoTRAG: Retrieval-Augmented Rule-of-Thumb Reasoning for Conversation Harm Detection.
The classifier decides whether a previously generated Rule of Thumb (RoT) can be carried over to the current dialogue turn or whether RoTRAG should generate a new RoT for the current context.
| Label | Meaning |
|---|---|
0 | The previous RoT is no longer sufficient; generate a new RoT. |
1 | The previous RoT can be retained for the current turn. |
This checkpoint is intended for the router step in the RoTRAG pipeline. Given the previous RoT information and the current context-response pair, it predicts whether the normative core of the previous RoT still applies.
It is not a standalone harm detector. The classifier only decides RoT carry-over versus RoT regeneration; downstream safety or prosocial labels are produced by separate RoTRAG reasoning and prediction steps.
RobertaForSequenceClassificationroberta-large0 or 1)The routing supervision data was constructed from ProsocialDialog train/validation instances. The annotation process first used 1,000 human-labeled routing examples, annotated by 10 expert annotators. The final gold label for each example was determined by hard voting.
The resulting annotation rule was distilled into a prompt and validated against the human-labeled subset, reaching 0.98 accuracy relative to the human gold labels. The validated prompt was then used to expand labels over the remaining training data.
Expanded label counts reported for classifier training:
| Split | Label 0 | Label 1 |
|---|---|---|
| Train | 14,528 | 46,206 |
| Validation | 2,489 | 8,147 |
The classifier was fine-tuned with the following setup:
| Hyperparameter | Value |
|---|---|
| Base model | roberta-large |
| Epochs | 3 |
| Learning rate | 2e-5 |
| Scheduler | Linear, no warm-up |
| Optimizer | AdamW |
| Weight decay | 0.01 |
| Train batch size | 8 |
| Gradient accumulation | 2 |
| Effective batch size | 16 |
| Evaluation batch size | 16 |
| Max sequence length | 256 |
| Padding | Dynamic |
| Mixed precision | FP16 |
| Best checkpoint criterion | Macro F1 |
| Random seed | 42 |
On 10,636 validation routing instances, the classifier produced the following confusion matrix counts:
| Outcome | Count | Share |
|---|---|---|
| True positive | 7,461 | 70.215% |
| True negative | 1,743 | 16.403% |
| False positive | 746 | 7.021% |
| False negative | 676 | 6.362% |
The reported behavior is strongest when the current turn clearly preserves or clearly departs from the previous RoT. Remaining errors are often borderline cases where the current response is partially related to the previous RoT but shifts specificity, framing, or normative emphasis.
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model_id = "hgLeo12/roberta_classifier"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
model.eval()
previous_rot = "You should not manipulate others."
current_context = "She gets what she gets. Her bad habits are getting out of control."
current_response = (
"You would have more luck if you just talked to her and explained the problem. "
"If she does not want to change, then maybe you should move on."
)
text = (
f"Previous RoT: {previous_rot}\n"
f"Current Context: {current_context}\n"
f"Current Response: {current_response}"
)
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=256)
with torch.no_grad():
logits = model(**inputs).logits
predicted_label = int(logits.argmax(dim=-1).item())
print(predicted_label)
Interpretation:
0: generate a new RoT.1: carry over the previous RoT.GitHub repository: GitLeo1/RoTRAG-Rule-of-Thumb-Reasoning-for-Conversation-Harm-Detection-with-Retrieval-Augmented-Generation