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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# EUMORA - Emotion-Aware Music Recommendation System
|
| 2 |
+
|
| 3 |
+
**Advanced lyrical emotion analysis with custom-trained transformer models and real-time visualization.**
|
| 4 |
+
|
| 5 |
+
> **Current Date**: April 20, 2026 | **Status**: Functional Prototype | **Latest Training**: April 10, 2026
|
| 6 |
+
|
| 7 |
+
## ๐ฏ Current Implementation Status
|
| 8 |
+
|
| 9 |
+
### โ
Phase 1: Lyrical Emotion Analysis *(Functional with Known Limitations)*
|
| 10 |
+
- **Custom DeBERTa-v3-Base model** (184M parameters) trained on combined datasets (~59k samples)
|
| 11 |
+
- **8 Emotion categories** with **validated performance** (65.6% validation F1 on clear cases; 95%+ on unambiguous text)
|
| 12 |
+
- **Automatic chart generation** with beautiful, publication-quality visualizations for every prediction
|
| 13 |
+
- **Multiple dataset support** - dair-ai/emotion (16k), GoEmotions (43k), and combined (59k samples)
|
| 14 |
+
- **Professional training pipeline** - early stopping, weighted loss, class balancing, and multi-dataset support
|
| 15 |
+
- **Cross-platform inference** - Apple MPS, NVIDIA CUDA, and CPU support with automatic device detection
|
| 16 |
+
- **Advanced sarcasm calibration** - Bayesian prior adjustment for deployment-specific sarcasm prevalence
|
| 17 |
+
|
| 18 |
+
### ๐ญ Detected Emotions
|
| 19 |
+
- **Sadness** - Melancholic, sorrowful themes
|
| 20 |
+
- **Joy** - Uplifting, celebratory content
|
| 21 |
+
- **Love** - Romantic, affectionate sentiments
|
| 22 |
+
- **Anger** - Intense, confrontational language
|
| 23 |
+
- **Fear** - Anxious, uncertain undertones
|
| 24 |
+
- **Surprise** - Unexpected, wonder-filled expressions
|
| 25 |
+
- **Neutral** - Balanced, observational tone
|
| 26 |
+
- **Sarcasm** - Ironic, sarcastic undertones (with Bayesian prior adjustment)
|
| 27 |
+
|
| 28 |
+
## ๐ Quick Start
|
| 29 |
+
|
| 30 |
+
### Installation
|
| 31 |
+
```bash
|
| 32 |
+
# Clone and install dependencies
|
| 33 |
+
git clone https://github.com/your-username/EUMORA.git
|
| 34 |
+
cd EUMORA
|
| 35 |
+
|
| 36 |
+
# Create virtual environment (recommended)
|
| 37 |
+
python -m venv .venv
|
| 38 |
+
|
| 39 |
+
# Activate virtual environment
|
| 40 |
+
# On Windows:
|
| 41 |
+
.venv\Scripts\activate
|
| 42 |
+
# On macOS/Linux:
|
| 43 |
+
source .venv/bin/activate
|
| 44 |
+
|
| 45 |
+
# Install dependencies
|
| 46 |
+
pip install -r requirements.txt
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
### Available Trained Models
|
| 50 |
+
|
| 51 |
+
**Three production-ready models are available** in `models/emotion_classifier/`:
|
| 52 |
+
|
| 53 |
+
1. **`emotion_classifier/final/`** (Latest Checkpoint - Recommended)
|
| 54 |
+
- Training: Combined dataset (59k samples)
|
| 55 |
+
- Validation F1: 65.61% weighted, 64.27% macro
|
| 56 |
+
- Use case: **Primary model for inference**
|
| 57 |
+
- Files: Full model with all components (config, weights, tokenizer)
|
| 58 |
+
|
| 59 |
+
2. **`emotion_classifier_20260410_135131/final/`** (Alternative)
|
| 60 |
+
- Training: Combined dataset with different seed
|
| 61 |
+
- Performance: Comparable to primary model
|
| 62 |
+
- Use case: Backup/comparison or ensemble testing
|
| 63 |
+
- Note: Use if primary model unavailable
|
| 64 |
+
|
| 65 |
+
3. **`sample_models/emotion_classifier_sample_20260410_134414/`** (Testing/Demo)
|
| 66 |
+
- Training: Limited sample (2k samples)
|
| 67 |
+
- Performance: Lower accuracy (~58%)
|
| 68 |
+
- Use case: Quick testing without loading full model
|
| 69 |
+
- Note: For prototyping only, not production
|
| 70 |
+
|
| 71 |
+
### Training Options
|
| 72 |
+
```bash
|
| 73 |
+
# Quick training (2k samples, ~5 minutes)
|
| 74 |
+
python main.py train --sample
|
| 75 |
+
|
| 76 |
+
# Standard training on dair-ai/emotion (16k samples, ~15 minutes)
|
| 77 |
+
python main.py train
|
| 78 |
+
|
| 79 |
+
# Advanced training on GoEmotions (43k samples, ~30 minutes)
|
| 80 |
+
python main.py train --goemotions
|
| 81 |
+
|
| 82 |
+
# Best results: Combined datasets (59k samples, ~45 minutes)
|
| 83 |
+
python main.py train --combined
|
| 84 |
+
|
| 85 |
+
# Advanced options
|
| 86 |
+
python main.py train --combined --no-weights # Disable class balancing
|
| 87 |
+
python main.py train --goemotions --samples 10000 # Limit training samples
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### Using the Model
|
| 91 |
+
|
| 92 |
+
#### Basic Predictions
|
| 93 |
+
```bash
|
| 94 |
+
# Simple prediction with default visualization
|
| 95 |
+
python main.py predict "I feel so happy today, everything is perfect!"
|
| 96 |
+
|
| 97 |
+
# Prediction without chart generation
|
| 98 |
+
python main.py predict "I'm feeling great" --disable-prior-adjustment
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
#### Advanced Sarcasm Calibration
|
| 102 |
+
The model includes Bayesian prior adjustment for deployment-specific sarcasm prevalence:
|
| 103 |
+
|
| 104 |
+
```bash
|
| 105 |
+
# Standard usage: assumes 15% sarcasm in deployment text (default)
|
| 106 |
+
python main.py predict "Oh amazing, another sleepless night"
|
| 107 |
+
|
| 108 |
+
# For high-sarcasm domains (e.g., social media): adjust prior upward
|
| 109 |
+
python main.py predict "Oh amazing, another sleepless night" --target-sarcasm-prior 0.25
|
| 110 |
+
|
| 111 |
+
# For low-sarcasm domains (e.g., customer service): adjust prior downward
|
| 112 |
+
python main.py predict "I'm so thrilled" --target-sarcasm-prior 0.05
|
| 113 |
+
|
| 114 |
+
# Fine-tune sarcasm detection threshold (0.0-1.0, default=None for auto)
|
| 115 |
+
python main.py predict "Yeah, great job" --target-sarcasm-prior 0.2 --sarcasm-threshold 0.4
|
| 116 |
+
|
| 117 |
+
# Disable prior calibration entirely for baseline comparison
|
| 118 |
+
python main.py predict "Oh amazing, another Monday" --disable-prior-adjustment
|
| 119 |
+
```
|
| 120 |
+
|
| 121 |
+
#### Visualization Options
|
| 122 |
+
```bash
|
| 123 |
+
# Simple bar chart (default, automatically generated)
|
| 124 |
+
python main.py predict "My heart is broken"
|
| 125 |
+
|
| 126 |
+
# Enhanced visualization with primary emotion indicator
|
| 127 |
+
python main.py predict "My heart is broken" --detailed-chart
|
| 128 |
+
|
| 129 |
+
# Interactive mode with options
|
| 130 |
+
python main.py analyze
|
| 131 |
+
|
| 132 |
+
# Demo with multiple comparison charts
|
| 133 |
+
python main.py demo
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
**Note**: All predictions generate and save charts to `visualizations/` folder automatically
|
| 137 |
+
|
| 138 |
+
## ๐ Example Output
|
| 139 |
+
|
| 140 |
+
### Text Output
|
| 141 |
+
```
|
| 142 |
+
๐ต EUMORA - Emotion Analysis
|
| 143 |
+
|
| 144 |
+
๐ Input: "City lights blur as I'm driving through the night"
|
| 145 |
+
|
| 146 |
+
๐ญ Emotion: FEAR
|
| 147 |
+
๐ Confidence: 53.9%
|
| 148 |
+
๐ธ Music Context: {'mood': 'anxious', 'energy': 'medium', 'valence': 'negative'}
|
| 149 |
+
|
| 150 |
+
๐ฌ Detected anxious and uncertain undertones with moderate confidence (53.9%).
|
| 151 |
+
Suggests anxious music with medium energy. Secondary: anger (22.9%).
|
| 152 |
+
|
| 153 |
+
๐ All Emotions:
|
| 154 |
+
fear: โโโโโโโโโโโโโ 53.9%
|
| 155 |
+
anger: โโโโโ 22.9%
|
| 156 |
+
joy: โโโโ 17.8%
|
| 157 |
+
sadness: โ 2.5%
|
| 158 |
+
surprise: โ 2.5%
|
| 159 |
+
love: 0.4%
|
| 160 |
+
|
| 161 |
+
๐ Chart saved to: visualizations/emotion_analysis_20260328_011358.png
|
| 162 |
+
```
|
| 163 |
+
|
| 164 |
+
### Visual Charts (Auto-generated)
|
| 165 |
+
- **Automatic bar charts** showing probability distribution (every prediction)
|
| 166 |
+
- **Primary emotion indicators** with confidence levels and totals verification
|
| 167 |
+
- **Mathematically accurate** - probabilities always sum to exactly 100%
|
| 168 |
+
- **Beautiful styling** with emotion-coded colors and high-resolution export
|
| 169 |
+
- **Comparison charts** in demo mode showing multiple predictions side-by-side
|
| 170 |
+
|
| 171 |
+
## ๐๏ธ Project Structure
|
| 172 |
+
|
| 173 |
+
```
|
| 174 |
+
EUMORA/
|
| 175 |
+
โโโ main.py # Enhanced CLI with training & visualization options
|
| 176 |
+
โโโ requirements.txt # All dependencies including matplotlib/seaborn
|
| 177 |
+
โโโ src/
|
| 178 |
+
โ โโโ config.py # Model configs, datasets, 7 emotion mappings
|
| 179 |
+
โ โโโ train.py # Advanced training with GoEmotions & class balancing
|
| 180 |
+
โ โโโ predict.py # Inference with custom DistilBERT model
|
| 181 |
+
โ โโโ visualize.py # Chart generation & visualization system
|
| 182 |
+
โ โโโ dataset.py # Multi-dataset loading & preprocessing
|
| 183 |
+
โโโ models/ # Your trained models (gitignored)
|
| 184 |
+
โ โโโ emotion_classifier/
|
| 185 |
+
โ โโโ final/ # Production model (66M parameters)
|
| 186 |
+
โโโ visualizations/ # Generated charts and graphs (gitignored)
|
| 187 |
+
โโโ data/ # Training datasets (auto-downloaded, gitignored)
|
| 188 |
+
โโโ notebooks/ # Jupyter notebooks for analysis
|
| 189 |
+
```
|
| 190 |
+
|
| 191 |
+
## ๏ฟฝ **Python API Usage (Programmatic)**
|
| 192 |
+
|
| 193 |
+
### Basic Usage
|
| 194 |
+
```python
|
| 195 |
+
from src.predict import EmotionPredictor
|
| 196 |
+
|
| 197 |
+
# Initialize predictor (loads model on first use)
|
| 198 |
+
predictor = EmotionPredictor(enable_viz=True)
|
| 199 |
+
|
| 200 |
+
# Make predictions
|
| 201 |
+
text = "I feel so happy today!"
|
| 202 |
+
result = predictor.predict(text)
|
| 203 |
+
|
| 204 |
+
# Access results
|
| 205 |
+
print(f"Emotion: {result['emotion']}") # e.g., "joy"
|
| 206 |
+
print(f"Confidence: {result['confidence']:.1%}") # e.g., 96.4%
|
| 207 |
+
print(f"All scores: {result['scores']}") # dict of all emotions
|
| 208 |
+
```
|
| 209 |
+
|
| 210 |
+
### Advanced: Custom Sarcasm Calibration
|
| 211 |
+
```python
|
| 212 |
+
# Initialize with custom sarcasm settings
|
| 213 |
+
predictor = EmotionPredictor(
|
| 214 |
+
enable_viz=False, # Disable charts for batch processing
|
| 215 |
+
target_sarcasm_prior=0.25, # 25% sarcasm in deployment
|
| 216 |
+
sarcasm_threshold=0.45 # Custom sarcasm threshold
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
# Process batch of texts
|
| 220 |
+
texts = [
|
| 221 |
+
"I love this!",
|
| 222 |
+
"Oh great, another bug",
|
| 223 |
+
"This is amazing"
|
| 224 |
+
]
|
| 225 |
+
|
| 226 |
+
for text in texts:
|
| 227 |
+
result = predictor.predict(text)
|
| 228 |
+
# Use results as needed
|
| 229 |
+
```
|
| 230 |
+
|
| 231 |
+
### Batch Processing with Prior Adjustment
|
| 232 |
+
```python
|
| 233 |
+
from pathlib import Path
|
| 234 |
+
|
| 235 |
+
# Disable visualization for speed
|
| 236 |
+
predictor = EmotionPredictor(
|
| 237 |
+
enable_viz=False,
|
| 238 |
+
target_sarcasm_prior=0.15
|
| 239 |
+
)
|
| 240 |
+
|
| 241 |
+
# Process many texts efficiently
|
| 242 |
+
texts = ["text1", "text2", "text3"]
|
| 243 |
+
results = [predictor.predict(t) for t in texts]
|
| 244 |
+
|
| 245 |
+
# Extract primary emotions
|
| 246 |
+
emotions = [r['emotion'] for r in results]
|
| 247 |
+
confidences = [r['confidence'] for r in results]
|
| 248 |
+
```
|
| 249 |
+
|
| 250 |
+
### Using Alternative Model
|
| 251 |
+
```python
|
| 252 |
+
from pathlib import Path
|
| 253 |
+
|
| 254 |
+
# Use backup model if primary unavailable
|
| 255 |
+
backup_model = Path("models/emotion_classifier_20260410_135131/final")
|
| 256 |
+
predictor = EmotionPredictor(model_path=backup_model)
|
| 257 |
+
|
| 258 |
+
result = predictor.predict("Your text here")
|
| 259 |
+
```
|
| 260 |
+
|
| 261 |
+
## ๏ฟฝ๐ Performance & Limitations
|
| 262 |
+
|
| 263 |
+
### ๐ด **Current Performance Reality**
|
| 264 |
+
**Training Metrics (Validation Set):**
|
| 265 |
+
- **F1-Weighted**: 65.61% (real performance from training logs)
|
| 266 |
+
- **F1-Macro**: 64.27%
|
| 267 |
+
- **Validation Accuracy**: 65.57%
|
| 268 |
+
- **Training**: 4 epochs, 5,428 steps on combined dataset
|
| 269 |
+
|
| 270 |
+
**Real-World Testing Results:**
|
| 271 |
+
- โ
**Clear emotions**: 95-99% accuracy ("I feel so happy" โ Joy 96.9%)
|
| 272 |
+
- โ
**Neutral content**: 89%+ accuracy (factual statements โ Neutral 89.3%)
|
| 273 |
+
- โ **Sarcasm detection**: **Complete failure** ("Oh great, another Monday" โ Joy 95.4% โ)
|
| 274 |
+
- โ **Mixed emotions**: **Negative bias** ("excited but nervous" โ Fear 94.0%, ignores excitement)
|
| 275 |
+
- โ ๏ธ **Ambiguous text**: Lower confidence, distributed predictions
|
| 276 |
+
|
| 277 |
+
### ๐ซ **Known Critical Weaknesses**
|
| 278 |
+
1. **Cannot detect sarcasm** - Interprets sarcastic phrases as genuine emotion
|
| 279 |
+
2. **Mixed emotion bias** - Heavily favors negative emotions in complex expressions
|
| 280 |
+
3. **Limited context understanding** - Missing social/cultural cues and implicit meaning
|
| 281 |
+
4. **Over-confident on ambiguous inputs** - High confidence even when uncertain
|
| 282 |
+
5. **Single sentence focus** - No conversation or document-level context
|
| 283 |
+
|
| 284 |
+
### โ
**What Works Well**
|
| 285 |
+
- Direct emotional expressions in text
|
| 286 |
+
- Neutral/factual content detection
|
| 287 |
+
- Clear positive emotions (joy, love, gratitude)
|
| 288 |
+
- Clear negative emotions (sadness, anger, fear)
|
| 289 |
+
- Hyperbolic language ("dying of laughter" โ Joy correctly)
|
| 290 |
+
|
| 291 |
+
## ๐ง **Troubleshooting**
|
| 292 |
+
|
| 293 |
+
### Common Issues and Solutions
|
| 294 |
+
|
| 295 |
+
#### 1. **CUDA Out of Memory Error During Training**
|
| 296 |
+
```bash
|
| 297 |
+
# Solution: Reduce batch size
|
| 298 |
+
python main.py train --combined --batch-size 8
|
| 299 |
+
|
| 300 |
+
# Or use gradient accumulation (2 steps)
|
| 301 |
+
python main.py train --combined --gradient-accumulation-steps 2
|
| 302 |
+
```
|
| 303 |
+
|
| 304 |
+
#### 2. **Model Takes Too Long to Load (>30 seconds)**
|
| 305 |
+
```bash
|
| 306 |
+
# Check if using CPU instead of GPU
|
| 307 |
+
# On Windows with CUDA installed:
|
| 308 |
+
set CUDA_VISIBLE_DEVICES=0
|
| 309 |
+
|
| 310 |
+
# On Mac with MPS:
|
| 311 |
+
python main.py predict "text" --device mps
|
| 312 |
+
```
|
| 313 |
+
|
| 314 |
+
#### 3. **Charts Not Generating or Saving**
|
| 315 |
+
```bash
|
| 316 |
+
# Ensure visualizations folder exists and is writable
|
| 317 |
+
mkdir visualizations
|
| 318 |
+
|
| 319 |
+
# Check permissions and try prediction again
|
| 320 |
+
python main.py predict "test"
|
| 321 |
+
|
| 322 |
+
# Verify file was created in visualizations/
|
| 323 |
+
ls visualizations/
|
| 324 |
+
```
|
| 325 |
+
|
| 326 |
+
#### 4. **Incorrect Emotion Predictions (Sarcasm Issues)**
|
| 327 |
+
```bash
|
| 328 |
+
# The model struggles with sarcasm by design. Solutions:
|
| 329 |
+
|
| 330 |
+
# Option A: Adjust sarcasm prior for your use case
|
| 331 |
+
python main.py predict "Oh great, another bug" --target-sarcasm-prior 0.3
|
| 332 |
+
|
| 333 |
+
# Option B: Use --disable-prior-adjustment for baseline
|
| 334 |
+
python main.py predict "Oh great, another bug" --disable-prior-adjustment
|
| 335 |
+
|
| 336 |
+
# Option C: Train a custom sarcasm dataset
|
| 337 |
+
python main.py train --custom-sarcasm-data your_data.csv
|
| 338 |
+
```
|
| 339 |
+
|
| 340 |
+
#### 5. **Memory Issues on Older GPUs**
|
| 341 |
+
```bash
|
| 342 |
+
# Use a smaller model variant (if available) or CPU inference:
|
| 343 |
+
python main.py predict "text" --device cpu --mixed-precision
|
| 344 |
+
|
| 345 |
+
# Or batch predictions instead of real-time
|
| 346 |
+
```
|
| 347 |
+
|
| 348 |
+
### Performance Tips
|
| 349 |
+
|
| 350 |
+
- **Fastest inference**: Use GPU (CUDA/MPS) - typically 50-150ms per prediction
|
| 351 |
+
- **Most compatible**: CPU mode works everywhere - 200-500ms per prediction
|
| 352 |
+
- **Memory efficient**: Load model once, reuse in loop within same process
|
| 353 |
+
- **Batch processing**: Organize predictions to load model once per batch
|
| 354 |
+
|
| 355 |
+
### ๐งฉ **Model Architecture**
|
| 356 |
+
- **Base Model**: `microsoft/deberta-v3-base` (184M parameters, 12 layers)
|
| 357 |
+
- **Classification Head**: 768-dim โ 8 neurons (8 emotion classes including sarcasm)
|
| 358 |
+
- **Tokenizer**: SentencePiece (128,000 vocab, max_length=256 tokens)
|
| 359 |
+
- **Framework**: PyTorch + Hugging Face Transformers
|
| 360 |
+
- **Device Support**: NVIDIA CUDA, Apple MPS, CPU (auto-detection)
|
| 361 |
+
- **Model Files**: ~737MB weights in SafeTensors format
|
| 362 |
+
- **Precision**: fp32 (full precision) for stable gradient computation
|
| 363 |
+
|
| 364 |
+
### ๐ **Training Configuration**
|
| 365 |
+
- **Dataset**: Combined dair-ai/emotion + GoEmotions (~59k samples)
|
| 366 |
+
- **Optimization**: AdamW (lr=1e-5, warmup=0.1, weight_decay=0.01)
|
| 367 |
+
- **Batch Size**: 16, Early Stopping (patience=2)
|
| 368 |
+
- **Epochs**: 5 with early stopping
|
| 369 |
+
- **Class Balancing**: Weighted Cross-Entropy for imbalanced emotions
|
| 370 |
+
|
| 371 |
+
## ๐จ Advanced Features
|
| 372 |
+
|
| 373 |
+
### Multiple Training Options
|
| 374 |
+
```bash
|
| 375 |
+
python main.py train # Standard: dair-ai/emotion (16k samples)
|
| 376 |
+
python main.py train --goemotions # Enhanced: GoEmotions (43k samples)
|
| 377 |
+
python main.py train --combined # Best: Combined datasets (59k samples)
|
| 378 |
+
python main.py train --sample # Quick test: 2k samples (~5 min)
|
| 379 |
+
python main.py train --no-weights # Disable class balancing
|
| 380 |
+
python main.py train --samples 5000 # Custom sample size
|
| 381 |
+
```
|
| 382 |
+
|
| 383 |
+
### Interactive Analysis
|
| 384 |
+
```bash
|
| 385 |
+
python main.py analyze
|
| 386 |
+
|
| 387 |
+
# Commands available:
|
| 388 |
+
>>> I love this song so much! # Basic analysis
|
| 389 |
+
>>> chart: feeling sad today # With simple chart
|
| 390 |
+
>>> detailed: amazing day full of joy # Enhanced visualization
|
| 391 |
+
>>> quit # Exit
|
| 392 |
+
```
|
| 393 |
+
|
| 394 |
+
### Visualization System
|
| 395 |
+
- **Automatic generation**: Every prediction creates a chart by default (no flags needed)
|
| 396 |
+
- **Simple charts**: Clean bar graphs with percentages and emotion colors
|
| 397 |
+
- **Detailed charts**: Enhanced with primary emotion indicators and verification totals
|
| 398 |
+
- **Comparison mode**: Side-by-side analysis of multiple texts in demo mode
|
| 399 |
+
- **Export**: High-resolution PNG files (300 DPI) saved to `visualizations/` folder
|
| 400 |
+
- **Interactive options**: Available in analyze mode (`chart:` and `detailed:` prefixes)
|
| 401 |
+
|
| 402 |
+
## ๐ป Complete Tech Stack
|
| 403 |
+
|
| 404 |
+
### Core Machine Learning
|
| 405 |
+
```python
|
| 406 |
+
torch>=2.0.0 # PyTorch deep learning framework
|
| 407 |
+
transformers>=4.35.0 # Hugging Face Transformers (DeBERTa-v3-Base)
|
| 408 |
+
datasets>=2.14.0 # Hugging Face Datasets integration
|
| 409 |
+
accelerate>=0.25.0 # Training acceleration & device management
|
| 410 |
+
```
|
| 411 |
+
|
| 412 |
+
### Data Processing & Analysis
|
| 413 |
+
```python
|
| 414 |
+
pandas>=2.0.0 # Data manipulation and analysis
|
| 415 |
+
numpy>=1.24.0 # Numerical computing
|
| 416 |
+
scikit-learn>=1.3.0 # ML utilities, metrics, class balancing
|
| 417 |
+
```
|
| 418 |
+
|
| 419 |
+
### Visualization & UI
|
| 420 |
+
```python
|
| 421 |
+
matplotlib>=3.7.0 # Plotting and chart generation
|
| 422 |
+
seaborn>=0.12.0 # Statistical data visualization
|
| 423 |
+
tqdm>=4.65.0 # Progress bars and logging
|
| 424 |
+
```
|
| 425 |
+
|
| 426 |
+
### Configuration & Utilities
|
| 427 |
+
```python
|
| 428 |
+
pyyaml>=6.0 # Configuration file parsing
|
| 429 |
+
pathlib # Modern file path handling (built-in)
|
| 430 |
+
argparse # CLI argument parsing (built-in)
|
| 431 |
+
```
|
| 432 |
+
|
| 433 |
+
### Model Specifications
|
| 434 |
+
- **Base Architecture**: `microsoft/deberta-v3-base`
|
| 435 |
+
- 12 transformer layers with disentangled attention
|
| 436 |
+
- 768 hidden dimensions
|
| 437 |
+
- 12 attention heads
|
| 438 |
+
- ~184M parameters
|
| 439 |
+
|
| 440 |
+
- **Custom Components**:
|
| 441 |
+
- Linear classification head: 768 โ 7 neurons (7 emotions)
|
| 442 |
+
- Dropout layer (p=0.1) for regularization
|
| 443 |
+
- Weighted Cross-Entropy loss for class balancing
|
| 444 |
+
- Automatic emotion mapping from 28 GoEmotions labels to 7 core emotions
|
| 445 |
+
|
| 446 |
+
### Training Infrastructure
|
| 447 |
+
- **Optimizer**: AdamW with weight decay
|
| 448 |
+
- **Scheduler**: Linear warmup + decay
|
| 449 |
+
- **Hardware**: Auto-detection (CPU/CUDA/MPS)
|
| 450 |
+
- **Memory Management**: Gradient accumulation support
|
| 451 |
+
- **Monitoring**: Loss tracking, F1-score optimization
|
| 452 |
+
|
| 453 |
+
### Data Pipeline
|
| 454 |
+
- **Tokenization**: SentencePiece tokenizer (128,000 vocab)
|
| 455 |
+
- **Preprocessing**: Automatic text cleaning, label mapping
|
| 456 |
+
- **Batching**: Dynamic padding, attention masks
|
| 457 |
+
- **Splits**: 80/10/10 train/validation/test
|
| 458 |
+
|
| 459 |
+
## ๐ง Technical Implementation Details
|
| 460 |
+
|
| 461 |
+
### Exact Model Architecture
|
| 462 |
+
```
|
| 463 |
+
Input Text: "I feel so happy today!"
|
| 464 |
+
โ
|
| 465 |
+
DeBERTa-v3 Tokenizer (SentencePiece):
|
| 466 |
+
โ token_ids + attention_mask
|
| 467 |
+
โ
|
| 468 |
+
Token Embeddings (768-dim) + Position Embeddings
|
| 469 |
+
โ
|
| 470 |
+
12x DeBERTa Transformer Layers:
|
| 471 |
+
โข Disentangled Attention (content + position, 12 heads)
|
| 472 |
+
โข Feed-Forward Network (3072 hidden)
|
| 473 |
+
โข Layer Normalization + Residual Connections
|
| 474 |
+
โ
|
| 475 |
+
[CLS] Token Output (768-dim) โ Pooler
|
| 476 |
+
โ
|
| 477 |
+
Classification Head:
|
| 478 |
+
Linear(768 โ 7) + Dropout(0.1)
|
| 479 |
+
โ
|
| 480 |
+
Logits: [0.2, 4.8, 0.1, -0.5, -1.2, 0.3, -0.8]
|
| 481 |
+
โ
|
| 482 |
+
Softmax Activation:
|
| 483 |
+
[0.02, 0.994, 0.018, 0.01, 0.005, 0.022, 0.007]
|
| 484 |
+
โ
|
| 485 |
+
Final Prediction: JOY (99.4% confidence)
|
| 486 |
+
```
|
| 487 |
+
|
| 488 |
+
### Specific Training Configuration
|
| 489 |
+
```python
|
| 490 |
+
# Production model training parameters (emotion_classifier/final/)
|
| 491 |
+
LEARNING_RATE = 2e-5 # Optimized for DeBERTa-v3-Base fine-tuning
|
| 492 |
+
BATCH_SIZE = 16 # Per-device batch size (adjust for GPU memory)
|
| 493 |
+
MAX_LENGTH = 256 # Token sequence length for lyrics
|
| 494 |
+
NUM_EPOCHS = 4 # With early stopping (patience=2)
|
| 495 |
+
WARMUP_RATIO = 0.1 # Linear warmup (10% of total steps)
|
| 496 |
+
WEIGHT_DECAY = 0.01 # L2 regularization to prevent overfitting
|
| 497 |
+
PRECISION = "float32" # Full precision (critical for stable gradients)
|
| 498 |
+
|
| 499 |
+
# Class balancing (computed automatically from dataset distribution)
|
| 500 |
+
CLASS_WEIGHTS = { # Example from combined dataset
|
| 501 |
+
'joy': 0.85, 'sadness': 1.24, 'anger': 1.18,
|
| 502 |
+
'fear': 2.31, 'love': 3.45, 'surprise': 2.67, 'neutral': 0.92, 'sarcasm': 2.1
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
# Training hardware & time
|
| 506 |
+
GPU_TYPE = "Apple MPS / NVIDIA CUDA"
|
| 507 |
+
ESTIMATED_TRAINING_TIME = "45-90 minutes for full dataset (combined)"
|
| 508 |
+
TOTAL_TRAINING_STEPS = "5,428 steps on 59k samples"
|
| 509 |
+
VALIDATION_FREQUENCY = "Every 500 steps"
|
| 510 |
+
```
|
| 511 |
+
|
| 512 |
+
### ๐ป **System Requirements & Performance**
|
| 513 |
+
**Hardware Requirements:**
|
| 514 |
+
- **Python**: 3.8+ (tested on 3.11.7)
|
| 515 |
+
- **Memory**: 2GB RAM minimum, 4GB+ recommended for training
|
| 516 |
+
- **Storage**: 2GB for models and datasets
|
| 517 |
+
- **GPU**: Optional - Apple MPS, NVIDIA CUDA supported for faster inference
|
| 518 |
+
|
| 519 |
+
**Estimated Performance *(varies by hardware)*:**
|
| 520 |
+
- **Model Loading**: 2-5 seconds
|
| 521 |
+
- **Single Prediction**: 50-200ms (MPS/CUDA), 200-500ms (CPU)
|
| 522 |
+
- **Training Time**: 30-90 minutes for full dataset (GPU recommended)
|
| 523 |
+
- **Memory Usage**: 1-2GB during inference, 4-8GB during training
|
| 524 |
+
|
| 525 |
+
### Datasets Supported
|
| 526 |
+
- **`dair-ai/emotion`**: 16,000 samples, 6 emotions (sadness, joy, love, anger, fear, surprise)
|
| 527 |
+
- Source: Tweet emotion classification dataset
|
| 528 |
+
- Label distribution: Balanced across core emotions
|
| 529 |
+
- Quality: High-quality manual annotations by emotion recognition experts
|
| 530 |
+
|
| 531 |
+
- **`google-research-datasets/go_emotions`**: 43,410 samples, 28 emotions โ mapped to 7
|
| 532 |
+
- Source: Reddit comments with fine-grained emotion labels
|
| 533 |
+
- Mapping: 28 GoEmotions labels clustered into our 7 core emotions + neutral
|
| 534 |
+
- Quality: Large-scale, diverse emotional expressions from social media
|
| 535 |
+
- Includes neutral category for balanced emotion representation
|
| 536 |
+
|
| 537 |
+
- **Combined Dataset**: Best of both worlds (59,410 total samples)
|
| 538 |
+
- Merges both datasets with unified 7-emotion schema
|
| 539 |
+
- Provides maximum coverage across different text domains (Twitter + Reddit)
|
| 540 |
+
- Recommended for production use due to superior performance
|
| 541 |
+
|
| 542 |
+
## ๐ต Music Context Mapping
|
| 543 |
+
|
| 544 |
+
Each emotion automatically maps to music recommendation parameters:
|
| 545 |
+
|
| 546 |
+
```python
|
| 547 |
+
{
|
| 548 |
+
"sadness": {"mood": "melancholic", "energy": "low", "valence": "negative"},
|
| 549 |
+
"joy": {"mood": "happy", "energy": "high", "valence": "positive"},
|
| 550 |
+
"love": {"mood": "romantic", "energy": "medium", "valence": "positive"},
|
| 551 |
+
"anger": {"mood": "intense", "energy": "high", "valence": "negative"},
|
| 552 |
+
"fear": {"mood": "anxious", "energy": "medium", "valence": "negative"},
|
| 553 |
+
"surprise": {"mood": "excited", "energy": "high", "valence": "mixed"},
|
| 554 |
+
"neutral": {"mood": "calm", "energy": "low", "valence": "neutral"}
|
| 555 |
+
}
|
| 556 |
+
```
|
| 557 |
+
|
| 558 |
+
## ๐ Exact Dependencies & Requirements
|
| 559 |
+
|
| 560 |
+
### System Requirements
|
| 561 |
+
- **Python**: 3.8+ (tested on 3.11.7)
|
| 562 |
+
- **Operating System**: macOS, Linux, Windows
|
| 563 |
+
- **Memory**: 4GB RAM minimum, 8GB recommended for training
|
| 564 |
+
- **Storage**: 2GB for models and datasets
|
| 565 |
+
|
| 566 |
+
### requirements.txt (Exact Versions)
|
| 567 |
+
```bash
|
| 568 |
+
# Core ML/DL Framework
|
| 569 |
+
torch>=2.0.0
|
| 570 |
+
transformers>=4.35.0
|
| 571 |
+
datasets>=2.14.0
|
| 572 |
+
|
| 573 |
+
# Data Processing
|
| 574 |
+
pandas>=2.0.0
|
| 575 |
+
numpy>=1.24.0
|
| 576 |
+
scikit-learn>=1.3.0
|
| 577 |
+
|
| 578 |
+
# Training Acceleration
|
| 579 |
+
accelerate>=0.25.0
|
| 580 |
+
|
| 581 |
+
# Visualization
|
| 582 |
+
matplotlib>=3.7.0
|
| 583 |
+
seaborn>=0.12.0
|
| 584 |
+
|
| 585 |
+
# Utilities
|
| 586 |
+
tqdm>=4.65.0
|
| 587 |
+
pyyaml>=6.0
|
| 588 |
+
```
|
| 589 |
+
|
| 590 |
+
### Model Files Structure
|
| 591 |
+
```
|
| 592 |
+
models/emotion_classifier/final/
|
| 593 |
+
โโโ config.json # Model configuration
|
| 594 |
+
โโโ model.safetensors # Model weights (~737MB)
|
| 595 |
+
โโโ spm.model # SentencePiece tokenizer model
|
| 596 |
+
โโโ tokenizer.json # Tokenizer vocabulary
|
| 597 |
+
โโโ tokenizer_config.json # Tokenizer settings
|
| 598 |
+
โโโ trainer_state.json # Training metrics (optional)
|
| 599 |
+
```
|
| 600 |
+
|
| 601 |
+
### Dataset Cache Locations
|
| 602 |
+
```
|
| 603 |
+
~/.cache/huggingface/datasets/
|
| 604 |
+
โโโ dair-ai___emotion/ # 16k samples (~45MB)
|
| 605 |
+
โโโ google-research-datasets___go_emotions/ # 43k samples (~125MB)
|
| 606 |
+
โโโ combined/ # Merged dataset (~170MB)
|
| 607 |
+
|
| 608 |
+
./visualizations/ # Generated charts (gitignored)
|
| 609 |
+
โโโ emotion_analysis_*.png # Simple bar charts
|
| 610 |
+
โโโ detailed_analysis_*.png # Enhanced visualizations
|
| 611 |
+
โโโ comparison_*.png # Demo comparison charts
|
| 612 |
+
```
|
| 613 |
+
|
| 614 |
+
## ๐ฎ Next Phases & Roadmap
|
| 615 |
+
|
| 616 |
+
### ๐ฏ **Priority Improvements** *(Planned Development)*
|
| 617 |
+
1. **Enhanced Sarcasm Detection**
|
| 618 |
+
- Collect sarcasm-specific labeled datasets
|
| 619 |
+
- Train dedicated sarcasm classification head
|
| 620 |
+
- Improve contextual understanding beyond single sentences
|
| 621 |
+
|
| 622 |
+
2. **Multi-Emotion Modeling**
|
| 623 |
+
- Multi-label classification (multiple emotions per text)
|
| 624 |
+
- Emotion intensity scoring (0-100 scale per emotion)
|
| 625 |
+
- Probabilistic emotion combinations
|
| 626 |
+
|
| 627 |
+
3. **Better Context Understanding**
|
| 628 |
+
- Sentence-level context windows (n-grams)
|
| 629 |
+
- Conversation history integration
|
| 630 |
+
- Stylistic/tone analysis
|
| 631 |
+
|
| 632 |
+
4. **Confidence Calibration**
|
| 633 |
+
- Uncertainty quantification
|
| 634 |
+
- Temperature scaling for better probability estimates
|
| 635 |
+
- Abstention on truly ambiguous inputs
|
| 636 |
+
|
| 637 |
+
### ๐ **Validation & Testing**
|
| 638 |
+
- Comprehensive sarcasm detection test suite
|
| 639 |
+
- Mixed emotion evaluation benchmarks
|
| 640 |
+
- Real-world music recommendation A/B testing
|
| 641 |
+
- User studies for edge cases
|
| 642 |
+
|
| 643 |
+
### ๐ **Expected Timeline**
|
| 644 |
+
- **Phase 1.5**: Bug fixes & optimization (2-3 weeks)
|
| 645 |
+
- **Phase 2.0**: Enhanced context & sarcasm (1-2 months)
|
| 646 |
+
- **Phase 3.0**: Audio feature integration (3-4 months)
|
| 647 |
+
- **Phase 4.0**: Multimodal audio+lyrics (4-6 months)
|
| 648 |
+
|
| 649 |
+
## โ ๏ธ **For Developers & Users**
|
| 650 |
+
|
| 651 |
+
### ๐ญ **Current Recommended Use Cases**
|
| 652 |
+
**โ
GOOD FOR:**
|
| 653 |
+
- Music mood classification from clear emotional text
|
| 654 |
+
- Sentiment analysis for unambiguous expressions
|
| 655 |
+
- Educational/research projects on emotion detection
|
| 656 |
+
- Prototype applications requiring basic emotion categorization
|
| 657 |
+
|
| 658 |
+
**โ NOT READY FOR:**
|
| 659 |
+
- Production sarcasm detection
|
| 660 |
+
- Complex multi-emotion analysis
|
| 661 |
+
- Social media content analysis (high sarcasm rate)
|
| 662 |
+
- Customer service sentiment (requires nuance)
|
| 663 |
+
- Any application where false positives on sarcasm are problematic
|
| 664 |
+
|
| 665 |
+
### ๐ **Developer Notice**
|
| 666 |
+
This is a **functional but limited** emotion detection system. The model works well for straightforward cases but has significant blind spots. **Use with caution in production environments** and consider adding manual review for critical applications.
|
| 667 |
+
|
| 668 |
+
**If you need sarcasm detection or complex emotion understanding, consider:**
|
| 669 |
+
- OpenAI GPT-4/Claude APIs for better contextual understanding
|
| 670 |
+
- Combine this model with rule-based sarcasm detection
|
| 671 |
+
- Wait for our Phase 2.0 improvements (see roadmap above)
|
| 672 |
+
|
| 673 |
+
## ๐ฎ Future Development Phases
|
| 674 |
+
|
| 675 |
+
- [ ] **Phase 2**: Enhanced Context & Sarcasm Detection
|
| 676 |
+
- [ ] **Phase 3**: Audio Analysis (spectrograms, MFCCs, audio emotion detection)
|
| 677 |
+
- [ ] **Phase 4**: Multimodal Fusion (combine lyrics + audio features)
|
| 678 |
+
- [ ] **Phase 5**: Music Database Integration (Spotify/Apple Music APIs)
|
| 679 |
+
- [ ] **Phase 6**: Web Interface & Mobile Apps
|
| 680 |
+
- [ ] **Phase 7**: Real-time Audio Processing & Social Features
|
| 681 |
+
|
| 682 |
+
## ๐ค Contributing
|
| 683 |
+
|
| 684 |
+
1. Fork the repository
|
| 685 |
+
2. Create feature branch (`git checkout -b feature/amazing-feature`)
|
| 686 |
+
3. Install dependencies (`pip install -r requirements.txt`)
|
| 687 |
+
4. Train and test your changes (`python main.py train --sample`)
|
| 688 |
+
5. Test predictions and visualizations (`python main.py predict "test text"`)
|
| 689 |
+
6. Commit changes (`git commit -m 'Add amazing feature'`)
|
| 690 |
+
7. Push to branch (`git push origin feature/amazing-feature`)
|
| 691 |
+
8. Open a Pull Request
|
| 692 |
+
|
| 693 |
+
**Note**: Generated visualizations and trained models are gitignored. Contributors should train their own models locally for testing.
|
| 694 |
+
|
| 695 |
+
## ๐ License
|
| 696 |
+
|
| 697 |
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
| 698 |
+
|
| 699 |
+
## ๐ Acknowledgments & References
|
| 700 |
+
|
| 701 |
+
### Models & Frameworks
|
| 702 |
+
- **Hugging Face Transformers** - `microsoft/deberta-v3-base` model architecture
|
| 703 |
+
- **PyTorch** - Deep learning framework and automatic differentiation
|
| 704 |
+
- **DeBERTa-v3** (He et al., 2023) - Disentangled attention transformer architecture
|
| 705 |
+
- **Matplotlib/Seaborn** - Visualization libraries for emotion analysis charts
|
| 706 |
+
|
| 707 |
+
### Datasets & Research
|
| 708 |
+
- **`dair-ai/emotion`** - Mohammad, S. M. (2012). Portable features for classifying emotional text
|
| 709 |
+
- **`google-research-datasets/go_emotions`** - Demszky et al. (2020). GoEmotions: A Dataset of Fine-Grained Emotions
|
| 710 |
+
- **Emotion Theory** - Ekman's basic emotions framework (joy, sadness, anger, fear, surprise)
|
| 711 |
+
- **Music Information Retrieval** - Research on emotion-music mapping (Russell's Circumplex Model)
|
| 712 |
+
|
| 713 |
+
### Technical References
|
| 714 |
+
```bibtex
|
| 715 |
+
@article{he2023debertav3,
|
| 716 |
+
title={DeBERTaV3: Improving DeBERTa using ELECTRA-Style Pre-Training with Gradient-Disentangled Embedding Sharing},
|
| 717 |
+
author={He, Pengcheng and Gao, Jianfeng and Chen, Weizhu},
|
| 718 |
+
journal={arXiv preprint arXiv:2111.09543},
|
| 719 |
+
year={2023}
|
| 720 |
+
}
|
| 721 |
+
|
| 722 |
+
@inproceedings{demszky2020goemotions,
|
| 723 |
+
title={GoEmotions: A Dataset of Fine-Grained Emotions},
|
| 724 |
+
author={Demszky, Dorottya and Movshovitz-Attias, Dana and Ko, Jeongwoo and Cowen, Alan and Nemade, Gaurav and Ravi, Sujith},
|
| 725 |
+
booktitle={ACL},
|
| 726 |
+
year={2020}
|
| 727 |
+
}
|
| 728 |
+
```
|
| 729 |
+
|
| 730 |
---
|
| 731 |
+
|
| 732 |
+
## ๐ฏ **Project Status Summary** (April 20, 2026)
|
| 733 |
+
|
| 734 |
+
**EUMORA** is a **fully functional emotion detection system** with documented strengths and limitations.
|
| 735 |
+
|
| 736 |
+
### โ
What's Production-Ready
|
| 737 |
+
- Clear, unambiguous emotion detection (95%+ accuracy)
|
| 738 |
+
- Neutral content classification (89%+ accuracy)
|
| 739 |
+
- Cross-platform inference (CPU, CUDA, MPS)
|
| 740 |
+
- Automatic visualization and chart generation
|
| 741 |
+
- Bayesian sarcasm calibration for domain adaptation
|
| 742 |
+
|
| 743 |
+
### โ ๏ธ Known Limitations
|
| 744 |
+
- Sarcasm detection requires domain-specific calibration
|
| 745 |
+
- Mixed emotion cases show negative bias
|
| 746 |
+
- Single-sentence focus (no multi-turn context)
|
| 747 |
+
- May overestimate confidence on ambiguous inputs
|
| 748 |
+
|
| 749 |
+
### ๐ Current Recommendation
|
| 750 |
+
**Suitable for**: Research, prototyping, educational projects, proof-of-concepts
|
| 751 |
+
**Not recommended for**: Critical production systems without manual review, sensitive applications requiring near-perfect accuracy
|
| 752 |
+
|
| 753 |
+
### ๐ Next Major Version
|
| 754 |
+
Version 2.0 will add:
|
| 755 |
+
- Enhanced sarcasm and context understanding
|
| 756 |
+
- Multi-label emotion support
|
| 757 |
+
- Audio feature integration
|
| 758 |
+
- Web/mobile interfaces
|
| 759 |
+
|
| 760 |
+
----
|
| 761 |
+
|
| 762 |
+
๐ต **EUMORA** - *Understanding emotions, advancing music.* ๐ญ
|