cointegrated / rubert-tiny-sentiment-balanced

huggingface.co
Total runs: 24.8K
24-hour runs: 0
7-day runs: 419
30-day runs: -23
Model's Last Updated: March 20 2023
text-classification

Introduction of rubert-tiny-sentiment-balanced

Model Details of rubert-tiny-sentiment-balanced

This is the cointegrated/rubert-tiny model fine-tuned for classification of sentiment for short Russian texts.

The problem is formulated as multiclass classification: negative vs neutral vs positive .

Usage

The function below estimates the sentiment of the given text:

# !pip install transformers sentencepiece --quiet
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

model_checkpoint = 'cointegrated/rubert-tiny-sentiment-balanced'
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = AutoModelForSequenceClassification.from_pretrained(model_checkpoint)
if torch.cuda.is_available():
    model.cuda()
    
def get_sentiment(text, return_type='label'):
    """ Calculate sentiment of a text. `return_type` can be 'label', 'score' or 'proba' """
    with torch.no_grad():
        inputs = tokenizer(text, return_tensors='pt', truncation=True, padding=True).to(model.device)
        proba = torch.sigmoid(model(**inputs).logits).cpu().numpy()[0]
    if return_type == 'label':
        return model.config.id2label[proba.argmax()]
    elif return_type == 'score':
        return proba.dot([-1, 0, 1])
    return proba

text = 'Какая гадость эта ваша заливная рыба!'
# classify the text
print(get_sentiment(text, 'label'))  # negative
# score the text on the scale from -1 (very negative) to +1 (very positive)
print(get_sentiment(text, 'score'))  # -0.5894946306943893
# calculate probabilities of all labels
print(get_sentiment(text, 'proba'))  # [0.7870447  0.4947824  0.19755007]
Training

We trained the model on the datasets collected by Smetanin . We have converted all training data into a 3-class format and have up- and downsampled the training data to balance both the sources and the classes. The training code is available as a Colab notebook . The metrics on the balanced test set are the following:

Source Macro F1
SentiRuEval2016_banks 0.83
SentiRuEval2016_tele 0.74
kaggle_news 0.66
linis 0.50
mokoron 0.98
rureviews 0.72
rusentiment 0.67

Runs of cointegrated rubert-tiny-sentiment-balanced on huggingface.co

24.8K
Total runs
0
24-hour runs
1.3K
3-day runs
419
7-day runs
-23
30-day runs

More Information About rubert-tiny-sentiment-balanced huggingface.co Model

rubert-tiny-sentiment-balanced huggingface.co

rubert-tiny-sentiment-balanced huggingface.co is an AI model on huggingface.co that provides rubert-tiny-sentiment-balanced's model effect (), which can be used instantly with this cointegrated rubert-tiny-sentiment-balanced model. huggingface.co supports a free trial of the rubert-tiny-sentiment-balanced model, and also provides paid use of the rubert-tiny-sentiment-balanced. Support call rubert-tiny-sentiment-balanced model through api, including Node.js, Python, http.

rubert-tiny-sentiment-balanced huggingface.co Url

https://huggingface.co/cointegrated/rubert-tiny-sentiment-balanced

cointegrated rubert-tiny-sentiment-balanced online free

rubert-tiny-sentiment-balanced huggingface.co is an online trial and call api platform, which integrates rubert-tiny-sentiment-balanced's modeling effects, including api services, and provides a free online trial of rubert-tiny-sentiment-balanced, you can try rubert-tiny-sentiment-balanced online for free by clicking the link below.

cointegrated rubert-tiny-sentiment-balanced online free url in huggingface.co:

https://huggingface.co/cointegrated/rubert-tiny-sentiment-balanced

rubert-tiny-sentiment-balanced install

rubert-tiny-sentiment-balanced is an open source model from GitHub that offers a free installation service, and any user can find rubert-tiny-sentiment-balanced on GitHub to install. At the same time, huggingface.co provides the effect of rubert-tiny-sentiment-balanced install, users can directly use rubert-tiny-sentiment-balanced installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

rubert-tiny-sentiment-balanced install url in huggingface.co:

https://huggingface.co/cointegrated/rubert-tiny-sentiment-balanced

Url of rubert-tiny-sentiment-balanced

rubert-tiny-sentiment-balanced huggingface.co Url

Provider of rubert-tiny-sentiment-balanced huggingface.co

cointegrated
ORGANIZATIONS

Other API from cointegrated