Instructions to use code-world/bert-mental-health-detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use code-world/bert-mental-health-detection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="code-world/bert-mental-health-detection")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("code-world/bert-mental-health-detection") model = AutoModelForSequenceClassification.from_pretrained("code-world/bert-mental-health-detection") - Notebooks
- Google Colab
- Kaggle
BERT for Early Detection of Mental Health Disorders from Social Media Text
Fine-tuned bert-base-uncased for 5-class mental health classification of social media posts.
Developed as part of a COM748 Masters Research Project: Explainable Transformer Based Framework
for Early Detection of Mental Health Disorders from Social Media Text.
Classes
| ID | Label |
|---|---|
| 0 | Anxiety/Stress |
| 1 | Bipolar |
| 2 | Depression |
| 3 | Normal |
| 4 | Suicidal |
Performance (held-out test set, n = 7,106)
| Metric | Score |
|---|---|
| Accuracy | 83.4% |
| Macro F1 | 0.841 |
Per-class F1: Normal 0.953 路 Anxiety/Stress 0.882 路 Bipolar 0.858 路 Depression 0.770 路 Suicidal 0.742
For comparison, the same encoder used as a frozen feature extractor reached only 0.680 macro-F1, and a TF-IDF + XGBoost baseline reached 0.775.
Training data
~47,400 posts merged from two public Kaggle datasets: Sentiment Analysis for Mental Health and Depression: Reddit Dataset (Cleaned), deduplicated and mapped to 5 classes, split 70/15/15.
Training setup
- 3 epochs, batch size 16, max length 128, AdamW lr 2e-5, weight decay 0.01
- Linear warmup (10%) then linear decay, gradient clipping at 1.0
- Class-weighted cross-entropy to counter class imbalance
- Best checkpoint selected by validation macro-F1
Usage
from transformers import pipeline
clf = pipeline("text-classification", model="usman-isb/bert-mental-health-detection")
print(clf("lately I cannot stop worrying about everything, my heart races all day"))
Intended use & limitations
鈿狅笍 Research prototype only. This model is not a clinical diagnostic instrument and must not be used as a substitute for professional mental health assessment. Labels reflect patterns in self-reported social media text, not clinical diagnoses. Performance on text from other platforms, languages, or demographics is untested.
- Downloads last month
- 36
Model tree for code-world/bert-mental-health-detection
Base model
google-bert/bert-base-uncased