这是一个在 RuSentiment 上训练的 DeepPavlov/rubert-base-cased-conversational 模型。
0: NEUTRAL 1: POSITIVE 2: NEGATIVE
import torch from transformers import AutoModelForSequenceClassification from transformers import BertTokenizerFast tokenizer = BertTokenizerFast.from_pretrained('blanchefort/rubert-base-cased-sentiment-rusentiment') model = AutoModelForSequenceClassification.from_pretrained('blanchefort/rubert-base-cased-sentiment-rusentiment', return_dict=True) @torch.no_grad() def predict(text): inputs = tokenizer(text, max_length=512, padding=True, truncation=True, return_tensors='pt') outputs = model(**inputs) predicted = torch.nn.functional.softmax(outputs.logits, dim=1) predicted = torch.argmax(predicted, dim=1).numpy() return predicted
A. Rogers A. Romanov A. Rumshisky S. Volkova M. Gronas A. Gribov RuSentiment:用于俄语社交媒体的增强情感分析数据集。COLING 2018会议论文。