Text Classification
Transformers
Safetensors
English
emotion-classification
healthcare
distilbert
patient-doctor-conversations
clinical-AI
mental-health
Instructions to use StringJammer/patient-emotion-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use StringJammer/patient-emotion-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="StringJammer/patient-emotion-classifier")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("StringJammer/patient-emotion-classifier", dtype="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse files
README.md
CHANGED
|
@@ -9,6 +9,8 @@ tags:
|
|
| 9 |
- distilbert
|
| 10 |
- patient-doctor-conversations
|
| 11 |
- text-classification
|
|
|
|
|
|
|
| 12 |
model_index:
|
| 13 |
- name: patient-emotion-classifier
|
| 14 |
results:
|
|
@@ -16,34 +18,61 @@ model_index:
|
|
| 16 |
type: text-classification
|
| 17 |
metrics:
|
| 18 |
- type: accuracy
|
| 19 |
-
value: 0.
|
| 20 |
- type: f1
|
| 21 |
-
value: 0.
|
| 22 |
---
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
| Category | Description |
|
| 31 |
|----------|-------------|
|
| 32 |
-
| Neutral |
|
| 33 |
-
| Anxiety/Fear | Patient expresses worry or fear |
|
| 34 |
-
| Anger/Frustration | Patient shows frustration or
|
| 35 |
-
| Sadness/Helplessness | Patient feels
|
| 36 |
-
| Confusion/Doubt | Patient expresses
|
| 37 |
-
| Gratitude/Relief | Patient
|
| 38 |
|
| 39 |
-
## Model Performance
|
| 40 |
|
| 41 |
### Overall Metrics
|
| 42 |
|
| 43 |
| Metric | Value |
|
| 44 |
|--------|-------|
|
| 45 |
-
| Accuracy | 71.3% |
|
| 46 |
-
| Macro F1 | 0.
|
| 47 |
| Weighted F1 | 0.72 |
|
| 48 |
|
| 49 |
### Per-Class Performance
|
|
@@ -61,53 +90,58 @@ NLP emotion classification model for patient-doctor conversations.
|
|
| 61 |
|
| 62 |

|
| 63 |
|
| 64 |
-
## Quick Start
|
| 65 |
|
| 66 |
### 1. Install Dependencies
|
| 67 |
|
| 68 |
```bash
|
| 69 |
pip install -r requirements.txt
|
| 70 |
-
```
|
| 71 |
|
| 72 |
-
### 2.
|
| 73 |
|
| 74 |
```bash
|
| 75 |
cd see
|
| 76 |
python app.py
|
| 77 |
-
```
|
| 78 |
|
| 79 |
-
### 3.
|
| 80 |
|
| 81 |
-
```
|
| 82 |
http://localhost:8002
|
| 83 |
-
```
|
| 84 |
|
| 85 |
-
## Dataset
|
| 86 |
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
- **
|
|
|
|
|
|
|
| 90 |
- **Categories**: 6 emotion labels
|
| 91 |
- **Language**: English
|
| 92 |
|
| 93 |
-
##
|
| 94 |
|
| 95 |
-
|
| 96 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
-
##
|
| 99 |
|
| 100 |
-
```
|
| 101 |
patient-emotion-analysis/
|
| 102 |
-
βββ best_model/ #
|
| 103 |
βββ see/ # Inference service
|
| 104 |
-
β βββ app.py
|
| 105 |
-
β βββ inference.py
|
| 106 |
-
β βββ templates/
|
| 107 |
-
βββ data/
|
| 108 |
-
βββ requirements.txt
|
| 109 |
-
βββ README.md
|
| 110 |
-
|
|
|
|
| 111 |
|
|
|
|
| 112 |
|
|
|
|
| 113 |
|
|
|
|
|
|
| 9 |
- distilbert
|
| 10 |
- patient-doctor-conversations
|
| 11 |
- text-classification
|
| 12 |
+
- clinical-AI
|
| 13 |
+
- mental-health
|
| 14 |
model_index:
|
| 15 |
- name: patient-emotion-classifier
|
| 16 |
results:
|
|
|
|
| 18 |
type: text-classification
|
| 19 |
metrics:
|
| 20 |
- type: accuracy
|
| 21 |
+
value: 0.713
|
| 22 |
- type: f1
|
| 23 |
+
value: 0.722
|
| 24 |
---
|
| 25 |
|
| 26 |
+
<div align="center">
|
| 27 |
|
| 28 |
+
# π€ Patient Emotion Classifier
|
| 29 |
|
| 30 |
+
**Advanced AI-Powered Emotion Recognition for Healthcare Dialogues**
|
| 31 |
+
|
| 32 |
+
*Part of the Blended AI+X Initiative β Bridging Artificial Intelligence and Healthcare*
|
| 33 |
+
|
| 34 |
+
---
|
| 35 |
+
|
| 36 |
+
[](https://huggingface.co/distilbert/distilbert-base-uncased)
|
| 37 |
+
[](LICENSE)
|
| 38 |
+
[]()
|
| 39 |
+
|
| 40 |
+
</div>
|
| 41 |
+
|
| 42 |
+
## π¬ Overview
|
| 43 |
+
|
| 44 |
+
We are thrilled to introduce **Patient Emotion Classifier**, a state-of-the-art NLP model engineered to understand emotional nuances in patient-doctor conversations.
|
| 45 |
+
|
| 46 |
+
This model represents our commitment to advancing **AI for Healthcare (AI+X)**, leveraging cutting-edge transformer architectures to bridge the gap between artificial intelligence and compassionate care.
|
| 47 |
+
|
| 48 |
+
### Key Capabilities
|
| 49 |
+
|
| 50 |
+
- **Multiclass Emotion Recognition** β Identifies 6 distinct emotional states in clinical dialogues
|
| 51 |
+
- **Healthcare-Optimized** β Specifically trained on medical conversation data
|
| 52 |
+
- **Production-Ready** β Deployable via REST API for real-time inference
|
| 53 |
+
- **Lightweight & Efficient** β Built on DistilBERT for fast inference
|
| 54 |
+
|
| 55 |
+
## π― Emotion Categories
|
| 56 |
+
|
| 57 |
+
Our model classifies emotional states into **6 clinically-relevant categories**:
|
| 58 |
|
| 59 |
| Category | Description |
|
| 60 |
|----------|-------------|
|
| 61 |
+
| π **Neutral** | Objective, non-emotional statements |
|
| 62 |
+
| π° **Anxiety/Fear** | Patient expresses worry, concern, or fear |
|
| 63 |
+
| π **Anger/Frustration** | Patient shows frustration or displeasure |
|
| 64 |
+
| π’ **Sadness/Helplessness** | Patient feels down or hopeless |
|
| 65 |
+
| π€ **Confusion/Doubt** | Patient expresses uncertainty or questions |
|
| 66 |
+
| π **Gratitude/Relief** | Patient conveys thanks or relief |
|
| 67 |
|
| 68 |
+
## π Model Performance
|
| 69 |
|
| 70 |
### Overall Metrics
|
| 71 |
|
| 72 |
| Metric | Value |
|
| 73 |
|--------|-------|
|
| 74 |
+
| **Accuracy** | **71.3%** |
|
| 75 |
+
| **Macro F1** | **0.722** |
|
| 76 |
| Weighted F1 | 0.72 |
|
| 77 |
|
| 78 |
### Per-Class Performance
|
|
|
|
| 90 |
|
| 91 |

|
| 92 |
|
| 93 |
+
## π Quick Start
|
| 94 |
|
| 95 |
### 1. Install Dependencies
|
| 96 |
|
| 97 |
```bash
|
| 98 |
pip install -r requirements.txt
|
|
|
|
| 99 |
|
| 100 |
+
### 2. Launch the Service
|
| 101 |
|
| 102 |
```bash
|
| 103 |
cd see
|
| 104 |
python app.py
|
|
|
|
| 105 |
|
| 106 |
+
### 3. Access the Interface
|
| 107 |
|
|
|
|
| 108 |
http://localhost:8002
|
|
|
|
| 109 |
|
| 110 |
+
## π Dataset
|
| 111 |
|
| 112 |
+
This model was trained on a meticulously curated subset of medical dialogues:
|
| 113 |
+
|
| 114 |
+
- **Original Source**: [Chinese MedDialog Dataset](https://tianchi.aliyun.com/dataset/92110) β Alibaba Cloud Tianchi
|
| 115 |
+
- **Post-Processing**: Carefully filtered, translated, and annotated for emotion classification
|
| 116 |
+
- **Total Samples**: 28,280 annotated dialogues
|
| 117 |
- **Categories**: 6 emotion labels
|
| 118 |
- **Language**: English
|
| 119 |
|
| 120 |
+
## ποΈ Technical Specifications
|
| 121 |
|
| 122 |
+
| Component | Details |
|
| 123 |
+
|-----------|---------|
|
| 124 |
+
| **Base Architecture** | [DistilBERT](https://huggingface.co/distilbert/distilbert-base-uncased) |
|
| 125 |
+
| **Task Type** | 6-class emotion classification |
|
| 126 |
+
| **Max Sequence Length** | 512 tokens |
|
| 127 |
+
| **Framework** | PyTorch + Transformers |
|
| 128 |
|
| 129 |
+
## π Project Structure
|
| 130 |
|
|
|
|
| 131 |
patient-emotion-analysis/
|
| 132 |
+
βββ best_model/ # Fine-tuned model weights
|
| 133 |
βββ see/ # Inference service
|
| 134 |
+
β βββ app.py # Web application
|
| 135 |
+
β βββ inference.py # Core inference logic
|
| 136 |
+
β βββ templates/ # UI templates
|
| 137 |
+
βββ data/ # Training & evaluation data
|
| 138 |
+
βββ requirements.txt # Dependencies
|
| 139 |
+
βββ README.md # This file
|
| 140 |
+
|
| 141 |
+
---
|
| 142 |
|
| 143 |
+
<div align="center">
|
| 144 |
|
| 145 |
+
**Blended AI+X Initiative** β *Advancing Healthcare Through Intelligence*
|
| 146 |
|
| 147 |
+
</div>
|