Downloads · 30 days
108
2% of all-time downloads
AnkitAI/deberta-v3-small-base-emotions-classifier
deberta-v3-small-base-emotions-classifier is a text classification model from AnkitAI. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
Downloads · 30 days
108
2% of all-time downloads
All-time downloads
6.6K
Public
Parameters
142M
570 MB on disk
Likes
2
Public
Click a slice to open those files.
.safetensors568 MB · 98%
From the Hugging Face model README
This model is a fine-tuned version of microsoft/deberta-v3-small for emotion detection using the dair-ai/emotion dataset.
Fast Emotion-X is a state-of-the-art emotion detection model fine-tuned from Microsoft's DeBERTa V3 Small model. It is designed to accurately classify text into one of six emotional categories. Leveraging the robust capabilities of DeBERTa, this model is fine-tuned on a comprehensive emotion dataset, ensuring high accuracy and reliability.
AnkitAI/deberta-v3-small-base-emotions-classifiermicrosoft/deberta-v3-smallYou can use this model directly with the provided Python package or the Hugging Face transformers library.
Install the package using pip:
pip install emotionclassifier
Here's an example of how to use the emotionclassifier to classify a single text:
from emotionclassifier import EmotionClassifier
# Initialize the classifier with the default model
classifier = EmotionClassifier()
# Classify a single text
text = "I am very happy today!"
result = classifier.predict(text)
print("Emotion:", result['label'])
print("Confidence:", result['confidence'])
You can classify multiple texts at once using the predict_batch method:
texts = ["I am very happy today!", "I am so sad."]
results = classifier.predict_batch(texts)
print("Batch processing results:", results)
To visualize the emotion distribution of a text:
from emotionclassifier import plot_emotion_distribution
result = classifier.predict("I am very happy today!")
plot_emotion_distribution(result['probabilities'], classifier.labels.values())
You can also use the package from the command line:
emotionclassifier --model deberta-v3-small --text "I am very happy today!"
Integrate with pandas DataFrames to classify text columns:
import pandas as pd
from emotionclassifier import DataFrameEmotionClassifier
df = pd.DataFrame({
'text': ["I am very happy today!", "I am so sad."]
})
classifier = DataFrameEmotionClassifier()
df = classifier.classify_dataframe(df, 'text')
print(df)
Analyze and plot emotion trends over time:
from emotionclassifier import EmotionTrends
texts = ["I am very happy today!", "I am feeling okay.", "I am very sad."]
trends = EmotionTrends()
emotions = trends.analyze_trends(texts)
trends.plot_trends(emotions)
Fine-tune a pre-trained model on your own dataset:
from emotionclassifier.fine_tune import fine_tune_model
# Define your training and validation datasets
train_dataset = ...
val_dataset = ...
# Fine-tune the model
fine_tune_model(classifier.model, classifier.tokenizer, train_dataset, val_dataset, output_dir='fine_tuned_model')
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_name = "AnkitAI/deberta-v3-small-base-emotions-classifier"
model = AutoModelForSequenceClassification.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# Example usage
def predict_emotion(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=128)
outputs = model(**inputs)
logits = outputs.logits
predictions = logits.argmax(dim=1)
return predictions
text = "I'm so happy with the results!"
emotion = predict_emotion(text)
print("Detected Emotion:", emotion)
The model was trained using the following parameters:
| Parameter | Value |
|---|---|
| Model Name | microsoft/deberta-v3-small |
| Training Dataset | dair-ai/emotion |
| Number of Training Epochs | 20 |
| Learning Rate | 2e-5 |
| Per Device Train Batch Size | 4 |
| Evaluation Strategy | Epoch |
| Best Model Accuracy | 94.6% |
If this model is useful in your work, you can support independent research:
<p align="left"> <a href="https://www.buymeacoffee.com/AnkitAI" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me a Coffee" height="60" width="217" /></a> </p>This model is licensed under the MIT License.
More models: ankitaglawe.com