Upload 7 files
Browse filesUpdate Model & Readme
- README.md +44 -56
- config.json +1 -1
- pytorch_model.bin +2 -2
README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2 |
license: mit
|
3 |
language:
|
4 |
- ru
|
|
|
5 |
tags:
|
6 |
- russian
|
7 |
- classification
|
@@ -10,76 +11,63 @@ tags:
|
|
10 |
- emotion-recognition
|
11 |
- multiclass
|
12 |
widget:
|
13 |
-
- text: Как дела?
|
14 |
-
- text: Дурак твой дед
|
15 |
-
- text: Только попробуй!!!
|
16 |
-
- text: Не хочу в школу(
|
17 |
- text: Сейчас ровно час дня
|
18 |
-
- text:
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
21 |
datasets:
|
22 |
-
- Djacon/
|
23 |
---
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
28 |
-
import torch
|
29 |
-
from transformers import BertForSequenceClassification, AutoTokenizer
|
30 |
|
31 |
-
|
32 |
-
tokenizer = AutoTokenizer.from_pretrained('Djacon/rubert-tiny2-russian-emotion-detection')
|
33 |
-
model = BertForSequenceClassification.from_pretrained('Djacon/rubert-tiny2-russian-emotion-detection')
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
pred = torch.nn.functional.sigmoid(outputs.logits)
|
44 |
-
pred = pred.argmax(dim=1)
|
45 |
-
|
46 |
-
return LABELS_RU[pred[0]]
|
47 |
-
|
48 |
-
|
49 |
-
# Probabilistic prediction of emotion in a text
|
50 |
-
@torch.no_grad()
|
51 |
-
def predict_emotions(text: str) -> dict:
|
52 |
-
inputs = tokenizer(text, truncation=True, return_tensors='pt')
|
53 |
-
inputs = inputs.to(model.device)
|
54 |
-
|
55 |
-
outputs = model(**inputs)
|
56 |
-
|
57 |
-
pred = torch.nn.functional.sigmoid(outputs.logits)
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
```
|
64 |
|
65 |
-
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
70 |
|
71 |
-
print(simple_prediction)
|
72 |
-
print(not_simple_prediction)
|
73 |
-
# радость
|
74 |
-
# {'нейтрально': 0.1985, 'радость': 0.7419, 'грусть': 0.0261, 'гнев': 0.0295, 'интерес': 0.1983, 'удивление': 0.4305, 'отвращение': 0.0082, 'страх': 0.008, 'вина': 0.0046, 'стыд': 0.0097}
|
75 |
-
```
|
76 |
|
77 |
-
|
78 |
```
|
79 |
@misc{Djacon,
|
80 |
-
author
|
81 |
-
year
|
82 |
-
publisher
|
83 |
-
journal
|
84 |
}
|
85 |
```
|
|
|
2 |
license: mit
|
3 |
language:
|
4 |
- ru
|
5 |
+
- en
|
6 |
tags:
|
7 |
- russian
|
8 |
- classification
|
|
|
11 |
- emotion-recognition
|
12 |
- multiclass
|
13 |
widget:
|
|
|
|
|
|
|
|
|
14 |
- text: Сейчас ровно час дня
|
15 |
+
- text: Сегодня такой замечательный день!
|
16 |
+
- text: Жалею, что вчера сходил на этот концерт
|
17 |
+
- text: Что за бред я только что посмотрел...
|
18 |
+
- text: Куда бы сегодня сходить?
|
19 |
+
- text: Воу, это было так неожиданно
|
20 |
+
- text: Фу, эта еда просто отвратительна!
|
21 |
+
- text: В темной комнате услышал тихий посторонний шорох
|
22 |
+
- text: Извини, я не хотел чтобы так все произошло
|
23 |
datasets:
|
24 |
+
- Djacon/ru-izard-emotions
|
25 |
---
|
26 |
|
27 |
+
## Short Description
|
28 |
|
29 |
+
The __rubert-tiny2-russian-emotion-detection__ is a fine-tuned [rubert-tiny2](https://huggingface.co/cointegrated/rubert-tiny2) model for multi-label __emotion classification__ task, specifically on Russian texts. Trained on custom [ru-izard-emotions](https://huggingface.co/datasets/Djacon/ru-izard-emotions) dataset, so this model can recognize a spectrum of 9 emotions, including __joy__, __sadness__, __anger__, __enthusiasm__, __surprise__, __disgust__, __fear__, __guilt__, __shame__ + __neutral__ (no emotion). Project was inspired by the [Izard's model](https://en.wikipedia.org/wiki/Differential_Emotions_Scale) of human emotions.
|
|
|
|
|
30 |
|
31 |
+
For more information about model, please check [Github repository](https://github.com/Djacon/russian-emotion-detection)
|
|
|
|
|
32 |
|
33 |
+
## Training Parameters:
|
34 |
+
```yaml
|
35 |
+
Optimizer: AdamW
|
36 |
+
Schedule: LambdaLR
|
37 |
+
Learning Rate: 1e-4
|
38 |
+
Batch Size: 64
|
39 |
+
Number Of Epochs: 10
|
40 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
+
## Emotion Categories:
|
43 |
+
```js
|
44 |
+
0. Neutral (Нейтрально)
|
45 |
+
1. Joy (Радость)
|
46 |
+
2. Sadness (Грусть)
|
47 |
+
3. Anger (Гнев)
|
48 |
+
4. Enthusiasm (Интерес)
|
49 |
+
5. Surprise (Удивление)
|
50 |
+
6. Disgust (Отвращение)
|
51 |
+
7. Fear (Страх)
|
52 |
+
8. Guilt (Вина)
|
53 |
+
9. Shame (Стыд)
|
54 |
```
|
55 |
|
56 |
+
## Test results:
|
57 |
|
58 |
+
||Neutral|Joy|Sadness|Anger|Enthusiasm|Surprise|Disgust|Fear|Guilt|Shame|Mean|
|
59 |
+
|-|-|-|-|-|-|-|-|-|-|-|-|
|
60 |
+
|AUC|0.7319|0.8234|0.8069|0.7884|0.8493|0.8047|0.8147|0.9034|0.8528|0.7145|0.8090|
|
61 |
+
|F1 micro|0.7192|0.7951|0.8204|0.7642|0.8630|0.9032|0.9156|0.9482|0.9526|0.9606|0.8642|
|
62 |
+
|F1 macro|0.6021|0.7237|0.6548|0.6274|0.7291|0.5712|0.4780|0.8158|0.4879|0.4900|0.6180|
|
63 |
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
+
## Citations
|
66 |
```
|
67 |
@misc{Djacon,
|
68 |
+
author={Djacon},
|
69 |
+
year={2023},
|
70 |
+
publisher={Hugging Face},
|
71 |
+
journal={Hugging Face Hub},
|
72 |
}
|
73 |
```
|
config.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
{
|
2 |
-
"_name_or_path": "
|
3 |
"architectures": [
|
4 |
"BertForSequenceClassification"
|
5 |
],
|
|
|
1 |
{
|
2 |
+
"_name_or_path": "cointegrated/rubert-tiny2",
|
3 |
"architectures": [
|
4 |
"BertForSequenceClassification"
|
5 |
],
|
pytorch_model.bin
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5d8f3bf465322538b595ebf8c62847602d32921655b608305c42f502fc76dfcb
|
3 |
+
size 116822239
|