Downloads · 30 days
307
9% of all-time downloads
mila-ai4h/Mila-Suicide-Prevention-Output-Guardrail
Mila-Suicide-Prevention-Output-Guardrail is a text classification model from mila-ai4h. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as apache-2.0.
A small classifier that flags LLM responses that enable, encourage, or endorse suicide or self-harm, in English and French.
Downloads · 30 days
307
9% of all-time downloads
All-time downloads
3.3K
Public
Parameters
308M
2.1 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors1.2 GB · 97%
From the Hugging Face model README
A small classifier that flags LLM responses that enable, encourage, or endorse suicide or self-harm, in English and French.
Beta release. Not intended for standalone production use. Deploy with human oversight and additional safety layers.
The model reads a single assistant response and predicts whether it violates our suicide and self-harm policy. It is one layer in a defense-in-depth stack: not an input guardrail, not a general harm classifier, and not a standalone moderation system.
ModernBertForSequenceClassification, single-logit head1 if p(unsafe) ≥ τ, else 0import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
repo_id = "mila-ai4h/Mila-Suicide-Prevention-Output-Guardrail"
THRESHOLD = 0.5 # choose an operating point from the Performance tables
tokenizer = AutoTokenizer.from_pretrained(repo_id)
model = AutoModelForSequenceClassification.from_pretrained(repo_id)
model.eval()
texts = [
"I hear how heavy this feels. Please call or text 988 if you are in crisis.",
"Je comprends que c'est difficile. Tu peux appeler le 9-8-8 si tu es en crise.",
]
inputs = tokenizer(texts, padding=True, truncation=True, max_length=512, return_tensors="pt")
with torch.no_grad():
p_unsafe = torch.sigmoid(model(**inputs).logits.squeeze(-1))
for text, p in zip(texts, p_unsafe.tolist()):
label = "unsafe" if p >= THRESHOLD else "safe"
print(f"{label} (p_unsafe={p:.4f}) {text}")
Expected output:
safe (p_unsafe=0.0370) I hear how heavy this feels. Please call or text 988 if you are in crisis.
safe (p_unsafe=0.0305) Je comprends que c'est difficile. Tu peux appeler le 9-8-8 si tu es en crise.
Based on the "Suicide and Self-Harm" category of MLCommons AILuminate.
| Label | Meaning |
|---|---|
1 | Enables, encourages, or endorses intentional suicide, self-injury, or disordered eating (e.g., methods, acquiring means, concealment, pro-eating-disorder tips). |
0 | Everything else: information or support about self-harm (e.g., crisis resources, recovery, clinical definitions), risky activities where self-harm is not the goal (e.g., smoking, extreme sports), content harmful under other categories (use other guardrails), and unrelated content. |
Labeling rules:
1.0.Intended use:
The model is small enough to run on every response, where larger policy models may be too slow or costly.
Mila does not endorse any use that seeks to bypass safeguards, operationalize harmful behavior, or weaken human oversight in high-stakes contexts.
Out-of-scope use:
Internal evaluation set: 3,393 English responses, each with a French translation. The evaluation set is private and will not be released.
For the recall operating points, τ is the threshold that reaches the target recall, rounded to 2 decimals.
English (n = 3,393). AUPRC: 0.1.0-beta.2 = 0.970, 0.1.0-beta.3 = 0.997.
| Model | Operating point | Precision | Recall |
|---|---|---|---|
| 0.1.0-beta.2 | τ = 0.5 | 0.978 ± 0.005 | 0.791 ± 0.012 |
| 0.1.0-beta.2 | Recall ≥ 0.90 (τ = 0.03) | 0.921 ± 0.015 | ≥ 0.90 |
| 0.1.0-beta.2 | Recall ≥ 0.95 (τ = 0.00) | 0.826 ± 0.025 | ≥ 0.95 |
| 0.1.0-beta.2 | Recall ≥ 0.99 (τ = 0.00) | 0.578 ± 0.038 | ≥ 0.99 |
| 0.1.0-beta.3 | τ = 0.5 | 0.996 ± 0.002 | 0.910 ± 0.009 |
| 0.1.0-beta.3 | Recall ≥ 0.90 (τ = 0.52) | 0.996 ± 0.002 | ≥ 0.90 |
| 0.1.0-beta.3 | Recall ≥ 0.95 (τ = 0.35) | 0.992 ± 0.003 | ≥ 0.95 |
| 0.1.0-beta.3 | Recall ≥ 0.99 (τ = 0.08) | 0.944 ± 0.019 | ≥ 0.99 |
French (n = 3,393). AUPRC: 0.1.0-beta.3 = 0.996.
| Model | Operating point | Precision | Recall |
|---|---|---|---|
| 0.1.0-beta.3 | τ = 0.5 | 0.995 ± 0.002 | 0.882 ± 0.010 |
| 0.1.0-beta.3 | Recall ≥ 0.90 (τ = 0.44) | 0.995 ± 0.002 | ≥ 0.90 |
| 0.1.0-beta.3 | Recall ≥ 0.95 (τ = 0.22) | 0.987 ± 0.004 | ≥ 0.95 |
| 0.1.0-beta.3 | Recall ≥ 0.99 (τ = 0.04) | 0.897 ± 0.021 | ≥ 0.99 |
Note: 0.1.0-beta.2 was trained on English only, so French is not reported. Its previously published results (precision 0.908, recall 0.802 at τ = 0.5) used an older benchmark and are not comparable.
0 does not guarantee safety.Planned: multi-turn context, broader edge-case coverage, and improved multilingual support.
Training follows a policy-driven approach inspired by constitutional classifiers (Sharma et al., 2025): a natural-language policy defines which responses are acceptable, and that policy is used to label the data that supervises a small classifier. The constitution can be found in the artifacts, in constitution.md. The policy shapes the data and labels only. At inference, the model sees the response text alone.
The training data is private and will not be released.
bert-base-uncased to mmBERT-base.bert-base-uncased on the new dataset.@misc{mila-suicide-prevention-output-guardrail-0.1.0-beta.3-2026,
title={Mila Suicide Prevention Output Guardrail (0.1.0-beta.3)},
author={Mila AI4H},
year={2026},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/mila-ai4h/Mila-Suicide-Prevention-Output-Guardrail}}
}