sergeyzh commited on
Commit
8d2b14c
·
verified ·
1 Parent(s): c8fa01e

Upload 7 files

Browse files
README.md CHANGED
@@ -1,3 +1,90 @@
1
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: mit
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - ru
4
+
5
+ pipeline_tag: text-classification
6
+
7
+ tags:
8
+ - russian
9
+ - sentiment-analysis
10
+ - multi-class-classification
11
+ - rubert
12
+ - tiny
13
+ - transformers
14
+
15
  license: mit
16
+
17
+ base_model: sergeyzh/rubert-tiny-sts-v2
18
+
19
+ library_name: transformers
20
+
21
  ---
22
+
23
+ Компактная модель BERT-tiny для классификации сентимента русских отзывов: 3 класса — Negative (0), Neutral (1), Positive (2).
24
+
25
+ Получена на базе [sergeyzh/rubert-tiny-sts-v2](https://huggingface.co/sergeyzh/rubert-tiny-sts-v2) дистилляцией мягких меток (soft labels) от учителя [sergeyzh/rubert-large-uncased-sentiment](https://huggingface.co/sergeyzh/rubert-large-uncased-sentiment).
26
+
27
+ Основные характеристики модели:
28
+ - размер hidden — 312,
29
+ - длина контекста — 512,
30
+ - слоёв — 3,
31
+ - параметров — ~29M (вес ~111 МБ).
32
+
33
+ Классы: `0` — Negative, `1` — Neutral, `2` — Positive.
34
+
35
+
36
+ ## Использование
37
+
38
+ Самый простой способ — `pipeline`:
39
+
40
+ ```Python
41
+ from transformers import pipeline
42
+
43
+ model = pipeline("text-classification", model="sergeyzh/rubert-tiny-sentiment")
44
+ model("Просто шедевр. Каждая минута на вес золота, ни секунды скуки. Музыка, игра актёров, режиссура — всё на высочайшем уровне.", truncation=True, max_length=512)
45
+ # [{'label': 'Positive', 'score': 0.9313}]
46
+ ```
47
+
48
+ Если нужны вероятности всех классов, используйте `transformers` напрямую:
49
+
50
+ ```Python
51
+ import torch
52
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
53
+
54
+ checkpoint = "sergeyzh/rubert-tiny-sentiment"
55
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
56
+ model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
57
+
58
+ text = "Просто шедевр. Каждая минута на вес золота, ни секунды скуки. Музыка, игра актёров, режиссура — всё на высочайшем уровне."
59
+ inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
60
+ with torch.no_grad():
61
+ logits = model(**inputs).logits
62
+ proba = torch.softmax(logits, dim=1)
63
+ label = model.config.id2label[proba.argmax().item()]
64
+ print(label, proba.tolist())
65
+ # Positive [[0.0109, 0.0577, 0.9313]]
66
+ ```
67
+
68
+
69
+ ## Обучение
70
+
71
+ - Базовая модель: [sergeyzh/rubert-tiny-sts-v2](https://huggingface.co/sergeyzh/rubert-tiny-sts-v2)
72
+ - Метод: дистилляция мягких меток (soft-label distillation) от учителя [sergeyzh/rubert-large-uncased-sentiment](https://huggingface.co/sergeyzh/rubert-large-uncased-sentiment), α = 0.5
73
+ - Данные: 105500 русских отзывов (94950 train / 10550 val) — датасеты Kinopoisk, RuReviews, Georeview
74
+ - 3 эпохи, batch_size = 32 (grad_accum = 2), lr = 5e-5, warmup = 0.1, weight_decay = 0.01, max_length = 256
75
+ - Отбор по валидационной F1 (лучшая эпоха 2, val F1 = 0.7552)
76
+
77
+
78
+ ## Метрики
79
+
80
+ Тестовые наборы: Kinopoisk (1500), RuReviews (15000), Georeview (5000, 5-звёздный рейтинг сведён к 3 классам: 1–2 звезды — Negative, 3 — Neutral, 4–5 — Positive). Оценка: argmax по логитам, max_length = 512.
81
+
82
+ | Модель | Kinopoisk Acc/F1 | RuReviews Acc/F1 | Georeview Acc/F1 | Avg F1 |
83
+ | :--- | :--- | :---: | :---: | :---: |
84
+ | [sergeyzh/rubert-large-uncased-sentiment](https://huggingface.co/sergeyzh/rubert-large-uncased-sentiment) | **0.7013** / **0.6929** | 0.7851 / 0.7866 | **0.7858** / **0.7361** | **0.7385** |
85
+ | **sergeyzh/rubert-tiny-sentiment** | 0.6593 / 0.6519 | 0.7672 / 0.7690 | 0.7680 / 0.7130 | 0.7113 |
86
+ | [seara/rubert-base-cased-russian-sentiment](https://huggingface.co/seara/rubert-base-cased-russian-sentiment) | 0.5653 / 0.5679 | **0.8163** / **0.8183** | 0.6566 / 0.6434 | 0.6765 |
87
+ | [seara/rubert-tiny2-russian-sentiment](https://huggingface.co/seara/rubert-tiny2-russian-sentiment) | 0.4980 / 0.5032 | 0.7877 / 0.7899 | 0.6218 / 0.6122 | 0.6351 |
88
+ | [blanchefort/rubert-base-cased-sentiment](https://huggingface.co/blanchefort/rubert-base-cased-sentiment) | 0.5253 / 0.5209 | 0.7615 / 0.7549 | 0.6716 / 0.6047 | 0.6268 |
89
+ | [blanchefort/rubert-base-cased-sentiment-rusentiment](https://huggingface.co/blanchefort/rubert-base-cased-sentiment-rusentiment) | 0.5413 / 0.5470 | 0.6230 / 0.6327 | 0.6022 / 0.5760 | 0.5852 |
90
+ | [cointegrated/rubert-tiny-sentiment-balanced](https://huggingface.co/cointegrated/rubert-tiny-sentiment-balanced) | 0.4293 / 0.3977 | 0.7330 / 0.7344 | 0.6158 / 0.5857 | 0.5726 |
config.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "sergeyzh/rubert-tiny-sentiment",
3
+ "architectures": [
4
+ "BertForSequenceClassification"
5
+ ],
6
+ "attention_probs_dropout_prob": 0.1,
7
+ "classifier_dropout": null,
8
+ "dtype": "float32",
9
+ "emb_size": 312,
10
+ "gradient_checkpointing": false,
11
+ "hidden_act": "gelu",
12
+ "hidden_dropout_prob": 0.1,
13
+ "hidden_size": 312,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 600,
16
+ "layer_norm_eps": 1e-12,
17
+ "max_position_embeddings": 2048,
18
+ "model_type": "bert",
19
+ "num_attention_heads": 12,
20
+ "num_hidden_layers": 3,
21
+ "pad_token_id": 0,
22
+ "position_embedding_type": "absolute",
23
+ "transformers_version": "4.57.6",
24
+ "type_vocab_size": 2,
25
+ "use_cache": true,
26
+ "vocab_size": 83828,
27
+ "num_labels": 3,
28
+ "id2label": {
29
+ "0": "Negative",
30
+ "1": "Neutral",
31
+ "2": "Positive"
32
+ },
33
+ "label2id": {
34
+ "Negative": 0,
35
+ "Neutral": 1,
36
+ "Positive": 2
37
+ }
38
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98be194838d149e8ecd5cab86266ae1f89151cde7fed26a66c4ef19d146b3c73
3
+ size 116785356
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": true,
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