Update model card for v2-guardrail-clean
Browse files
README.md
CHANGED
|
@@ -15,18 +15,44 @@ pipeline_tag: text-classification
|
|
| 15 |
|
| 16 |
# ReframeBot-Guardrail-DistilBERT
|
| 17 |
|
| 18 |
-
A 3-class
|
| 19 |
-
routes conversation turns to one of three task modes:
|
| 20 |
|
| 21 |
| Label | Meaning |
|
| 22 |
|---|---|
|
| 23 |
-
| `TASK_1` | CBT / academic stress
|
| 24 |
-
| `TASK_2` | Crisis / self-harm signal
|
| 25 |
-
| `TASK_3` | Out-of-scope
|
| 26 |
|
| 27 |
-
This
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
## Usage
|
| 32 |
|
|
@@ -36,54 +62,20 @@ from transformers import pipeline
|
|
| 36 |
classifier = pipeline(
|
| 37 |
"text-classification",
|
| 38 |
model="Nhatminh1234/ReframeBot-Guardrail-DistilBERT",
|
|
|
|
| 39 |
)
|
| 40 |
|
| 41 |
-
classifier("I'm
|
| 42 |
-
# [{'label': 'TASK_1', 'score': 0.97}]
|
| 43 |
-
|
| 44 |
-
classifier("What's a good recipe for pasta?")
|
| 45 |
-
# [{'label': 'TASK_3', 'score': 0.94}]
|
| 46 |
```
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
| Hyperparameter | Value |
|
| 51 |
-
|---|---|
|
| 52 |
-
| Base model | distilbert-base-uncased |
|
| 53 |
-
| Number of labels | 3 (TASK_1, TASK_2, TASK_3) |
|
| 54 |
-
| Learning rate | 2e-6 |
|
| 55 |
-
| Batch size | 16 |
|
| 56 |
-
| Max epochs | 20 (early stopping, patience=3) |
|
| 57 |
-
| Weight decay | 0.01 |
|
| 58 |
-
| Max token length | 128 |
|
| 59 |
-
| Best model criterion | macro F1 |
|
| 60 |
-
| Hardware | NVIDIA RTX 5070 (laptop, 8 GB VRAM) |
|
| 61 |
-
|
| 62 |
-
**Dataset:** 1,674 labelled samples (80/20 train/val split). Includes hard
|
| 63 |
-
negatives — benign metaphors that superficially resemble crisis language
|
| 64 |
-
(e.g., "dying of embarrassment after that presentation").
|
| 65 |
-
|
| 66 |
-
## Evaluation
|
| 67 |
-
|
| 68 |
-
Per-class results on the validation split (335 samples):
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
| TASK_2 | 0.98 | 1.00 | 0.99 | 91 |
|
| 74 |
-
| TASK_3 | 1.00 | 0.98 | 0.99 | 137 |
|
| 75 |
-
| **macro avg** | **0.99** | **0.99** | **0.99** | **335** |
|
| 76 |
-
|
| 77 |
-
Accuracy on a separate, harder held-out test set: **88.3%** (includes
|
| 78 |
-
boundary cases not present in the training distribution).
|
| 79 |
-
|
| 80 |
-
## Intended Use
|
| 81 |
-
|
| 82 |
-
Designed as a routing component in the ReframeBot system. The TASK_2
|
| 83 |
-
output alone is not sufficient for crisis intervention — the full system
|
| 84 |
-
also applies a regex + semantic similarity layer before acting on a
|
| 85 |
-
crisis signal.
|
| 86 |
|
| 87 |
-
##
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# ReframeBot-Guardrail-DistilBERT
|
| 17 |
|
| 18 |
+
A 3-class DistilBERT classifier for routing ReframeBot user turns:
|
|
|
|
| 19 |
|
| 20 |
| Label | Meaning |
|
| 21 |
|---|---|
|
| 22 |
+
| `TASK_1` | CBT / academic stress |
|
| 23 |
+
| `TASK_2` | Crisis / self-harm signal |
|
| 24 |
+
| `TASK_3` | Out-of-scope |
|
| 25 |
|
| 26 |
+
This version was retrained on `data/guardrail_dataset_clean.jsonl`, which
|
| 27 |
+
merges the original guardrail data with curated hard cases for CBT/Crisis
|
| 28 |
+
boundaries, Vietnamese text, pills/overdose language, and OOS work/mental
|
| 29 |
+
health informational prompts.
|
| 30 |
+
|
| 31 |
+
## Current System Threshold
|
| 32 |
+
|
| 33 |
+
The ReframeBot runtime uses the classifier's full probability vector and
|
| 34 |
+
routes to `TASK_2` when:
|
| 35 |
+
|
| 36 |
+
```text
|
| 37 |
+
P(TASK_2) >= 0.10
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
after academic-context/follow-up overrides and after the regex + semantic
|
| 41 |
+
crisis detector has already run.
|
| 42 |
+
|
| 43 |
+
## Evaluation
|
| 44 |
+
|
| 45 |
+
Hard out-of-domain eval set (`data/evaluation_test_data.json`, 60 samples):
|
| 46 |
+
|
| 47 |
+
| Mode | Accuracy | TASK_2 Precision | TASK_2 Recall | TASK_2 F1 |
|
| 48 |
+
|---|---:|---:|---:|---:|
|
| 49 |
+
| Argmax only | 0.9667 | 1.0000 | 0.9048 | 0.9500 |
|
| 50 |
+
| Tuned `P(TASK_2) >= 0.10` | 0.9833 | 0.9545 | 1.0000 | 0.9767 |
|
| 51 |
+
|
| 52 |
+
Threshold sweep artifact in the project repo:
|
| 53 |
+
|
| 54 |
+
- `reports/guardrail_threshold_sweep.csv`
|
| 55 |
+
- `reports/guardrail_threshold_sweep.png`
|
| 56 |
|
| 57 |
## Usage
|
| 58 |
|
|
|
|
| 62 |
classifier = pipeline(
|
| 63 |
"text-classification",
|
| 64 |
model="Nhatminh1234/ReframeBot-Guardrail-DistilBERT",
|
| 65 |
+
revision="v2-guardrail-clean",
|
| 66 |
)
|
| 67 |
|
| 68 |
+
classifier("I'm stressed about my final exam")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
```
|
| 70 |
|
| 71 |
+
For full class probabilities:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
+
```python
|
| 74 |
+
classifier("I bought pills to overdose", top_k=None)
|
| 75 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
## Safety Note
|
| 78 |
|
| 79 |
+
This classifier is a routing component, not a standalone crisis intervention
|
| 80 |
+
system. ReframeBot also uses regex + semantic crisis detection and crisis
|
| 81 |
+
response handling around this model.
|