yezdata commited on
Commit
29c0a9c
·
verified ·
1 Parent(s): 50cb585

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -191
README.md DELETED
@@ -1,191 +0,0 @@
1
- ---
2
- language:
3
- - en
4
- license: cc-by-nc-nd-4.0
5
- library_name: generic
6
- tags:
7
- - emotion-recognition
8
- - bayesian-deep-learning
9
- - mc-dropout
10
- - uncertainty-quantification
11
- - multi-label-classification
12
- datasets:
13
- - Skylion007/openwebtext
14
- - google-research-datasets/go_emotions
15
- metrics:
16
- - precision
17
- - recall
18
- - f1
19
- model-index:
20
- - name: EmCoder (v1)
21
- results:
22
- - task:
23
- type: text-classification
24
- name: Multi-label Emotion Classification
25
- dataset:
26
- name: GoEmotions
27
- type: go_emotions
28
- split: test
29
- metrics:
30
- - name: Macro F1
31
- type: f1
32
- value: 0.44
33
- - name: Macro Precision
34
- type: precision
35
- value: 0.408
36
- - name: Macro Recall
37
- type: recall
38
- value: 0.495
39
- ---
40
-
41
- # EmCoder
42
- <blockquote>
43
- <b>Probabilistic Emotion Recognition & Uncertainty Quantification</b><br>
44
- <b>28 Emotion multi-label classifier trained with MC Dropout methodology</b>
45
- </blockquote>
46
-
47
-
48
- Unlike standard classifiers, EmCoder quantifies what it doesn't know using Monte Carlo Dropout, making it suitable for high-stakes AI pipelines.<br>
49
- EmCoder is optimized for **MC Dropout inference**.
50
-
51
-
52
-
53
- ## SOTA benchmark
54
- ### Evaluation on the GoEmotions test split (macro avg metrics)
55
- EmCoder achieves competitive F1-scores while being ~35% smaller than RoBERTa-base and ~45% smaller than ModernBERT, offering a superior efficiency-to-uncertainty ratio.
56
- | Model | Precision | Recall | F1-Score | Params |
57
- | :--- | :--- | :--- | :--- | :--- |
58
- | **EmCoder (v1)** | **0.408** | **0.495** | **0.440** | **82.1M** |
59
- | Google BERT (Original) | 0.400 | 0.630 | 0.460 | 110M |
60
- | RoBERTa-base | 0.575 | 0.396 | 0.450 | 125M |
61
- | ModernBERT-base | 0.652 | 0.443 | 0.500 | 149M |
62
-
63
-
64
- ## How to use
65
- Since `.safetensors` files only store model weights and not the class logic, you need to use the provided `emcoder.py` to enable **MC Dropout inference**.<br>EmCoder v1.0 requires the `roberta-base` tokenizer for correct token-to-embedding mapping.
66
-
67
-
68
- ### 1. Setup & Tokenization
69
- ```python
70
- from transformers import AutoTokenizer
71
- from emcoder import EmCoder # Ensure emcoder.py is in your directory
72
-
73
- # Load the same tokenizer used during training
74
- tokenizer = AutoTokenizer.from_pretrained("roberta-base")
75
-
76
- EMCODER_PATH = "path/to/emcoder"
77
-
78
- # Initialize with same config as training
79
- model = EmCoder.from_pretrained(EMCODER_PATH)
80
- ```
81
- ### 2. Bayesian inference
82
- To obtain probabilistic outputs and uncertainty metrics, use the mc_forward method:
83
- ```python
84
- import torch
85
-
86
- # Perform 50 stochastic passes
87
- N_SAMPLES = 50
88
- model.eval()
89
-
90
- inputs = tokenizer("I am so happy you are here!", return_tensors="pt")
91
- logits_mc = model.mc_forward(inputs['input_ids'], inputs['attention_mask'], n_samples=N_SAMPLES) # Automatically keeps Dropout active, even when in model.eval
92
-
93
- # Bayesian Post-processing
94
- # logits_mc shape: (n_samples, batch_size, 28)
95
- probs_all = torch.sigmoid(logits_mc)
96
-
97
- mean_probs = probs_all.mean(dim=0) # Mean Predicted Probability
98
- uncertainty = probs_all.std(dim=0) # Epistemic Uncertainty (Standard Deviation)
99
- ```
100
-
101
-
102
-
103
- ## Model Architecture
104
- ![EmCoder Architecture](outputs/architecture.png)
105
-
106
-
107
- ### Optimization
108
- The model is trained using a Weighted Bayesian Binary Cross Entropy loss:
109
-
110
- $$
111
- \mathcal{L}_{Bayesian} = \frac{1}{T} \sum_{t=1}^{T} \text{BCEWithLogits}(z^{(t)}, y; w)
112
- $$
113
-
114
- Where weights $w$ are calculated using a logarithmic class-balancing scale to handle extreme label imbalance:
115
-
116
- $$
117
- w_{c} = \max\left( 0.1, \min\left( 20, 1 + \ln \left( \frac{N_{neg,c} + \epsilon}{N_{pos,c} + \epsilon} \right) \right) \right)
118
- $$
119
-
120
-
121
-
122
- ## Performance
123
- **Using threshold of 0.5 for binarizing predictions**
124
- | | precision | recall | f1-score | support |
125
- |:---------------|------------:|---------:|-----------:|----------:|
126
- | micro avg | 0.494 | 0.596 | 0.54 | 6329 |
127
- | macro avg | 0.408 | 0.495 | 0.44 | 6329 |
128
- | weighted avg | 0.492 | 0.596 | 0.535 | 6329 |
129
- | samples avg | 0.525 | 0.616 | 0.544 | 6329 |
130
- |----------------|-------------|----------|------------|-----------|
131
- | admiration | 0.541 | 0.673 | 0.599 | 504 |
132
- | amusement | 0.688 | 0.909 | 0.783 | 264 |
133
- | anger | 0.419 | 0.47 | 0.443 | 198 |
134
- | annoyance | 0.31 | 0.25 | 0.277 | 320 |
135
- | approval | 0.304 | 0.271 | 0.287 | 351 |
136
- | caring | 0.229 | 0.281 | 0.252 | 135 |
137
- | confusion | 0.26 | 0.497 | 0.342 | 153 |
138
- | curiosity | 0.432 | 0.764 | 0.552 | 284 |
139
- | desire | 0.453 | 0.518 | 0.483 | 83 |
140
- | disappointment | 0.176 | 0.152 | 0.163 | 151 |
141
- | disapproval | 0.279 | 0.404 | 0.33 | 267 |
142
- | disgust | 0.447 | 0.545 | 0.491 | 123 |
143
- | embarrassment | 0.325 | 0.351 | 0.338 | 37 |
144
- | excitement | 0.288 | 0.427 | 0.344 | 103 |
145
- | fear | 0.47 | 0.692 | 0.56 | 78 |
146
- | gratitude | 0.834 | 0.943 | 0.885 | 352 |
147
- | grief | 0 | 0 | 0 | 6 |
148
- | joy | 0.445 | 0.652 | 0.529 | 161 |
149
- | love | 0.724 | 0.895 | 0.801 | 238 |
150
- | nervousness | 0.24 | 0.261 | 0.25 | 23 |
151
- | optimism | 0.483 | 0.543 | 0.511 | 186 |
152
- | pride | 0.667 | 0.375 | 0.48 | 16 |
153
- | realization | 0.226 | 0.166 | 0.191 | 145 |
154
- | relief | 0.222 | 0.182 | 0.2 | 11 |
155
- | remorse | 0.516 | 0.857 | 0.644 | 56 |
156
- | sadness | 0.405 | 0.545 | 0.464 | 156 |
157
- | surprise | 0.429 | 0.539 | 0.478 | 141 |
158
- | neutral | 0.602 | 0.695 | 0.645 | 1787 |
159
-
160
-
161
-
162
- **Model uncertainty estimation**
163
- ![epistemic_unc](outputs/epistemic_unc_scatter.png)
164
-
165
- **Confusion matrix**
166
- ![multi_label_confusion_matrix](outputs/confusion_matrix.png)
167
-
168
-
169
-
170
- ## Workflow
171
- ![EmCoder Workflow](outputs/workflow.png)
172
-
173
-
174
- ### Note
175
- Note that this model was trained on GoEmotions dataset (social networks domain) and it may not generalize well to other domains.
176
-
177
-
178
- ## Citation
179
- If you use this model, please cite it as follows:
180
-
181
- ```bibtex
182
- @software{jez2026emcoder,
183
- author = {Václav Jež},
184
- title = {EmCoder: Probabilistic Emotion Recognition & Uncertainty Quantification},
185
- year = {2026},
186
- publisher = {GitHub},
187
- journal = {GitHub repository},
188
- howpublished = {\url{https://github.com/yezdata/emcoder}},
189
- version = {1.0.0}
190
- }
191
- ```