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.
44