Emotion Analysis Model - 8 Categories
This model performs multi-label emotion classification, detecting 8 basic emotions:
- joy
- trust
- fear
- surprise
- sadness
- disgust
- anger
- anticipation
Training Data
This model was trained on a processed version of the GoEmotions dataset. The original 27 emotion categories were mapped to 8 basic emotions.
The processed dataset is available at: https://huggingface.co/datasets/bulpara/emotion-analysis-8-categories-dataset and can be loaded with:
from datasets import load_dataset
dataset = load_dataset("bulpara/emotion-analysis-8-categories-dataset")
Model Details
- Architecture: DistilBERT for Sequence Classification
- Type: Multi-label classification
- Number of labels: 8
Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "{model_name}"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Prepare text
text = "I'm so excited about this new project!"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
# Make prediction
model.eval()
with torch.no_grad():
outputs = model(**inputs)
# Process outputs
import numpy as np
probs = torch.sigmoid(outputs.logits).squeeze().numpy()
emotions = ['joy', 'trust', 'fear', 'surprise', 'sadness', 'disgust', 'anger', 'anticipation']
# Print results
for emotion, prob in zip(emotions, probs):
if prob > 0.3: # threshold can be adjusted
print(f"{emotion}: {prob:.4f}")
Citation
@inproceedings{demszky2020goemotions,
author = {Demszky, Dorottya and Movshovitz-Attias, Dana and Ko, Jeongwoo and Cowen, Alan and Nemade, Gaurav and Ravi, Sujith},
booktitle = {58th Annual Meeting of the Association for Computational Linguistics (ACL)},
title = {{GoEmotions: A Dataset of Fine-Grained Emotions}},
year = {2020}
}
- Downloads last month
- 72
Inference Providers
NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API:
The model has no library tag.