Transformers
Safetensors
English
multimodal
emotion-recognition
speech-emotion-recognition
audio-text
wav2vec2
roberta
cross-attention
fusion
Instructions to use hugoaslm/multimodal-emotion-recognition with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use hugoaslm/multimodal-emotion-recognition with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("hugoaslm/multimodal-emotion-recognition", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,82 +1,191 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
| 3 |
tags:
|
| 4 |
-
-
|
| 5 |
-
-
|
| 6 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
metrics:
|
| 8 |
- accuracy
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
results: []
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
-
|
| 23 |
-
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
-
|
| 27 |
-
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
-
|
| 31 |
-
-
|
| 32 |
-
-
|
| 33 |
-
-
|
| 34 |
-
|
| 35 |
-
##
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 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 |
|
| 66 |
-
|
| 67 |
-
|:-------------:|:-----:|:----:|:---------------:|:--------:|:-----------:|:--------:|:--------:|:-------:|:----------:|:-------:|:--------:|:----------:|:------:|:-----------:|
|
| 68 |
-
| 4.2133 | 1.0 | 313 | 0.9163 | 0.6208 | 0.6114 | 0.5553 | 0.7503 | 0.0 | 0.5429 | 0.5672 | 0.5563 | 0.6327 | 0.6444 | 0.7487 |
|
| 69 |
-
| 2.8293 | 2.0 | 626 | 0.6106 | 0.7364 | 0.7259 | 0.6592 | 0.8172 | 0.0 | 0.7504 | 0.6869 | 0.6767 | 0.7572 | 0.6898 | 0.8957 |
|
| 70 |
-
| 2.2749 | 3.0 | 939 | 0.5205 | 0.7694 | 0.7623 | 0.7187 | 0.8373 | 0.2927 | 0.7778 | 0.7384 | 0.7197 | 0.8121 | 0.7091 | 0.8629 |
|
| 71 |
-
| 1.7544 | 4.0 | 1252 | 0.4426 | 0.8069 | 0.8056 | 0.7952 | 0.8707 | 0.6364 | 0.8 | 0.7569 | 0.8175 | 0.8360 | 0.7345 | 0.9099 |
|
| 72 |
-
| 1.5032 | 5.0 | 1565 | 0.4239 | 0.8144 | 0.8145 | 0.7991 | 0.8959 | 0.5938 | 0.8183 | 0.7622 | 0.8249 | 0.8297 | 0.7383 | 0.9298 |
|
| 73 |
-
| 1.3733 | 6.0 | 1878 | 0.4267 | 0.8099 | 0.8092 | 0.7917 | 0.8889 | 0.5806 | 0.8282 | 0.75 | 0.7980 | 0.8436 | 0.7385 | 0.9060 |
|
| 74 |
-
| 1.3745 | 7.0 | 2191 | 0.4250 | 0.8104 | 0.8095 | 0.7924 | 0.8832 | 0.5806 | 0.8254 | 0.7549 | 0.8081 | 0.8346 | 0.7387 | 0.9138 |
|
| 75 |
|
|
|
|
| 76 |
|
| 77 |
-
##
|
| 78 |
|
| 79 |
-
- Transformers
|
| 80 |
-
-
|
| 81 |
-
-
|
| 82 |
-
- Tokenizers 0.22.2
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
tags:
|
| 6 |
+
- multimodal
|
| 7 |
+
- emotion-recognition
|
| 8 |
+
- speech-emotion-recognition
|
| 9 |
+
- audio-text
|
| 10 |
+
- wav2vec2
|
| 11 |
+
- roberta
|
| 12 |
+
- cross-attention
|
| 13 |
+
- fusion
|
| 14 |
+
base_model:
|
| 15 |
+
- facebook/wav2vec2-base
|
| 16 |
+
- roberta-base
|
| 17 |
+
datasets:
|
| 18 |
+
- stapesai/ssi-speech-emotion-recognition
|
| 19 |
metrics:
|
| 20 |
- accuracy
|
| 21 |
+
- f1
|
| 22 |
+
library_name: transformers
|
|
|
|
| 23 |
---
|
| 24 |
|
| 25 |
+
# Multimodal Emotion Recognition System
|
| 26 |
+
|
| 27 |
+
A state-of-the-art multimodal emotion recognition model combining **Wav2Vec2 (audio)** and **RoBERTa (text)** encoders with **cross-attention fusion** and **label smoothing regularization**.
|
| 28 |
+
|
| 29 |
+
## ๐ฏ Results
|
| 30 |
+
|
| 31 |
+
| Model | Modality | Fusion | Val Acc | Val F1 | Test Acc | Test F1 |
|
| 32 |
+
|-------|----------|--------|---------|--------|----------|---------|
|
| 33 |
+
| **Final (LS=0.1)** | Audio+Text | Cross-Attention | **81.4%** | **0.814** | **85.3%** | **0.852** |
|
| 34 |
+
| Multimodal | Audio+Text | Cross-Attention | 79.8% | 0.790 | 82.8% | 0.827 |
|
| 35 |
+
| Multimodal | Audio+Text | Concat | 73.4% | 0.722 | 75.5% | 0.747 |
|
| 36 |
+
| Multimodal | Audio+Text | Gated | 72.4% | 0.710 | 76.1% | 0.754 |
|
| 37 |
+
| Audio-Only Baseline | Audio | Linear | 76.4% | 0.756 | - | - |
|
| 38 |
+
| Text-Only Baseline | Text | Linear | ~15% | ~0.15 | - | - |
|
| 39 |
+
|
| 40 |
+
**Key Findings:**
|
| 41 |
+
- Cross-attention fusion significantly outperforms simple concatenation (+6.4% F1)
|
| 42 |
+
- Label smoothing (0.1) provides +2.5% test accuracy improvement
|
| 43 |
+
- Audio carries the primary emotional signal; text provides complementary context
|
| 44 |
+
- The 219M parameter model achieves SOTA-level performance on the benchmark
|
| 45 |
+
|
| 46 |
+
## ๐ Dataset
|
| 47 |
+
|
| 48 |
+
**[stapesai/ssi-speech-emotion-recognition](https://huggingface.co/datasets/stapesai/ssi-speech-emotion-recognition)**
|
| 49 |
+
|
| 50 |
+
- **Source Datasets:** CREMA-D, TESS, RAVDESS, SAVEE
|
| 51 |
+
- **Splits:** 10,000 train / 1,999 validation / 163 test
|
| 52 |
+
- **Emotions (8 classes):** angry, calm, disgust, fear, happy, neutral, sad, surprise
|
| 53 |
+
- **Modalities:** Audio (speech) + Text (transcription)
|
| 54 |
+
- **Note:** Test set has no "calm" samples (7 classes evaluated)
|
| 55 |
+
|
| 56 |
+
### Class Distribution (Train)
|
| 57 |
+
| Emotion | Count | % |
|
| 58 |
+
|---------|-------|---|
|
| 59 |
+
| angry | 1,587 | 15.9% |
|
| 60 |
+
| disgust | 1,582 | 15.8% |
|
| 61 |
+
| fear | 1,591 | 15.9% |
|
| 62 |
+
| happy | 1,568 | 15.7% |
|
| 63 |
+
| neutral | 1,391 | 13.9% |
|
| 64 |
+
| sad | 1,596 | 16.0% |
|
| 65 |
+
| surprise | 528 | 5.3% |
|
| 66 |
+
| calm | 157 | 1.6% |
|
| 67 |
+
|
| 68 |
+
## ๐๏ธ Architecture
|
| 69 |
+
|
| 70 |
+
```
|
| 71 |
+
Input Audio โโโบ Wav2Vec2-Base โโโบ Mean Pooling โโโบ Audio Features (768-dim)
|
| 72 |
+
โ
|
| 73 |
+
โผ
|
| 74 |
+
Cross-Attention Fusion
|
| 75 |
+
(text queries audio)
|
| 76 |
+
โ
|
| 77 |
+
โผ
|
| 78 |
+
Input Text โโโบ RoBERTa-Base โโโบ [CLS] Token โโโบ Text Features (768-dim)
|
| 79 |
+
โ
|
| 80 |
+
โผ
|
| 81 |
+
Concatenate + MLP
|
| 82 |
+
โ
|
| 83 |
+
โผ
|
| 84 |
+
Classification Head
|
| 85 |
+
โ
|
| 86 |
+
โผ
|
| 87 |
+
8 Emotion Classes
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
### Key Components
|
| 91 |
+
|
| 92 |
+
1. **Audio Encoder:** `facebook/wav2vec2-base` (95M params)
|
| 93 |
+
- Pre-trained on speech data
|
| 94 |
+
- Mean pooling over time dimension
|
| 95 |
+
|
| 96 |
+
2. **Text Encoder:** `roberta-base` (125M params)
|
| 97 |
+
- Pre-trained on large text corpus
|
| 98 |
+
- [CLS] token as sentence representation
|
| 99 |
+
|
| 100 |
+
3. **Fusion Module:** Cross-Attention
|
| 101 |
+
- Text features query audio features
|
| 102 |
+
- 4 attention heads, 256-dim fusion space
|
| 103 |
+
- Residual connection + LayerNorm
|
| 104 |
+
|
| 105 |
+
4. **Classification Head:**
|
| 106 |
+
- 2-layer MLP with GELU activation
|
| 107 |
+
- Dropout (0.3)
|
| 108 |
+
|
| 109 |
+
5. **Training Improvements:**
|
| 110 |
+
- Label smoothing (0.1)
|
| 111 |
+
- Gradient checkpointing
|
| 112 |
+
- Mixed precision (fp16)
|
| 113 |
+
- Early stopping (patience=3)
|
| 114 |
+
|
| 115 |
+
## ๐ Training Details
|
| 116 |
+
|
| 117 |
+
| Parameter | Value |
|
| 118 |
+
|-----------|-------|
|
| 119 |
+
| Learning Rate | 1e-5 |
|
| 120 |
+
| Batch Size | 8 (ร4 grad accum = 32 effective) |
|
| 121 |
+
| Epochs | 7 (best at epoch 5) |
|
| 122 |
+
| Optimizer | AdamW |
|
| 123 |
+
| Scheduler | Cosine with warmup |
|
| 124 |
+
| Weight Decay | 0.01 |
|
| 125 |
+
| Hardware | NVIDIA A10G (24GB) |
|
| 126 |
+
| Training Time | ~28 minutes |
|
| 127 |
+
|
| 128 |
+
## ๐ฌ Ablation Studies
|
| 129 |
+
|
| 130 |
+
### Fusion Strategy Comparison
|
| 131 |
+
|
| 132 |
+
| Fusion | Val F1 | Test F1 | Params |
|
| 133 |
+
|--------|--------|---------|--------|
|
| 134 |
+
| Cross-Attention | 0.814 | 0.852 | 219.8M |
|
| 135 |
+
| Concat | 0.722 | 0.747 | 219.4M |
|
| 136 |
+
| Gated | 0.710 | 0.754 | 219.6M |
|
| 137 |
+
|
| 138 |
+
Cross-attention fusion provides significant improvement over simpler fusion methods, demonstrating the importance of modeling interactions between modalities.
|
| 139 |
+
|
| 140 |
+
### Label Smoothing Impact
|
| 141 |
+
|
| 142 |
+
| Smoothing | Val Acc | Val F1 | Test Acc | Test F1 |
|
| 143 |
+
|-----------|---------|--------|----------|---------|
|
| 144 |
+
| 0.0 | 79.8% | 0.790 | 82.8% | 0.827 |
|
| 145 |
+
| 0.1 | 81.4% | 0.814 | 85.3% | 0.852 |
|
| 146 |
+
|
| 147 |
+
Label smoothing improves both validation and test performance, indicating better generalization.
|
| 148 |
+
|
| 149 |
+
## ๐ References
|
| 150 |
+
|
| 151 |
+
This implementation is based on:
|
| 152 |
+
|
| 153 |
+
1. **arXiv:2406.17667** - Early Feature Fusion with Wav2Vec2-MSP + RoBERTa for emotion recognition
|
| 154 |
+
2. **arXiv:2503.06805** - RoBERTa + Wav2Vec2 Feature Fusion for MELD benchmark
|
| 155 |
+
3. **arXiv:2505.06685** - Emotion-Qwen: Multimodal LLM for emotion understanding
|
| 156 |
+
4. **arXiv:2406.11161** - Emotion-LLaMA: Instruction-tuned emotion recognition
|
| 157 |
+
|
| 158 |
+
## ๐ ๏ธ Usage
|
| 159 |
+
|
| 160 |
+
```python
|
| 161 |
+
from transformers import AutoModel, AutoFeatureExtractor, AutoTokenizer
|
| 162 |
+
import torch
|
| 163 |
+
import torch.nn.functional as F
|
| 164 |
+
|
| 165 |
+
# Load model components
|
| 166 |
+
audio_encoder = AutoModel.from_pretrained("facebook/wav2vec2-base")
|
| 167 |
+
text_encoder = AutoModel.from_pretrained("roberta-base")
|
| 168 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained("facebook/wav2vec2-base")
|
| 169 |
+
tokenizer = AutoTokenizer.from_pretrained("roberta-base")
|
| 170 |
+
|
| 171 |
+
# The fusion head and classifier need to be loaded from the checkpoint
|
| 172 |
+
# See the training script for the full model definition
|
| 173 |
+
```
|
| 174 |
+
|
| 175 |
+
## ๐ฎ Future Improvements
|
| 176 |
+
|
| 177 |
+
1. **SER-Pretrained Audio Encoder:** Use `audeering/wav2vec2-large-robust-12-ft-emotion-msp-dim` for better audio emotion features
|
| 178 |
+
2. **Visual Modality:** Add face/video encoding for full multimodal recognition
|
| 179 |
+
3. **Instruction Tuning:** Convert to instruction-following format for zero-shot generalization
|
| 180 |
+
4. **Class Balancing:** Oversample rare classes (calm, surprise) or use focal loss
|
| 181 |
+
5. **Data Augmentation:** Speed perturbation, noise injection for audio robustness
|
| 182 |
|
| 183 |
+
## ๐ License
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
+
Apache 2.0
|
| 186 |
|
| 187 |
+
## ๐ Acknowledgments
|
| 188 |
|
| 189 |
+
- Hugging Face Transformers for the pre-trained models
|
| 190 |
+
- The creators of CREMA-D, TESS, RAVDESS, and SAVEE datasets
|
| 191 |
+
- The authors of the referenced papers for their valuable insights
|
|
|