Text Classification
Transformers
Safetensors
English
bert
mental-health
social-media
text-embeddings-inference
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")# pip install -U transformers accelerate # 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", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from code-world/bert-mental-health-detection: direct link, hf CLI and curl.
- Browser
- Download file 2.31 kB
-
https://huggingface.co/code-world/bert-mental-health-detection/resolve/main/README.md
- Command line
-
hf download hf://code-world/bert-mental-health-detection/README.md
-
curl -L -o README.md https://huggingface.co/code-world/bert-mental-health-detection/resolve/main/README.md
2.31 kB
| language: en | |
| license: mit | |
| library_name: transformers | |
| pipeline_tag: text-classification | |
| base_model: google-bert/bert-base-uncased | |
| tags: | |
| - mental-health | |
| - text-classification | |
| - bert | |
| - social-media | |
| metrics: | |
| - accuracy | |
| - f1 | |
| # 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](https://www.kaggle.com/datasets/suchintikasarkar/sentiment-analysis-for-mental-health) | |
| and [Depression: Reddit Dataset (Cleaned)](https://www.kaggle.com/datasets/infamouscoder/depression-reddit-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 | |
| ```python | |
| 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. | |