Downloads · 30 days
19
7% of all-time downloads
bulpara/emotion-analysis-8-categories
emotion-analysis-8-categories is a machine learning model from bulpara. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This model performs multi-label emotion classification, detecting 8 basic emotions: - joy - trust - fear - surprise - sadness - disgust - anger - anticipation
Downloads · 30 days
19
7% of all-time downloads
All-time downloads
289
Public
Parameters
67M
2.9 GB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors268 MB · 100%
From the Hugging Face model README
This model performs multi-label emotion classification, detecting 8 basic emotions:
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")
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}")
@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}
}