fyaronskiy commited on
Commit
8fa3114
·
verified ·
1 Parent(s): 3df7273

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +122 -194
README.md CHANGED
@@ -1,199 +1,127 @@
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
  library_name: transformers
3
+ license: mit
4
+ datasets:
5
+ - seara/ru_go_emotions
6
+ language:
7
+ - ru
8
+ metrics:
9
+ - f1
10
  ---
11
 
 
12
 
13
+ This is [ruRoberta-large](https://huggingface.co/ai-forever/ruRoberta-large) model finetuned on [ru_go_emotions](https://huggingface.co/datasets/seara/ru_go_emotions)
14
+ dataset for multilabel classification. Model can be used to extract all emotions from text or detect certain emotions.
15
+
16
+ # Usage
17
+ Using model with Huggingface Transformers:
18
+ ```python
19
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
20
+ tokenizer = AutoTokenizer.from_pretrained("fyaronskiy/ruRoberta-large-ru-go-emotions")
21
+ model = AutoModelForSequenceClassification.from_pretrained("fyaronskiy/ruRoberta-large-ru-go-emotions")
22
+
23
+ best_thresholds = [0.36734693877551017, 0.2857142857142857, 0.2857142857142857, 0.16326530612244897, 0.14285714285714285, 0.14285714285714285, 0.18367346938775508, 0.3469387755102041, 0.32653061224489793, 0.22448979591836732, 0.2040816326530612, 0.2857142857142857, 0.18367346938775508, 0.2857142857142857, 0.24489795918367346, 0.7142857142857142, 0.02040816326530612, 0.3061224489795918, 0.44897959183673464, 0.061224489795918366, 0.18367346938775508, 0.04081632653061224, 0.08163265306122448, 0.1020408163265306, 0.22448979591836732, 0.3877551020408163, 0.3469387755102041, 0.24489795918367346]
24
+ LABELS = ['admiration', 'amusement', 'anger', 'annoyance', 'approval', 'caring', 'confusion', 'curiosity', 'desire', 'disappointment', 'disapproval', 'disgust', 'embarrassment', 'excitement', 'fear', 'gratitude', 'grief', 'joy', 'love', 'nervousness', 'optimism', 'pride', 'realization', 'relief', 'remorse', 'sadness', 'surprise', 'neutral']
25
+ ID2LABEL = dict(enumerate(LABELS))
26
+ ```
27
+
28
+ Here is how you can extract emotions contained in text:
29
+
30
+ ```python
31
+ def predict_emotions(text):
32
+ inputs = tokenizer(text, truncation=True, add_special_tokens=True, max_length=128, return_tensors='pt')
33
+ with torch.no_grad():
34
+ logits = model(**inputs).logits
35
+ probas = torch.sigmoid(logits).squeeze(dim=0)
36
+ probas = probas.cpu().numpy()
37
+
38
+ class_binary_labels = (probas > np.array(best_thresholds)).astype(int)
39
+ return [ID2LABEL[label_id] for label_id, value in enumerate(class_binary_labels) if value == 1]
40
+
41
+ print(predict_emotions('У вас отличный сервис и лучший кофе в городе, обожаю вашу кофейню!'))
42
+ #['admiration', 'love']
43
+ ```
44
+
45
+ This is the way to get all emotions and their scores:
46
+
47
+ ```python
48
+ def predict(text):
49
+ inputs = tokenizer(text, truncation=True, add_special_tokens=True, max_length=128, return_tensors='pt')
50
+ with torch.no_grad():
51
+ logits = model(**inputs).logits
52
+ probas = torch.sigmoid(logits).squeeze(dim=0).tolist()
53
+ probas = [round(proba, 3) for proba in probas]
54
+
55
+ labels2probas = dict(zip(LABELS, probas))
56
+ probas_dict_sorted = dict(sorted(labels2probas.items(), key=lambda x: x[1], reverse=True))
57
+ return probas_dict_sorted
58
+
59
+ print(predict('У вас отличный сервис и лучший кофе в городе, обожаю вашу кофейню!'))
60
+ '''{'admiration': 0.81,
61
+ 'love': 0.538,
62
+ 'joy': 0.041,
63
+ 'gratitude': 0.031,
64
+ 'approval': 0.026,
65
+ 'excitement': 0.023,
66
+ 'neutral': 0.009,
67
+ 'curiosity': 0.006,
68
+ 'amusement': 0.005,
69
+ 'desire': 0.005,
70
+ 'realization': 0.005,
71
+ 'caring': 0.004,
72
+ 'confusion': 0.004,
73
+ 'surprise': 0.004,
74
+ 'disappointment': 0.003,
75
+ 'disapproval': 0.003,
76
+ 'anger': 0.002,
77
+ 'annoyance': 0.002,
78
+ 'disgust': 0.002,
79
+ 'fear': 0.002,
80
+ 'grief': 0.002,
81
+ 'optimism': 0.002,
82
+ 'pride': 0.002,
83
+ 'relief': 0.002,
84
+ 'sadness': 0.002,
85
+ 'embarrassment': 0.001,
86
+ 'nervousness': 0.001,
87
+ 'remorse': 0.001}
88
+ '''
89
+ ```
90
+
91
+ # Eval results on test split of ru-go-emotions
92
+
93
+ precision recall f1-score support threshold
94
+
95
+ admiration 0.63 0.75 0.69 504 0.37
96
+ amusement 0.76 0.91 0.83 264 0.29
97
+ anger 0.47 0.32 0.38 198 0.29
98
+ annoyance 0.33 0.39 0.36 320 0.16
99
+ approval 0.27 0.58 0.37 351 0.14
100
+ caring 0.32 0.59 0.41 135 0.14
101
+ confusion 0.41 0.52 0.46 153 0.18
102
+ curiosity 0.45 0.73 0.55 284 0.35
103
+ desire 0.54 0.31 0.40 83 0.33
104
+ disappointment 0.31 0.34 0.33 151 0.22
105
+ disapproval 0.31 0.57 0.40 267 0.20
106
+ disgust 0.44 0.40 0.42 123 0.29
107
+ embarrassment 0.48 0.38 0.42 37 0.18
108
+ excitement 0.29 0.43 0.34 103 0.29
109
+ fear 0.56 0.78 0.65 78 0.24
110
+ gratitude 0.95 0.85 0.89 352 0.71
111
+ grief 0.03 0.33 0.05 6 0.02
112
+ joy 0.48 0.58 0.53 161 0.31
113
+ love 0.73 0.84 0.78 238 0.45
114
+ nervousness 0.24 0.48 0.32 23 0.06
115
+ optimism 0.57 0.54 0.56 186 0.18
116
+ pride 0.67 0.38 0.48 16 0.04
117
+ realization 0.18 0.31 0.23 145 0.08
118
+ relief 0.30 0.27 0.29 11 0.10
119
+ remorse 0.53 0.84 0.65 56 0.22
120
+ sadness 0.56 0.53 0.55 156 0.39
121
+ surprise 0.55 0.57 0.56 141 0.35
122
+ neutral 0.59 0.79 0.68 1787 0.24
123
+
124
+ micro avg 0.50 0.66 0.57 6329
125
+ macro avg 0.46 0.55 0.48 6329
126
+ weighted avg 0.53 0.66 0.58 6329
127
+ samples avg 0.55 0.68 0.59 6329