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
| language: | |
| - en | |
| license: apache-2.0 | |
| library_name: transformers | |
| tags: | |
| - emotion-classification | |
| - healthcare | |
| - distilbert | |
| - patient-doctor-conversations | |
| - text-classification | |
| - clinical-AI | |
| - mental-health | |
| model_index: | |
| - name: patient-emotion-classifier | |
| results: | |
| - task: | |
| type: text-classification | |
| metrics: | |
| - type: accuracy | |
| value: 0.713 | |
| - type: f1 | |
| value: 0.722 | |
| <div align="center"> | |
| # π€ Patient Emotion Classifier | |
| **Advanced AI-Powered Emotion Recognition for Healthcare Dialogues** | |
| *Part of the Blended AI+X Initiative β Bridging Artificial Intelligence and Healthcare* | |
| --- | |
| [](https://huggingface.co/distilbert/distilbert-base-uncased) | |
| [](LICENSE) | |
| []() | |
| </div> | |
| ## π¬ Overview | |
| We are thrilled to introduce **Patient Emotion Classifier**, a state-of-the-art NLP model engineered to understand emotional nuances in patient-doctor conversations. | |
| 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. | |
| ### Key Capabilities | |
| - **Multiclass Emotion Recognition** β Identifies 6 distinct emotional states in clinical dialogues | |
| - **Healthcare-Optimized** β Specifically trained on medical conversation data | |
| - **Production-Ready** β Deployable via REST API for real-time inference | |
| - **Lightweight & Efficient** β Built on DistilBERT for fast inference | |
| ## π― Emotion Categories | |
| Our model classifies emotional states into **6 clinically-relevant categories**: | |
| | Category | Description | | |
| |----------|-------------| | |
| | π **Neutral** | Objective, non-emotional statements | | |
| | π° **Anxiety/Fear** | Patient expresses worry, concern, or fear | | |
| | π **Anger/Frustration** | Patient shows frustration or displeasure | | |
| | π’ **Sadness/Helplessness** | Patient feels down or hopeless | | |
| | π€ **Confusion/Doubt** | Patient expresses uncertainty or questions | | |
| | π **Gratitude/Relief** | Patient conveys thanks or relief | | |
| ## π Model Performance | |
| ### Overall Metrics | |
| | Metric | Value | | |
| |--------|-------| | |
| | **Accuracy** | **71.3%** | | |
| | **Macro F1** | **0.722** | | |
| | Weighted F1 | 0.72 | | |
| ### Per-Class Performance | |
| | Emotion | Precision | Recall | F1-Score | | |
| |---------|-----------|--------|----------| | |
| | Neutral | 0.75 | 0.78 | 0.76 | | |
| | Anxiety/Fear | 0.52 | 0.63 | 0.57 | | |
| | Anger/Frustration | 0.80 | 0.73 | 0.76 | | |
| | Sadness/Helplessness | 0.65 | 0.55 | 0.60 | | |
| | Confusion/Doubt | 0.60 | 0.58 | 0.59 | | |
| | Gratitude/Relief | 0.72 | 0.75 | 0.73 | | |
| ### Label Distribution | |
|  | |
| ## π Quick Start | |
| ### 1. Install Dependencies | |
| ```bash | |
| pip install -r requirements.txt | |
| ### 2. Launch the Service | |
| ```bash | |
| cd see | |
| python app.py | |
| ### 3. Access the Interface | |
| http://localhost:8002 | |
| ## π Dataset | |
| This model was trained on a meticulously curated subset of medical dialogues: | |
| - **Original Source**: [Chinese MedDialog Dataset](https://tianchi.aliyun.com/dataset/92110) β Alibaba Cloud Tianchi | |
| - **Post-Processing**: Carefully filtered, translated, and annotated for emotion classification | |
| - **Total Samples**: 28,280 annotated dialogues | |
| - **Categories**: 6 emotion labels | |
| - **Language**: English | |
| ## π References | |
| 1. **MedDialog Dataset** | |
| Chinese Medical Dialogue Dataset. Alibaba Cloud Tianchi. | |
| https://tianchi.aliyun.com/dataset/92110 | |
| 2. **DistilBERT** | |
| Sanh, V., Debut, L., Chaumond, J., & Wolf, T. (2019). *DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter*. arXiv preprint arXiv:1910.01108. | |
| https://arxiv.org/abs/1910.01108 | |
| ## ποΈ Technical Specifications | |
| | Component | Details | | |
| |-----------|---------| | |
| | **Base Architecture** | [DistilBERT](https://huggingface.co/distilbert/distilbert-base-uncased) | | |
| | **Task Type** | 6-class emotion classification | | |
| | **Max Sequence Length** | 512 tokens | | |
| | **Framework** | PyTorch + Transformers | | |
| ## π Project Structure | |
| patient-emotion-analysis/ | |
| βββ best_model/ # Fine-tuned model weights | |
| βββ see/ # Inference service | |
| β βββ app.py # Web application | |
| β βββ inference.py # Core inference logic | |
| β βββ templates/ # UI templates | |
| βββ data/ # Training & evaluation data | |
| βββ requirements.txt # Dependencies | |
| βββ README.md # This file | |
| --- | |
| <div align="center"> | |
| **Blended AI+X Initiative** β *Advancing Healthcare Through Intelligence* | |
| </div> | |