blanchefort
commited on
Commit
•
ac1072f
1
Parent(s):
190f682
Initial commit
Browse files- README.md +43 -0
- config.json +29 -0
- pytorch_model.bin +3 -0
- special_tokens_map.json +1 -0
- tf_model.h5 +3 -0
- tokenizer_config.json +1 -0
- vocab.txt +0 -0
README.md
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- ru
|
4 |
+
tags:
|
5 |
+
- sentiment
|
6 |
+
- text-classification
|
7 |
+
datasets:
|
8 |
+
- RuTweetCorp
|
9 |
+
---
|
10 |
+
|
11 |
+
# RuBERT for Sentiment Analysis of Tweets
|
12 |
+
|
13 |
+
This is a [DeepPavlov/rubert-base-cased-conversational](https://huggingface.co/DeepPavlov/rubert-base-cased-conversational) model trained on [RuTweetCorp](https://study.mokoron.com/).
|
14 |
+
|
15 |
+
## Labels
|
16 |
+
0: POSITIVE
|
17 |
+
1: NEGATIVE
|
18 |
+
|
19 |
+
## How to use
|
20 |
+
```python
|
21 |
+
|
22 |
+
import torch
|
23 |
+
from transformers import AutoModelForSequenceClassification
|
24 |
+
from transformers import BertTokenizerFast
|
25 |
+
|
26 |
+
tokenizer = BertTokenizerFast.from_pretrained('blanchefort/rubert-base-cased-sentiment-mokoron')
|
27 |
+
model = AutoModelForSequenceClassification.from_pretrained('blanchefort/rubert-base-cased-sentiment-mokoron', return_dict=True)
|
28 |
+
|
29 |
+
@torch.no_grad()
|
30 |
+
def predict(text):
|
31 |
+
inputs = tokenizer(text, max_length=512, padding=True, truncation=True, return_tensors='pt')
|
32 |
+
outputs = model(**inputs)
|
33 |
+
predicted = torch.nn.functional.softmax(outputs.logits, dim=1)
|
34 |
+
predicted = torch.argmax(predicted, dim=1).numpy()
|
35 |
+
return predicted
|
36 |
+
```
|
37 |
+
|
38 |
+
|
39 |
+
## Dataset used for model training
|
40 |
+
|
41 |
+
**[RuTweetCorp](https://study.mokoron.com/)**
|
42 |
+
|
43 |
+
> Рубцова Ю. Автоматическое построение и анализ корпуса коротких текстов (постов микроблогов) для задачи разработки и тренировки тонового классификатора // Инженерия знаний и технологии семантического веба. – 2012. – Т. 1. – С. 109-116.
|
config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "../huggingface/rubert-base-cased-sentiment-mokoron",
|
3 |
+
"architectures": [
|
4 |
+
"BertForSequenceClassification"
|
5 |
+
],
|
6 |
+
"attention_probs_dropout_prob": 0.1,
|
7 |
+
"directionality": "bidi",
|
8 |
+
"gradient_checkpointing": false,
|
9 |
+
"hidden_act": "gelu",
|
10 |
+
"hidden_dropout_prob": 0.1,
|
11 |
+
"hidden_size": 768,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"intermediate_size": 3072,
|
14 |
+
"layer_norm_eps": 1e-12,
|
15 |
+
"max_position_embeddings": 512,
|
16 |
+
"model_type": "bert",
|
17 |
+
"num_attention_heads": 12,
|
18 |
+
"num_hidden_layers": 12,
|
19 |
+
"output_past": true,
|
20 |
+
"pad_token_id": 0,
|
21 |
+
"pooler_fc_size": 768,
|
22 |
+
"pooler_num_attention_heads": 12,
|
23 |
+
"pooler_num_fc_layers": 3,
|
24 |
+
"pooler_size_per_head": 128,
|
25 |
+
"pooler_type": "first_token_transform",
|
26 |
+
"return_dict": true,
|
27 |
+
"type_vocab_size": 2,
|
28 |
+
"vocab_size": 119547
|
29 |
+
}
|
pytorch_model.bin
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ec9b73777f37b73f85abc582c71c00b1a87dc6144863dc2e9d08c66c726246c4
|
3 |
+
size 711506441
|
special_tokens_map.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]"}
|
tf_model.h5
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:bedce8d72d14302cedc6912bcaa2ab7ec32f211cc50d5a514cf0d529061ffda8
|
3 |
+
size 711690600
|
tokenizer_config.json
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"do_lower_case": false, "unk_token": "[UNK]", "sep_token": "[SEP]", "pad_token": "[PAD]", "cls_token": "[CLS]", "mask_token": "[MASK]", "tokenize_chinese_chars": true, "strip_accents": null, "special_tokens_map_file": "/home/igor/.cache/torch/transformers/1f428acdde727eed5de979d6856ce350a470be2a64e134a1fdae04af78a27301.dd8bd9bfd3664b530ea4e645105f557769387b3da9f79bdb55ed556bdd80611d", "name_or_path": "blanchefort/rubert-base-cased-sentiment", "do_basic_tokenize": true, "never_split": null}
|
vocab.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|