dair-ai/emotion
Viewer • Updated • 437k • 33.8k • 440
How to use Prikshit7766/bert-base-uncased-emotion with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="Prikshit7766/bert-base-uncased-emotion") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("Prikshit7766/bert-base-uncased-emotion")
model = AutoModelForSequenceClassification.from_pretrained("Prikshit7766/bert-base-uncased-emotion")bert-base-uncasedThe model was fine-tuned on the dair-ai/emotion dataset, which consists of English tweets classified into six emotion categories.
text: The text of the tweetlabel: The emotion label for the text (ClassLabel: ['sadness', 'joy', 'love', 'anger', 'fear', 'surprise'])The model was trained using the following hyperparameters:
The model was trained for 7 epochs, but it stopped early due to early stopping. Early stopping was configured with the following details:
The model achieved the following results on the validation dataset in the final epoch:
After training, the model was evaluated on a held-out test set. The following are the results on the test dataset:
You can load the model and tokenizer for inference using the Hugging Face transformers library with the pipeline:
from transformers import pipeline
# Load the emotion classification pipeline
classifier = pipeline("text-classification", model='Prikshit7766/bert-base-uncased-emotion', return_all_scores=True)
# Test the classifier with a sample sentence
prediction = classifier("I am feeling great and happy today!")
# Print the predictions
print(prediction)
Output
[[{'label': 'sadness', 'score': 0.00010687233589123935},
{'label': 'joy', 'score': 0.9991187453269958},
{'label': 'love', 'score': 0.00041500659426674247},
{'label': 'anger', 'score': 7.090374856488779e-05},
{'label': 'fear', 'score': 5.2315706852823496e-05},
{'label': 'surprise', 'score': 0.0002362433006055653}]]
Base model
google-bert/bert-base-uncased