Downloads · 30 days
76
2% of all-time downloads
ourafla/mental-health-bert-finetuned
mental-health-bert-finetuned is a text classification model from ourafla. 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 fine-tuned BERT-based model for multi-class mental health text classification, achieving 89.7% accuracy on held-out test data.
Downloads · 30 days
76
2% of all-time downloads
All-time downloads
4.6K
Public
Parameters
109M
876 MB on disk
Likes
12
Public
Click a slice to open those files.
.bin438 MB · 50%
From the Hugging Face model README
A fine-tuned BERT-based model for multi-class mental health text classification, achieving 89.7% accuracy on held-out test data.
This model is a fine-tuned version of mental/mental-bert-base-uncased designed to classify text into four mental health categories:
Base Model: MentalBERT (BERT-Base uncased, pre-trained on mental health-related Reddit posts)
Architecture: BertForSequenceClassification with 4 output labels
Parameters: ~110M (BERT-Base: 12 layers, 768 hidden dimensions, 12 attention heads)
⚠️ Important: This model is NOT intended for clinical diagnosis. It is a supplementary research tool and should not replace professional mental health evaluation or therapy. Model predictions are not psychiatric diagnoses, and anyone struggling with mental health issues should seek professional help.
The model was trained on a combined dataset from multiple sources, which were then integrated into a unified 4‑class corpus published as ourafla/Mental-Health_Text-Classification_Dataset.
Mental Health Text Classification Dataset (4‑Class)
ourafla/Mental-Health_Text-Classification_DatasetMukherjee, P. (2025). Mental Health Text Classification Dataset (4‑Class) [Dataset]. Hugging Face Hub. https://huggingface.co/datasets/ourafla/Mental-Health_Text-Classification_Dataset
Suicide Detection Dataset
Mental Health Social Media Posts
Sentiment Analysis for Mental Health
The final training corpus used for this model corresponds to the processed version released as ourafla/Mental-Health_Text-Classification_Dataset.
The model underwent 3 development phases:
| Metric | Score |
|---|---|
| Accuracy | 89.72% |
| Macro Precision | 89.56% |
| Macro Recall | 89.72% |
| Macro F1-Score | 89.54% |
| Class | Precision | Recall | F1-Score | Support |
|---|---|---|---|---|
| Anxiety | 0.88 | 0.85 | 0.87 | 248 |
| Depression | 0.86 | 0.78 | 0.82 | 248 |
| Normal | 0.94 | 0.98 | 0.96 | 248 |
| Suicidal | 0.91 | 0.98 | 0.94 | 248 |
To better understand the model’s behaviour beyond aggregate metrics, an additional evaluation notebook is provided on Kaggle. This analysis focuses on class-wise errors, confusion patterns, and probability calibration, with particular attention to uncertainty in linguistically overlapping categories such as Anxiety and Depression.
The intent of this evaluation is not to claim clinical reliability, but to transparently examine where the model performs well and where it remains limited.
pip install transformers torch
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
# Load model and tokenizer
model_name = "mental/mental-bert-base-uncased"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=4)
# Load fine-tuned weights
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model.load_state_dict(torch.load("best_phase3.pth", map_location=device))
model.to(device)
model.eval()
# Define label mapping
id2label = {0: "Anxiety", 1: "Depression", 2: "Normal", 3: "Suicidal"}
# Example inference
text = "I've been feeling really overwhelmed and anxious lately"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
inputs = {k: v.to(device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model(**inputs)
prediction = torch.argmax(outputs.logits, dim=-1).item()
print(f"Predicted class: {id2label[prediction]}")
texts = [
"I feel hopeless and don't see the point anymore",
"Had a great day today, feeling positive!",
"My heart is racing and I can't stop worrying"
]
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True, max_length=128)
inputs = {k: v.to(device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=-1)
for text, pred in zip(texts, predictions):
print(f"Text: {text[:50]}...")
print(f"Predicted: {id2label[pred.item()]}\n")
Priyangshu Mukherjee
For questions or concerns about this model:
If you use this model in your research, please cite:
@software{mental_health_classifier_2025,
author = {Mukherjee, Priyangshu},
title = {Mental Health Text Classifier (MentalBERT Fine-tuned)},
year = {2025},
note = {Fine-tuned model for multi-class mental health text classification}
}
Base Model Citation:
@inproceedings{ji2022mentalbert,
title = {{MentalBERT: Publicly Available Pretrained Language Models for Mental Healthcare}},
author = {Shaoxiong Ji and Tianlin Zhang and Luna Ansari and Jie Fu and Prayag Tiwari and Erik Cambria},
year = {2022},
booktitle = {Proceedings of LREC}
}
This model is released for research and non-commercial use. Please check the base model license at mental/mental-bert-base-uncased for additional terms.
v3.0 (Phase 3): Enhanced model with improved data balancing and class weights
v2.0 (Phase 2): Refined preprocessing and training procedures
v1.0 (Phase 1): Initial baseline model
BertForSequenceClassification(
(bert): BertModel(
(embeddings): BertEmbeddings(...)
(encoder): BertEncoder(
12 x BertLayer(...)
)
(pooler): BertPooler(...)
)
(dropout): Dropout(p=0.1)
(classifier): Linear(768 -> 4)
)