dair-ai/emotion
Viewer • Updated • 437k • 16.7k • 455
How to use laxsvips/minilm-finetuned-emotion with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="laxsvips/minilm-finetuned-emotion") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("laxsvips/minilm-finetuned-emotion")
model = AutoModelForSequenceClassification.from_pretrained("laxsvips/minilm-finetuned-emotion", device_map="auto")This model is a fine-tuned version of microsoft/MiniLM-L12-H384-uncased on the Hugging Face emotion (https://huggingface.co/datasets/emotion) dataset. It achieves the following results on the evaluation set:
MiniLM is a distilled model from the paper "MiniLM: Deep Self-Attention Distillation for Task-Agnostic Compression of Pre-Trained Transformers".
This model has been created as a learning guide on:
from transformers import pipeline
model_cpt = "laxsvips/minilm-finetuned-emotion"
pipe = pipeline("text-classification", model=model_cpt)
predicted_scores = pipe("I am so glad you could help me")
print(predicted_scores)
The results:
[[{'label': 'sadness', 'score': 0.003758953418582678},
{'label': 'joy', 'score': 0.9874302744865417},
{'label': 'love', 'score': 0.00610917154699564},
{'label': 'anger', 'score': 9.696640336187556e-05},
{'label': 'fear', 'score': 0.0006420552381314337},
{'label': 'surprise', 'score': 0.00196251692250371}]]
Emotion is a dataset of English Twitter messages with six basic emotions: anger, fear, joy, love, sadness, and surprise.
Refer to the Colab notebook
The following hyperparameters were used during training:
| Train Loss | Train Accuracy | Validation Loss | Validation Accuracy | Epoch |
|---|---|---|---|---|
| 0.9485 | 0.5543 | 0.8404 | 0.6870 | 0 |
| 0.4192 | 0.8347 | 0.3450 | 0.9040 | 1 |
| 0.2132 | 0.9178 | 0.2288 | 0.9240 | 2 |
| 0.1465 | 0.9364 | 0.1838 | 0.9295 | 3 |
| 0.1168 | 0.9446 | 0.1709 | 0.9350 | 4 |
{'accuracy': 0.935,
'precision': 0.937365614416424,
'recall': 0.935,
'f1_score': 0.9355424419858925}