cirimus commited on
Commit
119c285
·
verified ·
1 Parent(s): 5c8b58c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +194 -154
README.md CHANGED
@@ -1,199 +1,239 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  library_name: transformers
3
- tags: []
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
- ## Model Details
13
-
14
- ### Model Description
15
-
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
-
52
- ### Out-of-Scope Use
53
-
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
-
109
- #### Testing Data
110
-
111
- <!-- This should link to a Dataset Card if possible. -->
112
-
113
- [More Information Needed]
114
-
115
- #### Factors
116
-
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
118
-
119
- [More Information Needed]
120
-
121
- #### Metrics
122
-
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
- [More Information Needed]
126
 
127
- ### Results
 
 
 
 
 
 
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
132
 
 
133
 
 
 
 
134
 
135
- ## Model Examination [optional]
 
 
 
 
 
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
 
138
 
139
- [More Information Needed]
 
 
140
 
141
- ## Environmental Impact
 
 
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
 
 
 
 
 
 
 
144
 
145
- 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).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
 
 
 
 
 
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
164
 
165
- [More Information Needed]
166
 
167
- #### Software
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
 
 
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
182
 
183
- ## Glossary [optional]
 
 
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
 
 
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
 
 
 
1
  ---
2
+ language: en
3
+ tags:
4
+ - text-classification
5
+ - pytorch
6
+ - ModernBERT
7
+ - emotions
8
+ - multi-class-classification
9
+ - multi-label-classification
10
+ datasets:
11
+ - go_emotions
12
+ license: mit
13
+ metrics:
14
+ - accuracy
15
+ - f1
16
+ - precision
17
+ - recall
18
+ - matthews_correlation
19
+ base_model:
20
+ - answerdotai/ModernBERT-base
21
+ widget:
22
+ - text: I am thrilled to be a part of this amazing journey!
23
+ - text: I feel so disappointed with the results.
24
+ - text: This is a neutral statement about cake.
25
  library_name: transformers
 
26
  ---
27
 
 
28
 
29
+ # Model Card for YourModelName
30
 
31
+ ### Overview
32
 
