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
- precision
|
| 8 |
+
- recall
|
| 9 |
+
base_model:
|
| 10 |
+
- microsoft/deberta-v2-xlarge
|
| 11 |
+
pipeline_tag: text-classification
|
| 12 |
+
tags:
|
| 13 |
+
- conversation-ending
|
| 14 |
+
- healthcare
|
| 15 |
+
- chatbot
|
| 16 |
+
- text-classification
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# EndConvo-health-deberta-v2
|
| 20 |
+
|
| 21 |
+
## Model Description
|
| 22 |
+
The **EndConvo-health-deberta-v2** is a fine-tuned conversational AI model based on the **DeBERTa** architecture. It is designed for binary classification tasks to determine whether a conversation in a health-related chatbot has reached its endpoint or should continue. The model significantly improves efficiency by identifying conversation closure, especially in healthcare applications, where accurate and timely responses are crucial.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## Intended Use
|
| 27 |
+
- **Primary Use Case:** End-of-conversation detection in health-related chatbot systems.
|
| 28 |
+
- **Scope of Application:** Healthcare dialogues, customer support automation, or any domain requiring conversational flow control.
|
| 29 |
+
- **Limitations:**
|
| 30 |
+
- Reduced recall for the "True" (conversation ending) class, which could affect performance in ambiguous scenarios.
|
| 31 |
+
- The model requires GPU support for efficient inference on large-scale data.
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## Training Dataset
|
| 36 |
+
- **Dataset Name:** Custom health-related conversational dataset (`conversation_dataset.csv`).
|
| 37 |
+
- **Structure:** Binary classification dataset with labels:
|
| 38 |
+
- `0` for "Continue conversation"
|
| 39 |
+
- `1` for "End conversation."
|
| 40 |
+
- **Size:** 4,000 training samples and 1,000 validation samples.
|
| 41 |
+
- **Source:** Annotated conversational data designed for healthcare-related use cases.
|
| 42 |
+
- **Preprocessing:**
|
| 43 |
+
- Tokenization using DeBERTa tokenizer.
|
| 44 |
+
- Maximum sequence length of 256 tokens.
|
| 45 |
+
- Truncation applied for longer conversations.
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Model Details
|
| 50 |
+
- **Base Model:** DeBERTa-V2
|
| 51 |
+
- **Training Framework:** Hugging Face Transformers
|
| 52 |
+
- **Optimizer:** AdamW with weight decay
|
| 53 |
+
- **Loss Function:** Cross-entropy loss
|
| 54 |
+
- **Batch Size:** 16
|
| 55 |
+
- **Epochs:** 3
|
| 56 |
+
- **Learning Rate:** 5e-5
|
| 57 |
+
- **Evaluation Metric:** Accuracy, Precision, Recall, F1-score
|
| 58 |
+
|
| 59 |
+
---
|
| 60 |
+
|
| 61 |
+
## Evaluation Metrics
|
| 62 |
+
- **Overall Accuracy:** 86.6%
|
| 63 |
+
- **Precision:** 86.7%
|
| 64 |
+
- **Recall:** 58.0%
|
| 65 |
+
- **F1-Score:** 69.5%
|
| 66 |
+
- **Validation Loss:** 0.3729
|
| 67 |
+
|
| 68 |
+
### Confusion Matrix
|
| 69 |
+
- **True Negatives (TN):** 71.29%
|
| 70 |
+
- **False Positives (FP):** 2.35%
|
| 71 |
+
- **False Negatives (FN):** 11.06%
|
| 72 |
+
- **True Positives (TP):** 15.29%
|
| 73 |
+
|
| 74 |
+
### Detailed Report
|
| 75 |
+
|
| 76 |
+
| Class | Precision | Recall | F1-Score | Support |
|
| 77 |
+
|-------------------------|-----------|--------|----------|---------|
|
| 78 |
+
| **False (Continue)** | 0.87 | 0.97 | 0.91 | 313 |
|
| 79 |
+
| **True (End)** | 0.87 | 0.58 | 0.70 | 112 |
|
| 80 |
+
| **Macro Average** | 0.87 | 0.77 | 0.80 | - |
|
| 81 |
+
| **Weighted Average** | 0.87 | 0.87 | 0.86 | - |
|
| 82 |
+
|
| 83 |
+
---
|
| 84 |
+
|
| 85 |
+
## Pipeline and Usage
|
| 86 |
+
- **Task Type:** Text classification for conversation flow.
|
| 87 |
+
- **Pipeline:** Predicts whether a conversation should continue or end.
|
| 88 |
+
|
| 89 |
+
### Example Usage
|
| 90 |
+
|
| 91 |
+
```python
|
| 92 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 93 |
+
|
| 94 |
+
# Load tokenizer and model
|
| 95 |
+
tokenizer = AutoTokenizer.from_pretrained("MathewManoj/EndConvo-health-deberta-v2")
|
| 96 |
+
model = AutoModelForSequenceClassification.from_pretrained("MathewManoj/EndConvo-health-deberta-v2")
|
| 97 |
+
|
| 98 |
+
# Example text input
|
| 99 |
+
text = "Thank you for your help. I don't have any more questions."
|
| 100 |
+
|
| 101 |
+
# Tokenize the input
|
| 102 |
+
inputs = tokenizer(text, return_tensors="pt")
|
| 103 |
+
outputs = model(**inputs)
|
| 104 |
+
|
| 105 |
+
# Prediction
|
| 106 |
+
prediction = outputs.logits.argmax(dim=-1).item()
|
| 107 |
+
print("Prediction:", "End" if prediction == 1 else "Continue")
|
| 108 |
+
```
|
| 109 |
+
---
|
| 110 |
+
|
| 111 |
+
## Performance Insights
|
| 112 |
+
### Strengths:
|
| 113 |
+
- High accuracy and precision indicate the model performs well in correctly identifying most "Continue" conversations.
|
| 114 |
+
|
| 115 |
+
### Limitations:
|
| 116 |
+
- Lower recall for "End" conversations suggests the need for additional data augmentation or fine-tuning to improve sensitivity.
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
|
| 120 |
+
## Environment and Dependencies
|
| 121 |
+
- **Framework:** Hugging Face Transformers (v4.46.3)
|
| 122 |
+
- **Python Version:** 3.8+
|
| 123 |
+
- **Dependencies:**
|
| 124 |
+
- `torch`
|
| 125 |
+
- `transformers`
|
| 126 |
+
- `safetensors`
|
| 127 |
+
- `numpy`
|
| 128 |
+
|
| 129 |
+
### Conda Environment Configuration
|
| 130 |
+
|
| 131 |
+
```yaml
|
| 132 |
+
name: huggingface-env
|
| 133 |
+
channels:
|
| 134 |
+
- defaults
|
| 135 |
+
- conda-forge
|
| 136 |
+
dependencies:
|
| 137 |
+
- python=3.8
|
| 138 |
+
- pip
|
| 139 |
+
- pip:
|
| 140 |
+
- torch==2.4.1
|
| 141 |
+
- transformers==4.46.3
|
| 142 |
+
- safetensors
|
| 143 |
+
```
|
| 144 |
+
---
|
| 145 |
+
|
| 146 |
+
## Model Limitations
|
| 147 |
+
1. The model exhibits reduced recall for the **"End conversation"** class, which could impact its utility in edge cases.
|
| 148 |
+
2. Requires labeled data for fine-tuning in other domains or applications.
|