Update README.md
Browse files
README.md
CHANGED
@@ -1,210 +1,140 @@
|
|
1 |
---
|
2 |
language: en
|
3 |
tags:
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
datasets:
|
11 |
-
|
12 |
license: mit
|
13 |
widget:
|
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 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
#### Summary
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
## Model Examination [optional]
|
147 |
-
|
148 |
-
<!-- Relevant interpretability work for the model goes here -->
|
149 |
-
|
150 |
-
[More Information Needed]
|
151 |
-
|
152 |
-
## Environmental Impact
|
153 |
-
|
154 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
155 |
-
|
156 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
157 |
-
|
158 |
-
- **Hardware Type:** [More Information Needed]
|
159 |
-
- **Hours used:** [More Information Needed]
|
160 |
-
- **Cloud Provider:** [More Information Needed]
|
161 |
-
- **Compute Region:** [More Information Needed]
|
162 |
-
- **Carbon Emitted:** [More Information Needed]
|
163 |
-
|
164 |
-
## Technical Specifications [optional]
|
165 |
-
|
166 |
-
### Model Architecture and Objective
|
167 |
-
|
168 |
-
[More Information Needed]
|
169 |
-
|
170 |
-
### Compute Infrastructure
|
171 |
-
|
172 |
-
[More Information Needed]
|
173 |
-
|
174 |
-
#### Hardware
|
175 |
-
|
176 |
-
[More Information Needed]
|
177 |
-
|
178 |
-
#### Software
|
179 |
-
|
180 |
-
[More Information Needed]
|
181 |
-
|
182 |
-
## Citation [optional]
|
183 |
-
|
184 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
185 |
-
|
186 |
-
**BibTeX:**
|
187 |
-
|
188 |
-
[More Information Needed]
|
189 |
-
|
190 |
-
**APA:**
|
191 |
-
|
192 |
-
[More Information Needed]
|
193 |
-
|
194 |
-
## Glossary [optional]
|
195 |
-
|
196 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
197 |
-
|
198 |
-
[More Information Needed]
|
199 |
-
|
200 |
-
## More Information [optional]
|
201 |
-
|
202 |
-
[More Information Needed]
|
203 |
-
|
204 |
-
## Model Card Authors [optional]
|
205 |
-
|
206 |
-
[More Information Needed]
|
207 |
-
|
208 |
-
## Model Card Contact
|
209 |
-
|
210 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
language: en
|
3 |
tags:
|
4 |
+
- text-classification
|
5 |
+
- pytorch
|
6 |
+
- roberta
|
7 |
+
- emotions
|
8 |
+
- multi-class-classification
|
9 |
+
- multi-label-classification
|
10 |
datasets:
|
11 |
+
- go_emotions
|
12 |
license: mit
|
13 |
widget:
|
14 |
+
- text: I am not having a great day.
|
15 |
---
|
16 |
|
17 |
+
#### Overview
|
18 |
+
|
19 |
+
Model trained from [roberta-base](https://huggingface.co/roberta-base) on the [go_emotions](https://huggingface.co/datasets/go_emotions) dataset for multi-label classification.
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
#### How the model was created
|
24 |
+
|
25 |
+
The model was trained using `AutoModelForSequenceClassification.from_pretrained` with `problem_type="multi_label_classification"` for 3 epochs with a learning rate of 2e-5 and weight decay of 0.01.
|
26 |
+
|
27 |
+
#### Inference
|
28 |
+
|
29 |
+
There are multiple ways to use this model in Huggingface Transformers. Possibly the simplest is using a pipeline:
|
30 |
+
|
31 |
+
```python
|
32 |
+
from transformers import pipeline
|
33 |
+
|
34 |
+
classifier = pipeline(task="text-classification", model="ShahzadSohail/emotion_detection_model_final", top_k=None)
|
35 |
+
|
36 |
+
sentences = ["I am not having a great day"]
|
37 |
+
|
38 |
+
model_outputs = classifier(sentences)
|
39 |
+
print(model_outputs[0])
|
40 |
+
# produces a list of dicts for each of the labels
|
41 |
+
```
|
42 |
+
|
43 |
+
|
44 |
+
|
45 |
+
##### Summary
|
46 |
+
|
47 |
+
As provided in the above notebook, evaluation of the multi-label output (of the 28 dim output via a threshold of 0.5 to binarize each) using the dataset test split gives:
|
48 |
+
|
49 |
+
- Accuracy: 0.474
|
50 |
+
- Precision: 0.575
|
51 |
+
- Recall: 0.396
|
52 |
+
- F1: 0.450
|
53 |
+
|
54 |
+
But the metrics are more meaningful when measured per label given the multi-label nature (each label is effectively an independent binary classification) and the fact that there is drastically different representations of the labels in the dataset.
|
55 |
+
|
56 |
+
With a threshold of 0.5 applied to binarize the model outputs, as per the above notebook, the metrics per label are:
|
57 |
+
|
58 |
+
| | accuracy | precision | recall | f1 | mcc | support | threshold |
|
59 |
+
| -------------- | -------- | --------- | ------ | ----- | ----- | ------- | --------- |
|
60 |
+
| admiration | 0.946 | 0.725 | 0.675 | 0.699 | 0.670 | 504 | 0.5 |
|
61 |
+
| amusement | 0.982 | 0.790 | 0.871 | 0.829 | 0.821 | 264 | 0.5 |
|
62 |
+
| anger | 0.970 | 0.652 | 0.379 | 0.479 | 0.483 | 198 | 0.5 |
|
63 |
+
| annoyance | 0.940 | 0.472 | 0.159 | 0.238 | 0.250 | 320 | 0.5 |
|
64 |
+
| approval | 0.942 | 0.609 | 0.302 | 0.404 | 0.403 | 351 | 0.5 |
|
65 |
+
| caring | 0.973 | 0.448 | 0.319 | 0.372 | 0.364 | 135 | 0.5 |
|
66 |
+
| confusion | 0.972 | 0.500 | 0.431 | 0.463 | 0.450 | 153 | 0.5 |
|
67 |
+
| curiosity | 0.950 | 0.537 | 0.356 | 0.428 | 0.412 | 284 | 0.5 |
|
68 |
+
| desire | 0.987 | 0.630 | 0.410 | 0.496 | 0.502 | 83 | 0.5 |
|
69 |
+
| disappointment | 0.974 | 0.625 | 0.199 | 0.302 | 0.343 | 151 | 0.5 |
|
70 |
+
| disapproval | 0.950 | 0.494 | 0.307 | 0.379 | 0.365 | 267 | 0.5 |
|
71 |
+
| disgust | 0.982 | 0.707 | 0.333 | 0.453 | 0.478 | 123 | 0.5 |
|
72 |
+
| embarrassment | 0.994 | 0.750 | 0.243 | 0.367 | 0.425 | 37 | 0.5 |
|
73 |
+
| excitement | 0.983 | 0.603 | 0.340 | 0.435 | 0.445 | 103 | 0.5 |
|
74 |
+
| fear | 0.992 | 0.758 | 0.603 | 0.671 | 0.672 | 78 | 0.5 |
|
75 |
+
| gratitude | 0.990 | 0.960 | 0.881 | 0.919 | 0.914 | 352 | 0.5 |
|
76 |
+
| grief | 0.999 | 0.000 | 0.000 | 0.000 | 0.000 | 6 | 0.5 |
|
77 |
+
| joy | 0.978 | 0.647 | 0.559 | 0.600 | 0.590 | 161 | 0.5 |
|
78 |
+
| love | 0.982 | 0.773 | 0.832 | 0.802 | 0.793 | 238 | 0.5 |
|
79 |
+
| nervousness | 0.996 | 0.600 | 0.130 | 0.214 | 0.278 | 23 | 0.5 |
|
80 |
+
| optimism | 0.972 | 0.667 | 0.376 | 0.481 | 0.488 | 186 | 0.5 |
|
81 |
+
| pride | 0.997 | 0.000 | 0.000 | 0.000 | 0.000 | 16 | 0.5 |
|
82 |
+
| realization | 0.974 | 0.541 | 0.138 | 0.220 | 0.264 | 145 | 0.5 |
|
83 |
+
| relief | 0.998 | 0.000 | 0.000 | 0.000 | 0.000 | 11 | 0.5 |
|
84 |
+
| remorse | 0.991 | 0.553 | 0.750 | 0.636 | 0.640 | 56 | 0.5 |
|
85 |
+
| sadness | 0.977 | 0.621 | 0.494 | 0.550 | 0.542 | 156 | 0.5 |
|
86 |
+
| surprise | 0.981 | 0.750 | 0.404 | 0.525 | 0.542 | 141 | 0.5 |
|
87 |
+
| neutral | 0.782 | 0.694 | 0.604 | 0.646 | 0.492 | 1787 | 0.5 |
|
88 |
+
|
89 |
+
Optimizing the threshold per label for the one that gives the optimum F1 metrics gives slightly better metrics - sacrificing some precision for a greater gain in recall, hence to the benefit of F1 (how this was done is shown in the above notebook):
|
90 |
+
|
91 |
+
| | accuracy | precision | recall | f1 | mcc | support | threshold |
|
92 |
+
| -------------- | -------- | --------- | ------ | ----- | ----- | ------- | --------- |
|
93 |
+
| admiration | 0.940 | 0.651 | 0.776 | 0.708 | 0.678 | 504 | 0.25 |
|
94 |
+
| amusement | 0.982 | 0.781 | 0.890 | 0.832 | 0.825 | 264 | 0.45 |
|
95 |
+
| anger | 0.959 | 0.454 | 0.601 | 0.517 | 0.502 | 198 | 0.15 |
|
96 |
+
| annoyance | 0.864 | 0.243 | 0.619 | 0.349 | 0.328 | 320 | 0.10 |
|
97 |
+
| approval | 0.926 | 0.432 | 0.442 | 0.437 | 0.397 | 351 | 0.30 |
|
98 |
+
| caring | 0.972 | 0.426 | 0.385 | 0.405 | 0.391 | 135 | 0.40 |
|
99 |
+
| confusion | 0.974 | 0.548 | 0.412 | 0.470 | 0.462 | 153 | 0.55 |
|
100 |
+
| curiosity | 0.943 | 0.473 | 0.711 | 0.568 | 0.552 | 284 | 0.25 |
|
101 |
+
| desire | 0.985 | 0.518 | 0.530 | 0.524 | 0.516 | 83 | 0.25 |
|
102 |
+
| disappointment | 0.974 | 0.562 | 0.298 | 0.390 | 0.398 | 151 | 0.40 |
|
103 |
+
| disapproval | 0.941 | 0.414 | 0.468 | 0.439 | 0.409 | 267 | 0.30 |
|
104 |
+
| disgust | 0.978 | 0.523 | 0.463 | 0.491 | 0.481 | 123 | 0.20 |
|
105 |
+
| embarrassment | 0.994 | 0.567 | 0.459 | 0.507 | 0.507 | 37 | 0.10 |
|
106 |
+
| excitement | 0.981 | 0.500 | 0.417 | 0.455 | 0.447 | 103 | 0.35 |
|
107 |
+
| fear | 0.991 | 0.712 | 0.667 | 0.689 | 0.685 | 78 | 0.40 |
|
108 |
+
| gratitude | 0.990 | 0.957 | 0.889 | 0.922 | 0.917 | 352 | 0.45 |
|
109 |
+
| grief | 0.999 | 0.333 | 0.333 | 0.333 | 0.333 | 6 | 0.05 |
|
110 |
+
| joy | 0.978 | 0.623 | 0.646 | 0.634 | 0.623 | 161 | 0.40 |
|
111 |
+
| love | 0.982 | 0.740 | 0.899 | 0.812 | 0.807 | 238 | 0.25 |
|
112 |
+
| nervousness | 0.996 | 0.571 | 0.348 | 0.432 | 0.444 | 23 | 0.25 |
|
113 |
+
| optimism | 0.971 | 0.580 | 0.565 | 0.572 | 0.557 | 186 | 0.20 |
|
114 |
+
| pride | 0.998 | 0.875 | 0.438 | 0.583 | 0.618 | 16 | 0.10 |
|
115 |
+
| realization | 0.961 | 0.270 | 0.262 | 0.266 | 0.246 | 145 | 0.15 |
|
116 |
+
| relief | 0.992 | 0.152 | 0.636 | 0.246 | 0.309 | 11 | 0.05 |
|
117 |
+
| remorse | 0.991 | 0.541 | 0.946 | 0.688 | 0.712 | 56 | 0.10 |
|
118 |
+
| sadness | 0.977 | 0.599 | 0.583 | 0.591 | 0.579 | 156 | 0.40 |
|
119 |
+
| surprise | 0.977 | 0.543 | 0.674 | 0.601 | 0.593 | 141 | 0.15 |
|
120 |
+
| neutral | 0.758 | 0.598 | 0.810 | 0.688 | 0.513 | 1787 | 0.25 |
|
121 |
+
|
122 |
+
This improves the overall metrics:
|
123 |
+
|
124 |
+
- Precision: 0.542
|
125 |
+
- Recall: 0.577
|
126 |
+
- F1: 0.541
|
127 |
+
|
128 |
+
Or if calculated weighted by the relative size of the support of each label:
|
129 |
+
|
130 |
+
- Precision: 0.572
|
131 |
+
- Recall: 0.677
|
132 |
+
- F1: 0.611
|
133 |
+
|
134 |
+
#### Commentary on the dataset
|
135 |
+
|
136 |
+
Some labels (E.g. gratitude) when considered independently perform very strongly with F1 exceeding 0.9, whilst others (E.g. relief) perform very poorly.
|
137 |
+
|
138 |
+
This is a challenging dataset. Labels such as relief do have much fewer examples in the training data (less than 100 out of the 40k+, and only 11 in the test split).
|
139 |
+
|
140 |
+
But there is also some ambiguity and/or labelling errors visible in the training data of go_emotions that is suspected to constrain the performance. Data cleaning on the dataset to reduce some of the mistakes, ambiguity, conflicts and duplication in the labelling would produce a higher performing model.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|