Downloads · 30 days
31
2% of all-time downloads
malexandersalazar/xlm-roberta-base-cls-depression
xlm-roberta-base-cls-depression is a text classification model from malexandersalazar. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
Depression represents one of the most significant global health challenges of our time. According to the World Health Organization (2023), it affects 3.8% of the world's population—approximately 280 million people—mak…
Downloads · 30 days
31
2% of all-time downloads
All-time downloads
1.6K
Public
Parameters
278M
2.5 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors1.1 GB · 100%
From the Hugging Face model README
Depression represents one of the most significant global health challenges of our time. According to the World Health Organization (2023), it affects 3.8% of the world's population—approximately 280 million people—making it the leading cause of disability worldwide. The impact is particularly severe among younger populations, with WHO reporting that half of all mental health conditions begin before age 14, and suicide ranking as the fourth leading cause of death among 15-29 year-olds.
This multilingual depression detection model addresses this critical need by leveraging advanced natural language processing to identify depression indicators across six languages. Trained on a rich dataset of 40,000+ expressions generated using Anthropic's Claude 3.5 Sonnet, the model achieves high precision in detecting depression-related content. With depression and anxiety costing the global economy US$ 1 trillion annually in lost productivity (World Bank, 2023), tools for early detection and intervention are more crucial than ever.
The model is available on the Hugging Face Hub, offering a production-ready solution for mental health monitoring and support systems.
claude-3-5-sonnet-20241022) Message Batches APIInput Processing & Categories Definition
Dynamic Prompt & Data Generation
claude-3-5-sonnet-20241022) integration through Message Batches APIExternal Dataset Integration
tyqiangz/multilingual-sentiments dataset from Hugging FaceDataset Merging & Final Balancing
This summary includes a total of 37,441 dynamically generated texts.
Note: The integration of the external sentiment dataset, tyqiangz/multilingual-sentiments, has not been included in this summary.
The tyqiangz/multilingual-sentiments dataset offers baseline examples of a "Healthy" mental state, even when negative sentiments are present. While these texts may convey sadness or negative emotions, they do not exhibit clinical depression indicators or suicidal ideation. It is important to distinguish between general negative emotions and markers of clinical depression.
| Split | Samples | Percentage |
|---|---|---|
| Training | 8,028 | 70.0% |
| Validation | 2,294 | 20.0% |
| Test | 1,147 | 10.0% |
| Total | 11,469 | 100% |
The generated dataset, mental_health_texts.csv (malexandersalazar/mental-health-depression), features examples with explicit clinical depression indicators. The "Healthy" category includes texts reflecting a normal emotional range and resilience, while the "Unhealthy" category comprises texts exhibiting clear signs of depression and clinical manifestations.
| Split | Samples | Percentage |
|---|---|---|
| Training | 26,208 | 70.0% |
| Validation | 7,488 | 20.0% |
| Test | 3,745 | 10.0% |
| Total | 37,441 | 100% |
Total Dataset Size
Note: All splits maintain stratification across languages, categories, and text lengths to ensure representative sampling in each subset.
Results from evaluation on the test dataset:
Note: The test dataset maintains the same balanced distribution across languages, mental health states, categories, and text lengths as the training data, ensuring robust evaluation across all supported dimensions.
| Model | Accuracy | Precision | Recall | F1 Score |
|---|---|---|---|---|
| depression-reddit-distilroberta-base | 0.7604 | 0.6937 | 0.9360 | 0.7968 |
| xlm-roberta-base-cls-depression | 0.7841 | 0.8458 | 0.6967 | 0.7640 |
| finetuned-distil-bert-depression | 0.7135 | 0.6475 | 0.9419 | 0.7674 |
| finetuned-roberta-depression | 0.6820 | 0.6164 | 0.9701 | 0.7538 |
| distilroberta-base-finetuned-suicide-depression | 0.5663 | 0.5605 | 0.6291 | 0.5928 |
The xlm-roberta-base-cls-depression model demonstrates strong performance, achieving the highest accuracy and precision among compared models. This is particularly noteworthy given that it maintains multilingual capabilities while competing against English-specialized models. The results suggest effective transfer learning and robust depression detection capabilities across different linguistic contexts.
from transformers import AutoModelForSequenceClassification, AutoTokenizer
# Load model directly from Hugging Face Hub
model = AutoModelForSequenceClassification.from_pretrained("malexandersalazar/xlm-roberta-base-cls-depression")
tokenizer = AutoTokenizer.from_pretrained("FacebookAI/xlm-roberta-base")
# Labels/Prediction Values:
# 1: Depression Indicators Present
# 0: No Depression Indicators
# For inference
text = "Your text here"
inputs = tokenizer(
text,
padding="max_length",
truncation=True,
max_length=512,
return_tensors="pt"
)
outputs = model(**inputs)
prediction = outputs.logits.argmax(-1).item()
xlm-roberta-base-cls-depression/
├── data/
│ ├── source/ # Raw data sources
│ ├── raw/ # Generated texts
│ ├── clean/ # Processed datasets
│ ├── models/ # Trained models
│ └── dist/ # Optimized models
├── notebooks/
│ ├── 1. generator.ipynb # Dataset generation
│ ├── 2. pre_processor.ipynb # Text preprocessing
│ ├── 3. trainer.ipynb # Model training
│ ├── 4. post_training.ipynb # ONNX optimization
│ └── 5. test.ipynb # Model testing
└── requirements.txt
This model is designed for research and supportive purposes only. It should not be used as a diagnostic tool or replacement for professional mental health evaluation. Always consult qualified mental health professionals for actual diagnosis and treatment.
This project is licensed under the MIT License - see the LICENSE file for details.
Depresión: Cómo comprenderla y superarla - This book provided invaluable insights into understanding depression as a mental health condition and helped shape my approach to responsible dataset generationtyqiangz/multilingual-sentiments datasetIf you use this model in your research, please cite:
@software{malexandersalazar_xlm_roberta_base_cls_depression,
author = {Alexander Salazar},
title = {XLM-RoBERTa Depression Detection Model},
year = {2025},
month = {1},
url = {https://github.com/malexandersalazar/xlm-roberta-base-cls-depression},
version = {1.0.0},
date = {2025-01-03},
abstract = {A fine-tuned XLM-RoBERTa model for detecting depression indicators in multilingual text, trained on a rich dataset of 40,000+ expressions generated using Claude 3.5 Sonnet (claude-3-5-sonnet-20241022) through the Message Batches API. The model achieves high precision and is available on the Hugging Face Hub.},
keywords = {depression-detection, mental-health, xlm-roberta, multilingual, natural-language-processing}
}