File size: 4,446 Bytes
343c0b6 3046351 a2be5b1 cfb6e15 343c0b6 dba0dda ec313ee dba0dda ec313ee dba0dda ec313ee dba0dda 0356fa3 dba0dda ab6b58b dba0dda ec313ee dba0dda 0356fa3 dba0dda 0356fa3 dba0dda 0356fa3 dba0dda 0356fa3 dba0dda ec313ee dba0dda 72a723b dba0dda 764ae2b ec313ee 764ae2b ec313ee dba0dda 3046351 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | ---
license: cc-by-nc-4.0
language:
- de
base_model:
- google-bert/bert-base-german-cased
pipeline_tag: text-classification
tags:
- depression
- mental-health
- MADRS
- clinical
- interview
---
# MADRS-BERT
**MADRS-BERT** is a fine-tuned `bert-base-german-cased` model that predicts depression severity scores (0–6) across individual items of the [Montgomery-Åsberg Depression Rating Scale (MADRS)](https://en.wikipedia.org/wiki/MADRS). Each prediction is based on transcribed, structured clinician–patient interview segments.
- **Publication**: [https://www.nature.com/articles/s41746-025-01982-8#Sec8](https://www.nature.com/articles/s41746-025-01982-8#Sec8)
- **Example dataset**: [https://github.com/webersamantha/MADRS-BERT/data](https://github.com/webersamantha/MADRS-BERT/data)
- **Github Repo**: The code for data curation, finetuning and evaluation is shared in the following github repo: [https://github.com/webersamantha/MADRS-BERT](https://github.com/webersamantha/MADRS-BERT)
This model was developed to support standardized, scalable mental health assessments in both clinical and low-resource settings.
## Model Details
- **Base model**: `bert-base-german-cased`
- **Task**: Ordinal regression (scores 0–6)
- **Language**: German
- **Input**: Text (dialogue segment grouped by MADRS topic)
- **Output**: Predicted score for each MADRS item (rounded integer 0–6)
- **Training data**: Mix of real and synthetic clinician–patient interviews (MADRS-structured)
## Intended Use
This model is intended for research and development use. It is not a certified medical device. The goal is to:
- Explore AI-assisted symptom severity assessment
- Enable structured evaluation of individual MADRS items
- Support clinicians or researchers working in psychiatry/mental health
---
## 🚀 How to Use
### Preprocess Data File:
Please organize your data equivalent to the example data (synthetic data) with columns: Subject, Speaker, Transcription, Topic, Score.
```python
import pandas as pd
def load_and_prepare_conversations(filepath):
df = pd.read_excel(filepath)
conversations = []
for topic in df['Topic'].unique():
topic_df = df[df['Topic'] == topic]
if topic_df.empty: continue
dialogue = "\n".join([
f"{row['Speaker']}: {row['Transcription']}"
for _, row in topic_df.iterrows()
if pd.notnull(row['Transcription'])
])
conversations.append((topic, dialogue))
return conversations
```
### Load model and tokenizer:
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "webesama/MADRS-BERT"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval().to("cuda" if torch.cuda.is_available() else "cpu")
```
### Predict on a full structured interview / Run inference:
Assume you have a conversation log like this:
```python
def predict_madrs_scores(conversations, tokenizer, model):
device = model.device
predictions = {}
for topic, dialogue in conversations:
inputs = tokenizer(dialogue, truncation=True, padding="max_length", max_length=512, return_tensors="pt").to(device)
with torch.no_grad():
score = torch.round(model(**inputs).logits).clamp(0, 6).item()
predictions[topic] = score
return predictions
file_path = "example_interview.xlsx"
conversations = load_and_prepare_conversations(file_path)
scores = predict_madrs_scores(conversations, tokenizer, model)
print(scores)
```
---
## Acknowledgements
Model trained and released by [Samantha Weber](https://github.com/webersamantha) within the framework of the [Multicast Project on predicting and treating suicidality](https://www.multicast.uzh.ch/en.html). Research conducted as part of efforts to improve AI-driven mental health tools. Thanks to all clinicians and collaborators who contributed to the annotated MADRS dataset.
## Evaluation
The model was evaluated on a held-out clinical validation set and achieved strong performance under both strict and flexible scoring criteria (±1 deviation tolerance). See publication for full metrics.
## Citation
If you use this model, please cite:
> Weber, S. et al. (2025). "Using a Fine-tuned Large Language Model for Symptom-based Depression Evaluation" (DOI: https://doi.org/10.1038/s41746-025-01982-8) |