Text Classification
Transformers
PyTorch
English
distilbert
fill-mask
emotion
emotion-detection
affective-computing
text-embeddings-inference
Instructions to use Jayan12321/distilbert-emotion-classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Jayan12321/distilbert-emotion-classifier with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Jayan12321/distilbert-emotion-classifier")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("Jayan12321/distilbert-emotion-classifier") model = AutoModelForMaskedLM.from_pretrained("Jayan12321/distilbert-emotion-classifier", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,89 +1,60 @@
|
|
| 1 |
-
---
|
| 2 |
-
language: en
|
| 3 |
-
license: apache-2.0
|
| 4 |
-
tags:
|
| 5 |
-
- text-classification
|
| 6 |
-
- emotion
|
| 7 |
-
- emotion-detection
|
| 8 |
-
- affective-computing
|
| 9 |
-
- distilbert
|
| 10 |
-
- transformers
|
| 11 |
-
- pytorch
|
| 12 |
-
pipeline_tag: text-classification
|
| 13 |
-
widget:
|
| 14 |
-
- text: "I was skeptical at first, but the results completely blew me away with how good it turned out!"
|
| 15 |
-
example_title: "Joy Example"
|
| 16 |
-
- text: "I have been sitting here in complete darkness, feeling utterly exhausted and defeated."
|
| 17 |
-
example_title: "Sadness Example"
|
| 18 |
-
- text: "Get out of my face right now before I lose my temper completely!"
|
| 19 |
-
example_title: "Anger Example"
|
| 20 |
-
- text: "Every single moment spent with you makes my life feel infinitely more meaningful."
|
| 21 |
-
example_title: "Love Example"
|
| 22 |
-
---
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
* **
|
| 35 |
-
* **
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
| Emotion | Precision | Recall | F1-Score | Support |
|
| 62 |
-
| :--- | :---: | :---: | :---: | :---: |
|
| 63 |
-
| **Joy** | 0.95 | 0.94 | 0.95 | 695 |
|
| 64 |
-
| **Sadness** | 0.96 | 0.97 | 0.96 | 581 |
|
| 65 |
-
| **Anger** | 0.92 | 0.91 | 0.92 | 275 |
|
| 66 |
-
| **Fear** | 0.88 | 0.92 | 0.90 | 224 |
|
| 67 |
-
| **Love** | 0.79 | 0.87 | 0.83 | 159 |
|
| 68 |
-
| **Surprise** | 0.93 | 0.56 | 0.70 | 66 |
|
| 69 |
-
|
| 70 |
-
---
|
| 71 |
-
|
| 72 |
-
## π Production Architecture Blueprint
|
| 73 |
-
```
|
| 74 |
-
[ Free-Form Input Text ]
|
| 75 |
-
β
|
| 76 |
-
βΌ (<15ms SLA)
|
| 77 |
-
[ Fast Tokenizer (WordPiece) ]
|
| 78 |
-
β
|
| 79 |
-
βΌ
|
| 80 |
-
[ DistilBERT Sequence Classifier ]
|
| 81 |
-
β
|
| 82 |
-
ββββββββββββββββ΄βββββββββββββββ
|
| 83 |
-
βΌ βΌ
|
| 84 |
-
[ Argmax Class ] [ Softmax Distribution ]
|
| 85 |
-
β’ Primary Emotion β’ Multi-class confidence
|
| 86 |
-
```
|
| 87 |
-
|
| 88 |
-
---
|
| 89 |
-
*Authored and published by [Jayan Gupta](https://huggingface.co/Jayan12321) β’ Data Scientist & AI Engineer*
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: apache-2.0
|
| 4 |
+
tags:
|
| 5 |
+
- text-classification
|
| 6 |
+
- emotion
|
| 7 |
+
- emotion-detection
|
| 8 |
+
- affective-computing
|
| 9 |
+
- distilbert
|
| 10 |
+
- transformers
|
| 11 |
+
- pytorch
|
| 12 |
+
pipeline_tag: text-classification
|
| 13 |
+
widget:
|
| 14 |
+
- text: "I was skeptical at first, but the results completely blew me away with how good it turned out!"
|
| 15 |
+
example_title: "Joy Example"
|
| 16 |
+
- text: "I have been sitting here in complete darkness, feeling utterly exhausted and defeated."
|
| 17 |
+
example_title: "Sadness Example"
|
| 18 |
+
- text: "Get out of my face right now before I lose my temper completely!"
|
| 19 |
+
example_title: "Anger Example"
|
| 20 |
+
- text: "Every single moment spent with you makes my life feel infinitely more meaningful."
|
| 21 |
+
example_title: "Love Example"
|
| 22 |
+
---
|
| 23 |
+
|
| 24 |
+
# DistilBERT Multiclass Emotion Classifier π
|
| 25 |
+
|
| 26 |
+
A fine-tuned **DistilBERT (Distilled Bidirectional Encoder Representations from Transformers)** sequence classification model trained to detect nuanced affective and emotional states from unstructured natural language.
|
| 27 |
+
|
| 28 |
+
- **Author**: [Jayan Gupta](https://huggingface.co/Jayan12321)
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## π― Model Overview & Classes
|
| 33 |
+
The model classifies text across 6 primary emotional dimensions:
|
| 34 |
+
* `0`: **Sadness** (grief, sorrow, exhaustion)
|
| 35 |
+
* `1`: **Joy** (happiness, triumph, gratitude)
|
| 36 |
+
* `2`: **Love** (affection, admiration, intimacy)
|
| 37 |
+
* `3`: **Anger** (irritation, frustration, rage)
|
| 38 |
+
* `4`: **Fear** (anxiety, dread, panic)
|
| 39 |
+
* `5`: **Surprise** (shock, amazement, disbelief)
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## π» Python Quickstart with Transformers Pipeline
|
| 44 |
+
|
| 45 |
+
```python
|
| 46 |
+
from transformers import pipeline
|
| 47 |
+
|
| 48 |
+
# Load fine-tuned pipeline directly from Hugging Face
|
| 49 |
+
classifier = pipeline(
|
| 50 |
+
"text-classification",
|
| 51 |
+
model="Jayan12321/distilbert-emotion-classifier"
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
# Run inference
|
| 55 |
+
sample_text = "I received the scholarship offer this morning and I cannot stop smiling!"
|
| 56 |
+
prediction = classifier(sample_text)
|
| 57 |
+
|
| 58 |
+
print(prediction)
|
| 59 |
+
# Output: [{'label': 'joy', 'score': 0.987}]
|
| 60 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|