Views
No views yet
0 — Negative, 1 — Neutral, 2 — Positive.pipeline:1from transformers import pipeline
2
3model = pipeline("text-classification", model="sergeyzh/rubert-large-uncased-sentiment")
4model("Просто шедевр. Каждая минута на вес золота, ни секунды скуки. Музыка, игра актёров, режиссура — всё на высочайшем уровне.", truncation=True, max_length=512)
5# [{'label': 'Positive', 'score': 0.7779}]transformers напрямую:1import torch
2from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
4checkpoint = "sergeyzh/rubert-large-uncased-sentiment"
5tokenizer = AutoTokenizer.from_pretrained(checkpoint)
6model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
7
8text = "Просто шедевр. Каждая минута на вес золота, ни секунды скуки. Музыка, игра актёров, режиссура — всё на высочайшем уровне."
9inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
10with torch.no_grad():
11 logits = model(**inputs).logits
12proba = torch.softmax(logits, dim=1)
13label = model.config.id2label[proba.argmax().item()]
14print(label, proba.tolist())
15# Positive [[0.0126, 0.2095, 0.7779]]| Модель | Kinopoisk Acc/F1 | RuReviews Acc/F1 | Georeview Acc/F1 | Avg F1 |
|---|---|---|---|---|
| sergeyzh/rubert-large-uncased-sentiment | 0.7013 / 0.6929 | 0.7851 / 0.7866 | 0.7858 / 0.7361 | 0.7385 |
| sergeyzh/rubert-tiny-sentiment | 0.6593 / 0.6519 | 0.7672 / 0.7690 | 0.7680 / 0.7130 | 0.7113 |
| seara/rubert-base-cased-russian-sentiment | 0.5653 / 0.5679 | 0.8163 / 0.8183 | 0.6566 / 0.6434 | 0.6765 |
| seara/rubert-tiny2-russian-sentiment | 0.4980 / 0.5032 | 0.7877 / 0.7899 | 0.6218 / 0.6122 | 0.6351 |
| blanchefort/rubert-base-cased-sentiment | 0.5253 / 0.5209 | 0.7615 / 0.7549 | 0.6716 / 0.6047 | 0.6268 |
| blanchefort/rubert-base-cased-sentiment-rusentiment | 0.5413 / 0.5470 | 0.6230 / 0.6327 | 0.6022 / 0.5760 | 0.5852 |
| cointegrated/rubert-tiny-sentiment-balanced | 0.4293 / 0.3977 | 0.7330 / 0.7344 | 0.6158 / 0.5857 | 0.5726 |