Text Classification
Transformers
Safetensors
PyTorch
English
bert
distilbert
multiclass-classification
mental-health
text-embeddings-inference
Instructions to use gaguine/PsychoClass with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use gaguine/PsychoClass with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="gaguine/PsychoClass")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("gaguine/PsychoClass") model = AutoModelForSequenceClassification.from_pretrained("gaguine/PsychoClass", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,158 @@
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: text-classification
|
| 7 |
+
base_model: distilbert/distilbert-base-multilingual-cased
|
| 8 |
+
tags:
|
| 9 |
+
- distilbert
|
| 10 |
+
- text-classification
|
| 11 |
+
- multiclass-classification
|
| 12 |
+
- mental-health
|
| 13 |
+
- pytorch
|
| 14 |
+
metrics:
|
| 15 |
+
- f1
|
| 16 |
---
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# Mental State Text Classification with DistilBERT
|
| 21 |
+
|
| 22 |
+
This model is a fine-tuned version of
|
| 23 |
+
[`distilbert/distilbert-base-multilingual-cased`](https://huggingface.co/distilbert/distilbert-base-multilingual-cased)
|
| 24 |
+
for multiclass classification of short English statements into seven mental-state categories.
|
| 25 |
+
|
| 26 |
+
It was developed as part of a 2026 master's thesis on language modelling and fine-tuning language models for mental-state text classification.
|
| 27 |
+
|
| 28 |
+
> **Important:** This is a research model, not a medical or psychological diagnostic system. Its output must not be interpreted as a clinical diagnosis, risk assessment, or substitute for a qualified professional.
|
| 29 |
+
|
| 30 |
+
## Model description
|
| 31 |
+
|
| 32 |
+
- **Task:** Multiclass text classification
|
| 33 |
+
- **Base model:** `distilbert/distilbert-base-multilingual-cased`
|
| 34 |
+
- **Architecture:** DistilBERT with a sequence-classification head
|
| 35 |
+
- **Number of classes:** 7
|
| 36 |
+
- **Recommended input:** One sentence or a short statement
|
| 37 |
+
- **Maximum training sequence length:** 256 tokens
|
| 38 |
+
- **Framework:** PyTorch and Hugging Face Transformers
|
| 39 |
+
|
| 40 |
+
The base model contains six Transformer layers, a hidden size of 768, 12 attention heads, and approximately 134 million parameters. It was selected to provide a practical balance between classification performance and computational requirements.
|
| 41 |
+
|
| 42 |
+
## Labels
|
| 43 |
+
|
| 44 |
+
| ID | Label |
|
| 45 |
+
|---:|---|
|
| 46 |
+
| 0 | Normal |
|
| 47 |
+
| 1 | Depression |
|
| 48 |
+
| 2 | Suicidal |
|
| 49 |
+
| 3 | Anxiety |
|
| 50 |
+
| 4 | Stress |
|
| 51 |
+
| 5 | Bipolar |
|
| 52 |
+
| 6 | Personality disorder |
|
| 53 |
+
|
| 54 |
+
The predicted categories describe patterns learned from the dataset. They do not establish whether a person has any medical condition.
|
| 55 |
+
|
| 56 |
+
## Intended use
|
| 57 |
+
|
| 58 |
+
The model is intended for:
|
| 59 |
+
|
| 60 |
+
- research on multiclass text classification;
|
| 61 |
+
- educational demonstrations of fine-tuning DistilBERT;
|
| 62 |
+
- exploratory analysis of short statements;
|
| 63 |
+
- prototyping systems that require human review of model predictions.
|
| 64 |
+
|
| 65 |
+
The model is not intended for:
|
| 66 |
+
|
| 67 |
+
- clinical diagnosis or treatment decisions;
|
| 68 |
+
- emergency or suicide-risk assessment;
|
| 69 |
+
- autonomous moderation or decisions affecting access to care, employment, education, insurance, or other high-impact services;
|
| 70 |
+
- surveillance or profiling of individuals;
|
| 71 |
+
- use without appropriate privacy protections and informed consent.
|
| 72 |
+
|
| 73 |
+
## Training data
|
| 74 |
+
|
| 75 |
+
The model was fine-tuned on the Kaggle
|
| 76 |
+
[`Sentiment Analysis for Mental Health`](https://www.kaggle.com/datasets/suchintikasarkar/sentiment-analysis-for-mental-health)
|
| 77 |
+
dataset. The dataset contains 51,074 labelled statements collected from several public online sources, including social-media platforms, forums, Twitter/X, and Reddit.
|
| 78 |
+
|
| 79 |
+
The class distribution reported in the thesis is imbalanced:
|
| 80 |
+
|
| 81 |
+
| Class | Approximate share |
|
| 82 |
+
|---|---:|
|
| 83 |
+
| Normal | 31% |
|
| 84 |
+
| Depression | 29% |
|
| 85 |
+
| Suicidal | 20% |
|
| 86 |
+
| Anxiety | 7% |
|
| 87 |
+
| Bipolar | 5% |
|
| 88 |
+
| Stress | 5% |
|
| 89 |
+
| Personality disorder | 2% |
|
| 90 |
+
|
| 91 |
+
Because the dataset aggregates multiple sources, its examples may differ in writing style, length, subject matter, annotation methods, and annotation reliability.
|
| 92 |
+
|
| 93 |
+
The data was randomly divided using seed 42 into approximately:
|
| 94 |
+
|
| 95 |
+
- 80% training data;
|
| 96 |
+
- 10% validation data;
|
| 97 |
+
- 10% test data.
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
## Training procedure
|
| 101 |
+
|
| 102 |
+
| Hyperparameter | Value |
|
| 103 |
+
|---|---:|
|
| 104 |
+
| Learning rate | `3e-5` |
|
| 105 |
+
| Training batch size per device | `8` |
|
| 106 |
+
| Evaluation batch size per device | `8` |
|
| 107 |
+
| Epochs | `15` |
|
| 108 |
+
| Maximum sequence length | `256` |
|
| 109 |
+
| Weight decay | `0.01` |
|
| 110 |
+
| Warmup ratio | `0.1` |
|
| 111 |
+
| Random seed | `42` |
|
| 112 |
+
|
| 113 |
+
Logging, validation, and checkpoint saving were performed after every epoch. Checkpoint selection was configured to maximize Macro F1.
|
| 114 |
+
|
| 115 |
+
## Evaluation
|
| 116 |
+
|
| 117 |
+
Macro F1 was the main evaluation metric because the dataset is imbalanced. The fine-tuned model reached a **test Macro F1 of 0.803**, compared with **0.096** for the unfine-tuned base model in the reported experiment.
|
| 118 |
+
|
| 119 |
+
### Test F1 by class
|
| 120 |
+
|
| 121 |
+
| Class | Base model | Fine-tuned model |
|
| 122 |
+
|---|---:|---:|
|
| 123 |
+
| Normal | 0.278 | 0.937 |
|
| 124 |
+
| Depression | 0.000 | 0.756 |
|
| 125 |
+
| Suicidal | 0.332 | 0.673 |
|
| 126 |
+
| Anxiety | 0.000 | 0.889 |
|
| 127 |
+
| Stress | 0.048 | 0.719 |
|
| 128 |
+
| Bipolar | 0.000 | 0.872 |
|
| 129 |
+
| Personality disorder | 0.014 | 0.774 |
|
| 130 |
+
| **Macro F1** | **0.096** | **0.803** |
|
| 131 |
+
|
| 132 |
+
The most important reported confusion was between the `Suicidal` and `Depression` categories. The model also sometimes classified `Stress` examples as `Normal`.
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
## Limitations and risks
|
| 137 |
+
|
| 138 |
+
- The dataset is class-imbalanced, and the least frequent classes may be less reliably represented.
|
| 139 |
+
- The dataset combines several online sources with potentially inconsistent annotation standards.
|
| 140 |
+
- Labels may reflect subjective or noisy annotations rather than clinical assessments.
|
| 141 |
+
- The model may learn unintended correlations with text length, vocabulary, platform, or writing style.
|
| 142 |
+
- Removing punctuation may discard useful emotional or semantic information.
|
| 143 |
+
- The model was designed for individual sentences and short statements. Long documents are truncated and may require sentence-level processing and aggregation.
|
| 144 |
+
- The model has difficulty distinguishing semantically related categories, especially `Depression` and `Suicidal`.
|
| 145 |
+
- Performance may decrease on languages, communities, platforms, and writing styles that differ from the training data.
|
| 146 |
+
- A high softmax score is model confidence, not proof that the predicted category is correct.
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
```bibtex
|
| 151 |
+
@mastersthesis{butera2026mentalstate,
|
| 152 |
+
author = {Butera, Gaetano Antonio},
|
| 153 |
+
title = {Language Modelling and Fine-Tuning Large Language Models for the Classification of Texts by Mental-State Category},
|
| 154 |
+
school = {Volga State University of Technology},
|
| 155 |
+
year = {2026}
|
| 156 |
+
}
|
| 157 |
+
```
|
| 158 |
+
|