Upload folder using huggingface_hub
Browse files- README.md +183 -3
- config.json +41 -0
- model.safetensors +3 -0
- special_tokens_map.json +37 -0
- tokenizer.json +0 -0
- tokenizer_config.json +65 -0
- vocab.txt +0 -0
README.md
CHANGED
@@ -1,3 +1,183 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# rubert_tiny2_russian_emotion_sentiment
|
2 |
+
|
3 |
+
## Описание
|
4 |
+
|
5 |
+
Модель `rubert_tiny2_russian_emotion_sentiment` — это дообученная версия легковесной модели [`cointegrated/rubert-tiny2`](https://huggingface.co/cointegrated/rubert-tiny2) для классификации пяти эмоций в русскоязычных сообщениях:
|
6 |
+
|
7 |
+
- **0**: aggression (агрессия)
|
8 |
+
- **1**: anxiety (тревожность)
|
9 |
+
- **2**: neutral (нейтральное состояние)
|
10 |
+
- **3**: positive (позитив)
|
11 |
+
- **4**: sarcasm (сарказм)
|
12 |
+
|
13 |
+
|
14 |
+
### Результаты на валидации
|
15 |
+
|
16 |
+
| Метрика | Значение |
|
17 |
+
|------------|----------|
|
18 |
+
| Accuracy | 0.8911 |
|
19 |
+
| F1 macro | 0.8910 |
|
20 |
+
| F1 micro | 0.8911 |
|
21 |
+
|
22 |
+
**Точность по классам**:
|
23 |
+
|
24 |
+
- агрессия (0): 0.9120
|
25 |
+
- тревожность (1): 0.9462
|
26 |
+
- нейтральное (2): 0.8663
|
27 |
+
- позитив (3): 0.8884
|
28 |
+
- сарказм (4): 0.8426
|
29 |
+
|
30 |
+
### Использование
|
31 |
+
|
32 |
+
```bash
|
33 |
+
pip install transformers torch
|
34 |
+
```
|
35 |
+
|
36 |
+
```python
|
37 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
38 |
+
import torch
|
39 |
+
|
40 |
+
# Загружаем модель и токенизатор
|
41 |
+
MODEL_ID = "Kostya165/rubert_tiny2_russian_emotion_sentiment"
|
42 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
43 |
+
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
|
44 |
+
model.eval()
|
45 |
+
|
46 |
+
texts = [
|
47 |
+
"Сегодня отличный день!",
|
48 |
+
"Меня это всё бесит и раздражает."
|
49 |
+
]
|
50 |
+
|
51 |
+
# Токенизация
|
52 |
+
enc = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
|
53 |
+
with torch.no_grad():
|
54 |
+
logits = model(**enc).logits
|
55 |
+
preds = logits.argmax(dim=-1).tolist()
|
56 |
+
|
57 |
+
# Преобразуем ID обратно в метки
|
58 |
+
id2label = model.config.id2label
|
59 |
+
labels = [id2label[p] for p in preds]
|
60 |
+
print(labels) # например: ['positive', 'aggression']
|
61 |
+
```
|
62 |
+
|
63 |
+
### Как было обучено
|
64 |
+
|
65 |
+
- **База**: `cointegrated/rubert-tiny2`
|
66 |
+
- **Датасет**: `Kostya165/ru_emotion_dvach`
|
67 |
+
- **Эпохи**: 2
|
68 |
+
- **Batch size**: 32
|
69 |
+
- **LR**: 1e-5
|
70 |
+
- **Mixed precision**: FP16
|
71 |
+
- **Регуляризация**: Dropout 0.1, weight_decay 0.01, warmup_ratio 0.1
|
72 |
+
|
73 |
+
### Зависимости
|
74 |
+
|
75 |
+
- `transformers>=4.30.0`
|
76 |
+
- `torch>=1.10.0`
|
77 |
+
- `datasets`
|
78 |
+
- `evaluate`
|
79 |
+
|
80 |
+
### Лицензия
|
81 |
+
|
82 |
+
CC-BY-SA 4.0.
|
83 |
+
|
84 |
+
### Цитирование
|
85 |
+
|
86 |
+
```bibtex
|
87 |
+
@article{rubert_tiny2_russian_emotion_sentiment,
|
88 |
+
title = {Russian Emotion Sentiment Classification with RuBERT-tiny2},
|
89 |
+
author = {Kostya165},
|
90 |
+
year = {2024},
|
91 |
+
howpublished = {\url{https://huggingface.co/Kostya165/rubert_tiny2_russian_emotion_sentiment}}
|
92 |
+
}
|
93 |
+
```
|
94 |
+
|
95 |
+
---
|
96 |
+
|
97 |
+
## English
|
98 |
+
|
99 |
+
# rubert_tiny2_russian_emotion_sentiment
|
100 |
+
|
101 |
+
**Description**
|
102 |
+
|
103 |
+
The `rubert_tiny2_russian_emotion_sentiment` model is a fine‑tuned version of the lightweight [`cointegrated/rubert-tiny2`](https://huggingface.co/cointegrated/rubert-tiny2) for classifying five emotions in Russian text:
|
104 |
+
|
105 |
+
- **0**: aggression
|
106 |
+
- **1**: anxiety
|
107 |
+
- **2**: neutral
|
108 |
+
- **3**: positive
|
109 |
+
- **4**: sarcasm
|
110 |
+
|
111 |
+
|
112 |
+
**Validation Results**
|
113 |
+
|
114 |
+
| Metric | Value |
|
115 |
+
|------------|--------|
|
116 |
+
| Accuracy | 0.8911 |
|
117 |
+
| F1 macro | 0.8910 |
|
118 |
+
| F1 micro | 0.8911 |
|
119 |
+
|
120 |
+
**Per‑class accuracy**:
|
121 |
+
|
122 |
+
- aggression: 0.9120
|
123 |
+
- anxiety: 0.9462
|
124 |
+
- neutral: 0.8663
|
125 |
+
- positive: 0.8884
|
126 |
+
- sarcasm: 0.8426
|
127 |
+
|
128 |
+
**Usage**
|
129 |
+
|
130 |
+
```bash
|
131 |
+
pip install transformers torch
|
132 |
+
```
|
133 |
+
|
134 |
+
```python
|
135 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
136 |
+
import torch
|
137 |
+
|
138 |
+
MODEL_ID = "Kostya165/rubert_tiny2_russian_emotion_sentiment"
|
139 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
|
140 |
+
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
|
141 |
+
model.eval()
|
142 |
+
|
143 |
+
texts = ["Сегодня отличный день!", "Меня это всё бесит и раздражает."]
|
144 |
+
enc = tokenizer(texts, padding=True, truncation=True, max_length=128, return_tensors="pt")
|
145 |
+
with torch.no_grad():
|
146 |
+
logits = model(**enc).logits
|
147 |
+
preds = logits.argmax(dim=-1).tolist()
|
148 |
+
|
149 |
+
labels = [model.config.id2label[p] for p in preds]
|
150 |
+
print(labels) # e.g. ['positive', 'aggression']
|
151 |
+
```
|
152 |
+
|
153 |
+
**Training Details**
|
154 |
+
|
155 |
+
- Base: `cointegrated/rubert-tiny2`
|
156 |
+
- Dataset: `Kostya165/ru_emotion_dvach` (train/validation)
|
157 |
+
- Epochs: 2
|
158 |
+
- Batch size: 32
|
159 |
+
- Learning rate: 1e‑5
|
160 |
+
- Mixed precision: FP16
|
161 |
+
- Regularization: Dropout 0.1, weight_decay 0.01, warmup_ratio 0.1
|
162 |
+
|
163 |
+
**Requirements**
|
164 |
+
|
165 |
+
- `transformers>=4.30.0`
|
166 |
+
- `torch>=1.10.0`
|
167 |
+
- `datasets`
|
168 |
+
- `evaluate`
|
169 |
+
|
170 |
+
**License**
|
171 |
+
|
172 |
+
CC-BY-SA 4.0.
|
173 |
+
|
174 |
+
**Citation**
|
175 |
+
|
176 |
+
```bibtex
|
177 |
+
@article{rubert_tiny2_russian_emotion_sentiment,
|
178 |
+
title = {Russian Emotion Sentiment Classification with RuBERT-tiny2},
|
179 |
+
author = {Kostya165},
|
180 |
+
year = {2024},
|
181 |
+
howpublished = {\url{https://huggingface.co/Kostya165/rubert_tiny2_russian_emotion_sentiment}}
|
182 |
+
}
|
183 |
+
```
|
config.json
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"BertForSequenceClassification"
|
4 |
+
],
|
5 |
+
"attention_probs_dropout_prob": 0.1,
|
6 |
+
"classifier_dropout": null,
|
7 |
+
"emb_size": 312,
|
8 |
+
"gradient_checkpointing": false,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 312,
|
12 |
+
"id2label": {
|
13 |
+
"0": "aggression",
|
14 |
+
"1": "anxiety",
|
15 |
+
"2": "neutral",
|
16 |
+
"3": "positive",
|
17 |
+
"4": "sarcasm"
|
18 |
+
},
|
19 |
+
"initializer_range": 0.02,
|
20 |
+
"intermediate_size": 600,
|
21 |
+
"label2id": {
|
22 |
+
"aggression": 0,
|
23 |
+
"anxiety": 1,
|
24 |
+
"neutral": 2,
|
25 |
+
"positive": 3,
|
26 |
+
"sarcasm": 4
|
27 |
+
},
|
28 |
+
"layer_norm_eps": 1e-12,
|
29 |
+
"max_position_embeddings": 2048,
|
30 |
+
"model_type": "bert",
|
31 |
+
"num_attention_heads": 12,
|
32 |
+
"num_hidden_layers": 3,
|
33 |
+
"pad_token_id": 0,
|
34 |
+
"position_embedding_type": "absolute",
|
35 |
+
"problem_type": "single_label_classification",
|
36 |
+
"torch_dtype": "float32",
|
37 |
+
"transformers_version": "4.50.0.dev0",
|
38 |
+
"type_vocab_size": 2,
|
39 |
+
"use_cache": true,
|
40 |
+
"vocab_size": 83828
|
41 |
+
}
|
model.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b2e45121e908f3bf6885bdcf73dd0777749d35cf499154cc6740423347343030
|
3 |
+
size 116787892
|
special_tokens_map.json
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cls_token": {
|
3 |
+
"content": "[CLS]",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"mask_token": {
|
10 |
+
"content": "[MASK]",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": {
|
17 |
+
"content": "[PAD]",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"sep_token": {
|
24 |
+
"content": "[SEP]",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"unk_token": {
|
31 |
+
"content": "[UNK]",
|
32 |
+
"lstrip": false,
|
33 |
+
"normalized": false,
|
34 |
+
"rstrip": false,
|
35 |
+
"single_word": false
|
36 |
+
}
|
37 |
+
}
|
tokenizer.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
tokenizer_config.json
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"added_tokens_decoder": {
|
3 |
+
"0": {
|
4 |
+
"content": "[PAD]",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false,
|
9 |
+
"special": true
|
10 |
+
},
|
11 |
+
"1": {
|
12 |
+
"content": "[UNK]",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false,
|
17 |
+
"special": true
|
18 |
+
},
|
19 |
+
"2": {
|
20 |
+
"content": "[CLS]",
|
21 |
+
"lstrip": false,
|
22 |
+
"normalized": false,
|
23 |
+
"rstrip": false,
|
24 |
+
"single_word": false,
|
25 |
+
"special": true
|
26 |
+
},
|
27 |
+
"3": {
|
28 |
+
"content": "[SEP]",
|
29 |
+
"lstrip": false,
|
30 |
+
"normalized": false,
|
31 |
+
"rstrip": false,
|
32 |
+
"single_word": false,
|
33 |
+
"special": true
|
34 |
+
},
|
35 |
+
"4": {
|
36 |
+
"content": "[MASK]",
|
37 |
+
"lstrip": false,
|
38 |
+
"normalized": false,
|
39 |
+
"rstrip": false,
|
40 |
+
"single_word": false,
|
41 |
+
"special": true
|
42 |
+
}
|
43 |
+
},
|
44 |
+
"clean_up_tokenization_spaces": false,
|
45 |
+
"cls_token": "[CLS]",
|
46 |
+
"do_basic_tokenize": true,
|
47 |
+
"do_lower_case": false,
|
48 |
+
"extra_special_tokens": {},
|
49 |
+
"mask_token": "[MASK]",
|
50 |
+
"max_length": 512,
|
51 |
+
"model_max_length": 2048,
|
52 |
+
"never_split": null,
|
53 |
+
"pad_to_multiple_of": null,
|
54 |
+
"pad_token": "[PAD]",
|
55 |
+
"pad_token_type_id": 0,
|
56 |
+
"padding_side": "right",
|
57 |
+
"sep_token": "[SEP]",
|
58 |
+
"stride": 0,
|
59 |
+
"strip_accents": null,
|
60 |
+
"tokenize_chinese_chars": true,
|
61 |
+
"tokenizer_class": "BertTokenizer",
|
62 |
+
"truncation_side": "right",
|
63 |
+
"truncation_strategy": "longest_first",
|
64 |
+
"unk_token": "[UNK]"
|
65 |
+
}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|