Views
No views yet
| Metric | Score |
|---|---|
| F1-Score | 0.298 |
| Precision | 0.459 |
| Recall | 0.260 |
| Accuracy | 89.5% |
| Improvement | 7.6x over baseline |
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
3
4# Load model and tokenizer
5tokenizer = AutoTokenizer.from_pretrained("YOUR_USERNAME/mental-health-enhanced-distilbert")
6model = AutoModelForSequenceClassification.from_pretrained("YOUR_USERNAME/mental-health-enhanced-distilbert")
7
8# Example usage
9text = "I'm feeling really anxious about tomorrow"
10inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
11
12with torch.no_grad():
13 outputs = model(**inputs)
14 predictions = torch.sigmoid(outputs.logits)
15
16# Get emotion labels
17emotions = []
18for i, score in enumerate(predictions[0]):
19 if score > 0.4: # Threshold
20 emotion = model.config.id2label[i]
21 emotions.append((emotion, score.item()))
22
23print(emotions)Input Text → DistilBERT Encoder → Enhanced Classification Head
↓
Hidden Layer 1 (768→512)
↓
Hidden Layer 2 (512→256)
↓
Hidden Layer 3 (256→128)
↓
Output Layer (128→28)| Epoch | F1-Score | Precision | Recall |
|---|---|---|---|
| 1 | 0.0145 | 0.0419 | 0.0089 |
| 2 | 0.1430 | 0.2797 | 0.1211 |
| 3 | 0.2141 | 0.4751 | 0.1804 |
| 4 | 0.2749 | 0.4317 | 0.2340 |
| 5 | 0.2897 | 0.4524 | 0.2533 |
| 6 | 0.2981 | 0.4592 | 0.2597 |
@misc{mental-health-emotion-distilbert,
title={Mental Health Emotion Detection - Enhanced DistilBERT},
author={Your Name},
year={2024},
publisher={Hugging Face},
url={https://huggingface.co/YOUR_USERNAME/mental-health-enhanced-distilbert}
}