Back to all models
Model: mrm8488/distilroberta-base-finetuned-sentiment

Monthly model downloads

mrm8488/distilroberta-base-finetuned-sentiment mrm8488/distilroberta-base-finetuned-sentiment
- downloads
last 30 days

pytorch

tf

Contributed by

mrm8488 Manuel Romero
67 models

How to use this model directly from the πŸ€—/transformers library:

			
Copy model
tokenizer = AutoTokenizer.from_pretrained("mrm8488/distilroberta-base-finetuned-sentiment") model = AutoModelForSequenceClassification.from_pretrained("mrm8488/distilroberta-base-finetuned-sentiment")

DistilRoBERTa + Sentiment Analysis πŸ˜‚πŸ˜’πŸ˜‘πŸ˜ƒπŸ˜―

This in an adapted version of @omarsar0 tutorial He explains everything so detailed and provided the dataset. I just changed some parameters and created the config.jsonfile to upload it to πŸ€—Transformers HUB

In this tutorial, he shows how to fine-tune a language model (LM) for emotion classification with code adapted from this tutorial by MARCIN ZABŁOCKI.

The emotions covered are:

  • sadness 😒
  • joy πŸ˜ƒ
  • love πŸ₯°
  • anger 😑
  • fear 😱
  • surprise 😯

Details of the language model

The base model used is DistilRoBERTa

Details of the downstream task (Sentence classification) - Dataset πŸ“š

Dataset split # Size # Sequences
Train 1.58M 20000
Validation 200 KB
Test 202 KB

Results after training πŸ‹οΈβ€β™€οΈπŸ§Ύ

emotion precision recall f1-score support
sadness 0.973868 0.949066 0.961307 589
joy 0.970313 0.901306 0.934537 689
love 0.743119 0.925714 0.824427 175
anger 0.884615 0.969349 0.925046 261
fear 0.951456 0.875000 0.911628 224
surprise 0.750000 0.919355 0.826087 62
accuracy 0.924000 2000
macro avg 0.878895 0.923298 0.897172 2000
weighted avg 0.931355 0.924000 0.925620 2000

Model in action πŸ”¨

Fast usage with pipelines πŸ§ͺ

from transformers import pipeline

nlp_sentiment = pipeline(
    "sentiment-analysis",
    model="mrm8488/distilroberta-base-finetuned-sentiment",
    tokenizer="mrm8488/distilroberta-base-finetuned-sentiment"
)

text = "i feel i should return to the start of the weekend so my loyal readers can get a feeling for things up to this point"

nlp_sentiment(text)
# Output: [{'label': 'love', 'score': 0.2183746}]

Created by Manuel Romero/@mrm8488

Made with in Spain