Instructions to use blanchefort/rubert-base-cased-sentiment-rusentiment with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use blanchefort/rubert-base-cased-sentiment-rusentiment with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="blanchefort/rubert-base-cased-sentiment-rusentiment")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("blanchefort/rubert-base-cased-sentiment-rusentiment") model = AutoModelForSequenceClassification.from_pretrained("blanchefort/rubert-base-cased-sentiment-rusentiment") - Inference
- Notebooks
- Google Colab
- Kaggle
RuBERT for Sentiment Analysis
This is a DeepPavlov/rubert-base-cased-conversational model trained on RuSentiment.
Labels
0: NEUTRAL
1: POSITIVE
2: NEGATIVE
How to use
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
Dataset used for model training
A. Rogers A. Romanov A. Rumshisky S. Volkova M. Gronas A. Gribov RuSentiment: An Enriched Sentiment Analysis Dataset for Social Media in Russian. Proceedings of COLING 2018.
- Downloads last month
- 302,698