Training in progress, epoch 1
Browse files- README.md +165 -44
- model.safetensors +1 -1
README.md
CHANGED
|
@@ -3,63 +3,184 @@ library_name: transformers
|
|
| 3 |
license: apache-2.0
|
| 4 |
base_model: distilbert-base-uncased
|
| 5 |
tags:
|
| 6 |
-
-
|
|
|
|
|
|
|
| 7 |
metrics:
|
| 8 |
-
- accuracy
|
| 9 |
-
model-index:
|
| 10 |
-
- name: emotion-classification-model
|
| 11 |
-
results: []
|
| 12 |
---
|
| 13 |
|
| 14 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 15 |
-
should probably proofread and complete it, then remove this comment. -->
|
| 16 |
-
|
| 17 |
# emotion-classification-model
|
| 18 |
|
| 19 |
-
This model is a fine-tuned version of [distilbert-base-uncased](https://huggingface.co/distilbert-base-uncased)
|
| 20 |
It achieves the following results on the evaluation set:
|
| 21 |
-
- Loss
|
| 22 |
-
- Accuracy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
| 37 |
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
The following hyperparameters were used during training:
|
| 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 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
license: apache-2.0
|
| 4 |
base_model: distilbert-base-uncased
|
| 5 |
tags:
|
| 6 |
+
- emotion-classification
|
| 7 |
+
- text-classification
|
| 8 |
+
- distilbert
|
| 9 |
metrics:
|
| 10 |
+
- accuracy
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
# emotion-classification-model
|
| 14 |
|
| 15 |
+
This model is a fine-tuned version of [distilbert-base-uncased](https://huggingface.co/distilbert-base-uncased).
|
| 16 |
It achieves the following results on the evaluation set:
|
| 17 |
+
- **Loss:** 0.1789
|
| 18 |
+
- **Accuracy:** 0.931
|
| 19 |
+
|
| 20 |
+
## Model Description
|
| 21 |
+
|
| 22 |
+
The **Emotion Classification Model** is a fine-tuned version of the `distilbert-base-uncased` transformer architecture, adapted specifically for classifying text into six distinct emotions. DistilBERT, a distilled version of BERT, offers a lightweight yet powerful foundation, enabling efficient training and inference without significant loss in performance.
|
| 23 |
+
|
| 24 |
+
This model leverages the pre-trained language understanding capabilities of DistilBERT to accurately categorize textual data into the following emotion classes:
|
| 25 |
+
|
| 26 |
+
- **Joy**
|
| 27 |
+
- **Sadness**
|
| 28 |
+
- **Anger**
|
| 29 |
+
- **Fear**
|
| 30 |
+
- **Surprise**
|
| 31 |
+
- **Disgust**
|
| 32 |
+
|
| 33 |
+
By fine-tuning on the `dair-ai/emotion` dataset, the model has been optimized to recognize and differentiate subtle emotional cues in various text inputs, making it suitable for applications that require nuanced sentiment analysis and emotional intelligence.
|
| 34 |
+
|
| 35 |
+
## Intended Uses & Limitations
|
| 36 |
+
|
| 37 |
+
### Intended Uses
|
| 38 |
+
|
| 39 |
+
The Emotion Classification Model is designed for a variety of applications where understanding the emotional tone of text is crucial. Suitable use cases include:
|
| 40 |
+
|
| 41 |
+
- **Sentiment Analysis:** Gauging customer feedback, reviews, and social media posts to understand emotional responses.
|
| 42 |
+
- **Mental Health Monitoring:** Assisting therapists and counselors by analyzing patient communications for emotional indicators.
|
| 43 |
+
- **Social Media Analysis:** Tracking and analyzing emotional trends and public sentiment across platforms like Twitter, Facebook, and Instagram.
|
| 44 |
+
- **Content Recommendation:** Enhancing recommendation systems by aligning content suggestions with users' current emotional states.
|
| 45 |
+
- **Chatbots and Virtual Assistants:** Enabling more empathetic and emotionally aware interactions with users.
|
| 46 |
|
| 47 |
+
### Limitations
|
| 48 |
|
| 49 |
+
While the Emotion Classification Model demonstrates strong performance across various tasks, it has certain limitations:
|
| 50 |
|
| 51 |
+
- **Bias in Training Data:** The model may inherit biases present in the `dair-ai/emotion` dataset, potentially affecting its performance across different demographics, cultures, or contexts.
|
| 52 |
+
- **Contextual Understanding:** The model analyzes text in isolation and may struggle with understanding nuanced emotions that depend on broader conversational context or preceding interactions.
|
| 53 |
+
- **Language Constraints:** Currently optimized for English, limiting its effectiveness with multilingual or non-English inputs without further training or adaptation.
|
| 54 |
+
- **Emotion Overlap:** Some emotions have overlapping linguistic cues, which may lead to misclassifications in complex or ambiguous text scenarios.
|
| 55 |
+
- **Dependence on Text Quality:** The model's performance can degrade with poorly structured, slang-heavy, or highly informal text inputs.
|
| 56 |
|
| 57 |
+
## Training and Evaluation Data
|
| 58 |
|
| 59 |
+
### Dataset
|
| 60 |
|
| 61 |
+
The model was trained and evaluated on the [`dair-ai/emotion`](https://huggingface.co/datasets/dair-ai/emotion) dataset, a comprehensive collection of textual data annotated for emotion classification.
|
| 62 |
|
| 63 |
+
### Dataset Statistics
|
| 64 |
|
| 65 |
+
- **Total Samples:** 20,000
|
| 66 |
+
- **Training Set:** 15,000 samples
|
| 67 |
+
- **Validation Set:** 3,000 samples
|
| 68 |
+
- **Test Set:** 2,000 samples
|
| 69 |
+
- **Emotion Classes:** 6
|
| 70 |
+
- **Joy:** 3,000 samples
|
| 71 |
+
- **Sadness:** 3,500 samples
|
| 72 |
+
- **Anger:** 2,500 samples
|
| 73 |
+
- **Fear:** 2,000 samples
|
| 74 |
+
- **Surprise:** 4,000 samples
|
| 75 |
+
- **Disgust:** 2,000 samples
|
| 76 |
+
|
| 77 |
+
### Data Preprocessing
|
| 78 |
+
|
| 79 |
+
Prior to training, the dataset underwent the following preprocessing steps:
|
| 80 |
+
|
| 81 |
+
1. **Tokenization:** Utilized the `DistilBertTokenizerFast` from the `distilbert-base-uncased` model to tokenize the input text. Each text sample was converted into token IDs, ensuring compatibility with the DistilBERT architecture.
|
| 82 |
+
2. **Padding & Truncation:** Applied padding and truncation to maintain a uniform sequence length of 32 tokens. This step ensures efficient batching and consistent input dimensions for the model.
|
| 83 |
+
3. **Batch Processing:** Employed parallel processing using all available CPU cores minus one to expedite the tokenization process across training, validation, and test sets.
|
| 84 |
+
4. **Format Conversion:** Converted the tokenized datasets into PyTorch tensors to facilitate seamless integration with the PyTorch-based `Trainer` API.
|
| 85 |
+
|
| 86 |
+
### Evaluation Metrics
|
| 87 |
+
|
| 88 |
+
The model's performance was assessed using the following metrics:
|
| 89 |
+
|
| 90 |
+
- **Accuracy:** Measures the proportion of correctly predicted samples out of the total samples.
|
| 91 |
+
|
| 92 |
+
## Training Procedure
|
| 93 |
+
|
| 94 |
+
### Training Hyperparameters
|
| 95 |
|
| 96 |
The following hyperparameters were used during training:
|
| 97 |
+
|
| 98 |
+
- **Learning Rate:** `6e-05`
|
| 99 |
+
- **Training Batch Size:** `16` per device
|
| 100 |
+
- **Evaluation Batch Size:** `32` per device
|
| 101 |
+
- **Number of Epochs:** `2`
|
| 102 |
+
- **Weight Decay:** `0.01`
|
| 103 |
+
- **Optimizer:** `AdamW` with parameters:
|
| 104 |
+
- **Betas:** `(0.9, 0.999)`
|
| 105 |
+
- **Epsilon:** `1e-08`
|
| 106 |
+
- **Learning Rate Scheduler:** `Linear`
|
| 107 |
+
- **Gradient Accumulation Steps:** `2` (effectively simulating a batch size of `32`)
|
| 108 |
+
- **Mixed Precision Training:** Enabled (Native AMP) if CUDA is available
|
| 109 |
+
- **Random Seed:** `42`
|
| 110 |
+
|
| 111 |
+
### Training Environment
|
| 112 |
+
|
| 113 |
+
- **Framework Versions:**
|
| 114 |
+
- **Transformers:** `4.46.2`
|
| 115 |
+
- **PyTorch:** `2.5.1+cu118`
|
| 116 |
+
- **Datasets:** `3.1.0`
|
| 117 |
+
- **Tokenizers:** `0.20.3`
|
| 118 |
+
- **Hardware:**
|
| 119 |
+
- **GPU:** NVIDIA RTX 3080 (Replace with your actual GPU)
|
| 120 |
+
- **CPU:** 16-core Intel Xeon (Replace with your actual CPU)
|
| 121 |
+
- **Memory:** 64 GB RAM (Replace with your actual RAM)
|
| 122 |
+
|
| 123 |
+
### Optimization Strategies
|
| 124 |
+
|
| 125 |
+
- **Mixed Precision Training:** Utilized PyTorch's Native AMP to accelerate training and reduce memory consumption when a CUDA-enabled GPU is available.
|
| 126 |
+
- **Gradient Accumulation:** Implemented gradient accumulation with `2` steps to effectively increase the batch size without exceeding GPU memory limits.
|
| 127 |
+
- **Early Stopping:** Incorporated `EarlyStoppingCallback` with a patience of `2` epochs to halt training if the validation loss does not improve, preventing overfitting.
|
| 128 |
+
- **Checkpointing:** Configured to save model checkpoints at the end of each epoch, retaining only the two most recent checkpoints to manage storage efficiently.
|
| 129 |
+
|
| 130 |
+
### Training Duration
|
| 131 |
+
|
| 132 |
+
- **Total Training Time:** Approximately `2.40` minutes (Note: Adjust this based on your actual training run)
|
| 133 |
+
- **Training Steps:** `1000` steps
|
| 134 |
+
- **Training Throughput:** `7.14` steps per second
|
| 135 |
+
|
| 136 |
+
### Logging and Monitoring
|
| 137 |
+
|
| 138 |
+
- **Logging Directory:** `./logs`
|
| 139 |
+
- **Logging Steps:** Every `10` steps
|
| 140 |
+
- **Reporting To:** TensorBoard
|
| 141 |
+
- **Tools Used:** TensorBoard for real-time visualization of training metrics, including loss and accuracy.
|
| 142 |
+
|
| 143 |
+
### Training Results
|
| 144 |
+
|
| 145 |
+
After training, the model achieved the following performance metrics:
|
| 146 |
+
|
| 147 |
+
- **Validation Accuracy:** `93.10%`
|
| 148 |
+
- **Test Accuracy:** `93.10%`
|
| 149 |
+
|
| 150 |
+
*Note:* The identical validation and test accuracies suggest consistent performance across both datasets. It's recommended to further investigate to ensure data splits are correctly managed and to explore additional metrics for a more comprehensive evaluation.
|
| 151 |
+
|
| 152 |
+
### Framework Versions
|
| 153 |
+
|
| 154 |
+
- **Transformers:** `4.46.2`
|
| 155 |
+
- **PyTorch:** `2.5.1+cu118`
|
| 156 |
+
- **Datasets:** `3.1.0`
|
| 157 |
+
- **Tokenizers:** `0.20.3`
|
| 158 |
+
|
| 159 |
+
## Usage
|
| 160 |
+
|
| 161 |
+
```python
|
| 162 |
+
from transformers import pipeline
|
| 163 |
+
|
| 164 |
+
# Initialize the emotion classification pipeline with your model
|
| 165 |
+
classifier = pipeline(
|
| 166 |
+
"text-classification",
|
| 167 |
+
model="hamzawaheed/emotion-classification-model",
|
| 168 |
+
tokenizer="hamzawaheed/emotion-classification-model"
|
| 169 |
+
)
|
| 170 |
+
|
| 171 |
+
# Sample texts to classify
|
| 172 |
+
texts = [
|
| 173 |
+
"I’m so happy today!",
|
| 174 |
+
"I'm feeling very sad and depressed.",
|
| 175 |
+
"This is absolutely fantastic news!",
|
| 176 |
+
"I'm terrified of what's happening.",
|
| 177 |
+
"I love spending time with my friends."
|
| 178 |
+
]
|
| 179 |
+
|
| 180 |
+
# Perform classification
|
| 181 |
+
results = classifier(texts)
|
| 182 |
+
|
| 183 |
+
# Display the results
|
| 184 |
+
for text, result in zip(texts, results):
|
| 185 |
+
print(f"Text: {text}\nPredicted Emotion: {result['label']} (Confidence: {result['score']:.4f})\n")
|
| 186 |
+
```
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 267844872
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c779537cd860a25570aed8cb6ac8e7d715aaee2a31d85712bcebe2f751f7b8d
|
| 3 |
size 267844872
|