33
+ This model was fine-tuned from [ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) on the [GoEmotions](https://huggingface.co/datasets/google-research-datasets/go_emotions) dataset for multi-label classification. It predicts emotional states in text, with a total of 28 possible labels. Each input text can have one or more associated labels, reflecting the multi-label nature of the task.
34
 
35
+ ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ ### Model Details
38
 
39
+ - **Base Model**: [ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base)
40
+ - **Fine-Tuning Dataset**: [GoEmotions](https://huggingface.co/datasets/go_emotions)
41
+ - **Number of Labels**: 28
42
+ - **Problem Type**: Multi-label classification
43
+ - **Language**: English
44
+ - **License**: [MIT](https://opensource.org/licenses/MIT)
45
+ - **Fine-Tuning Framework**: Hugging Face Transformers
46
 
47
+ ---
48
 
49
+ ### Example Usage
50
 
51
+ Here’s how to use the model with Hugging Face Transformers:
52
 
53
+ ```python
54
+ from transformers import pipeline
55
+ import torch
56
 
57
+ # Load the model
58
+ classifier = pipeline(
59
+ "text-classification",
60
+ model="cirimus/modernbert-base-go-emotions",
61
+ return_all_scores=True
62
+ )
63
 
64
+ text = "I am so happy and excited about this opportunity!"
65
+ predictions = classifier(text)
66
 
67
+ # Print top 5 detected emotions
68
+ sorted_preds = sorted(predictions[0], key=lambda x: x['score'], reverse=True)
69
+ top_5 = sorted_preds[:5]
70
 
71
+ print("\nTop 5 emotions detected:")
72
+ for pred in top_5:
73
+ print(f"{pred['label']}: {pred['score']:.3f}")
74
 
75
+ # Example output:
76
+ # Top 5 emotions detected:
77
+ # excitement: 0.937
78
+ # joy: 0.915
79
+ # desire: 0.022
80
+ # love: 0.020
81
+ # admiration: 0.017
82
+ ```
83
 
 
84
 
 
 
 
 
 
85
 
86
+ ### How the Model Was Created
87
 
88
+ The model was fine-tuned for 3 epochs using the following hyperparameters:
89
 
90
+ - **Learning Rate**: `2e-5`
91
+ - **Batch Size**: 16
92
+ - **Weight Decay**: `0.01`
93
+ - **Warmup Steps**: 500
94
+ - **Optimizer**: AdamW
95
+ - **Evaluation Metrics**: Precision, Recall, F1 Score (weighted), Accuracy
96
 
97
+ ---
98
 
99
+ ### Dataset
100
 
101
+ The [GoEmotions](https://huggingface.co/datasets/google-research-datasets/go_emotions) dataset is a multi-label emotion classification dataset derived from Reddit comments. It contains 58,000 examples with 28 emotion labels (e.g., admiration, amusement, anger, etc.), and it is annotated for multi-label classification.
102
 
103
+ ---
104
 
105
+ ### Evaluation Results
106
+
107
+ The model was evaluated on the test split of the GoEmotions dataset, using a threshold of `0.5` for binarizing predictions. The overall metrics were:
108
+
109
+
110
+ **Standard Results**:
111
+
112
+ Using the default threshold of 0.5.
113
+
114
+ *Macro Averages (test)*
115
+ - Accuracy: `0.970`
116
+ - Precision: `0.665`
117
+ - Recall: `0.389`
118
+ - F1: `0.465`
119
+ - MCC: `0.477`
120
+
121
+ *Per-Label Results (test)*
122
+
123
+ | Label | Accuracy | Precision | Recall | F1 | MCC | Support | Threshold |
124
+ |----------------|----------|-----------|--------|-------|-------|---------|-----------|
125
+ | admiration | 0.945 | 0.737 | 0.627 | 0.677 | 0.650 | 504 | 0.5 |
126
+ | amusement | 0.980 | 0.794 | 0.803 | 0.798 | 0.788 | 264 | 0.5 |
127
+ | anger | 0.968 | 0.680 | 0.258 | 0.374 | 0.406 | 198 | 0.5 |
128
+ | annoyance | 0.940 | 0.468 | 0.159 | 0.238 | 0.249 | 320 | 0.5 |
129
+ | approval | 0.942 | 0.614 | 0.276 | 0.381 | 0.387 | 351 | 0.5 |
130
+ | caring | 0.976 | 0.524 | 0.244 | 0.333 | 0.347 | 135 | 0.5 |
131
+ | confusion | 0.975 | 0.625 | 0.294 | 0.400 | 0.418 | 153 | 0.5 |
132
+ | curiosity | 0.951 | 0.538 | 0.423 | 0.473 | 0.452 | 284 | 0.5 |
133
+ | desire | 0.987 | 0.604 | 0.349 | 0.443 | 0.453 | 83 | 0.5 |
134
+ | disappointment | 0.974 | 0.656 | 0.139 | 0.230 | 0.294 | 151 | 0.5 |
135
+ | disapproval | 0.950 | 0.494 | 0.292 | 0.367 | 0.356 | 267 | 0.5 |
136
+ | disgust | 0.980 | 0.674 | 0.252 | 0.367 | 0.405 | 123 | 0.5 |
137
+ | embarrassment | 0.995 | 0.857 | 0.324 | 0.471 | 0.526 | 37 | 0.5 |
138
+ | excitement | 0.984 | 0.692 | 0.262 | 0.380 | 0.420 | 103 | 0.5 |
139
+ | fear | 0.992 | 0.796 | 0.551 | 0.652 | 0.659 | 78 | 0.5 |
140
+ | gratitude | 0.990 | 0.957 | 0.892 | 0.924 | 0.919 | 352 | 0.5 |
141
+ | grief | 0.999 | 0.000 | 0.000 | 0.000 | 0.000 | 6 | 0.5 |
142
+ | joy | 0.978 | 0.652 | 0.571 | 0.609 | 0.600 | 161 | 0.5 |
143
+ | love | 0.982 | 0.792 | 0.798 | 0.795 | 0.786 | 238 | 0.5 |
144
+ | nervousness | 0.996 | 0.636 | 0.304 | 0.412 | 0.439 | 23 | 0.5 |
145
+ | optimism | 0.975 | 0.743 | 0.403 | 0.523 | 0.536 | 186 | 0.5 |
146
+ | pride | 0.998 | 0.857 | 0.375 | 0.522 | 0.566 | 16 | 0.5 |
147
+ | realization | 0.973 | 0.514 | 0.124 | 0.200 | 0.244 | 145 | 0.5 |
148
+ | relief | 0.998 | 1.000 | 0.091 | 0.167 | 0.301 | 11 | 0.5 |
149
+ | remorse | 0.992 | 0.594 | 0.732 | 0.656 | 0.656 | 56 | 0.5 |
150
+ | sadness | 0.979 | 0.759 | 0.385 | 0.511 | 0.532 | 156 | 0.5 |
151
+ | surprise | 0.978 | 0.649 | 0.340 | 0.447 | 0.460 | 141 | 0.5 |
152
+ | neutral | 0.794 | 0.715 | 0.623 | 0.666 | 0.520 | 1787 | 0.5 |
153
+
154
+ **Optimal Results**:
155
+
156
+ Using the best threshold for each label based on the training set (tuned on F1).
157
+
158
+ *Macro Averages (test)*
159
+ - Accuracy: `0.967`
160
+ - Precision: `0.568`
161
+ - Recall: `0.531`
162
+ - F1: `0.541`
163
+ - MCC: `0.526`
164
+
165
+ *Per-Label Results (test)*
166
+
167
+ | Label | Accuracy | Precision | Recall | F1 | MCC | Support | Threshold |
168
+ |----------------|----------|-----------|--------|-------|-------|---------|-----------|
169
+ | admiration | 0.946 | 0.700 | 0.726 | 0.713 | 0.683 | 504 | 0.30 |
170
+ | amusement | 0.981 | 0.782 | 0.856 | 0.817 | 0.808 | 264 | 0.40 |
171
+ | anger | 0.963 | 0.490 | 0.510 | 0.500 | 0.481 | 198 | 0.20 |
172
+ | annoyance | 0.917 | 0.337 | 0.425 | 0.376 | 0.334 | 320 | 0.25 |
173
+ | approval | 0.922 | 0.411 | 0.473 | 0.440 | 0.399 | 351 | 0.25 |
174
+ | caring | 0.971 | 0.424 | 0.415 | 0.419 | 0.405 | 135 | 0.25 |
175
+ | confusion | 0.970 | 0.468 | 0.484 | 0.476 | 0.460 | 153 | 0.30 |
176
+ | curiosity | 0.947 | 0.493 | 0.630 | 0.553 | 0.530 | 284 | 0.35 |
177
+ | desire | 0.988 | 0.708 | 0.410 | 0.519 | 0.533 | 83 | 0.45 |
178
+ | disappointment | 0.963 | 0.321 | 0.291 | 0.306 | 0.287 | 151 | 0.25 |
179
+ | disapproval | 0.943 | 0.429 | 0.464 | 0.446 | 0.417 | 267 | 0.30 |
180
+ | disgust | 0.981 | 0.604 | 0.496 | 0.545 | 0.538 | 123 | 0.20 |
181
+ | embarrassment | 0.995 | 0.789 | 0.405 | 0.536 | 0.564 | 37 | 0.30 |
182
+ | excitement | 0.979 | 0.444 | 0.388 | 0.415 | 0.405 | 103 | 0.25 |
183
+ | fear | 0.991 | 0.693 | 0.667 | 0.680 | 0.675 | 78 | 0.30 |
184
+ | gratitude | 0.990 | 0.951 | 0.886 | 0.918 | 0.913 | 352 | 0.50 |
185
+ | grief | 0.999 | 0.500 | 0.500 | 0.500 | 0.499 | 6 | 0.20 |
186
+ | joy | 0.978 | 0.628 | 0.609 | 0.618 | 0.607 | 161 | 0.40 |
187
+ | love | 0.982 | 0.789 | 0.819 | 0.804 | 0.795 | 238 | 0.45 |
188
+ | nervousness | 0.995 | 0.375 | 0.391 | 0.383 | 0.380 | 23 | 0.25 |
189
+ | optimism | 0.970 | 0.558 | 0.597 | 0.577 | 0.561 | 186 | 0.15 |
190
+ | pride | 0.998 | 0.750 | 0.375 | 0.500 | 0.529 | 16 | 0.15 |
191
+ | realization | 0.968 | 0.326 | 0.200 | 0.248 | 0.240 | 145 | 0.25 |
192
+ | relief | 0.998 | 0.429 | 0.273 | 0.333 | 0.341 | 11 | 0.25 |
193
+ | remorse | 0.993 | 0.611 | 0.786 | 0.688 | 0.689 | 56 | 0.55 |
194
+ | sadness | 0.979 | 0.667 | 0.538 | 0.596 | 0.589 | 156 | 0.20 |
195
+ | surprise | 0.978 | 0.585 | 0.511 | 0.545 | 0.535 | 141 | 0.30 |
196
+ | neutral | 0.782 | 0.649 | 0.737 | 0.690 | 0.526 | 1787 | 0.40 |
197
 
 
198
 
199
+ ---
200
 
201
+ ### Intended Use
202
 
203
+ The model is designed for emotion classification in English-language text, particularly in domains such as:
204
 
205
+ - Social media sentiment analysis
206
+ - Customer feedback evaluation
207
+ - Behavioral or psychological research
208
 
209
+ ---
210
 
211
+ ### Limitations and Biases
212
 
213
+ - **Data Bias**: The dataset is based on Reddit comments, which may not generalize well to other domains or cultural contexts.
214
+ - **Underrepresented Classes**: Certain labels like "grief" and "relief" have very few examples, leading to lower performance for those classes.
215
+ - **Ambiguity**: Some training data contain annotation inconsistencies or ambiguities that may impact predictions.
216
 
217
+ ---
218
 
219
+ ---
220
 
221
+ ### Environmental Impact
222
 
223
+ - **Hardware Used**: NVIDIA RTX4090
224
+ - **Training Time**: <1 hour
225
+ - **Carbon Emissions**: ~0.04 kg CO2 (calculated via [ML CO2 Impact Calculator](https://mlco2.github.io/impact)).
226
 
227
+ ---
228
 
229
+ ### Citation
230
 
231
+ If you use this model, please cite it as follows:
232
 
233
+ ```bibtex
234
+ @inproceedings{YourCitation,
235
+ title = {Emotion Classification with ModernBERT},
236
+ author = {Enric Junqu\'e de Fortuny},
237
+ year = {2025},
238
+ howpublished = {\url{https://huggingface.co/cirimus/modernbert-base-go-emotions}},
239
+ }