File size: 22,353 Bytes
39da8c9
0d0d64f
39da8c9
731b855
0d0d64f
 
 
 
 
 
 
 
 
6c45b4a
0d0d64f
39da8c9
0d0d64f
 
 
 
 
 
 
 
731b855
0d0d64f
 
 
 
 
017c998
0d0d64f
731b855
0d0d64f
 
 
731b855
0d0d64f
 
 
 
 
 
f8f1f2f
6c45b4a
 
017c998
f30d348
0d0d64f
6c45b4a
0d0d64f
017c998
 
 
6c45b4a
017c998
 
 
0d0d64f
017c998
 
 
 
 
 
 
 
 
 
 
 
 
0d0d64f
6c45b4a
017c998
6c45b4a
017c998
6c45b4a
f8f1f2f
6c45b4a
017c998
 
 
 
 
0d0d64f
6c45b4a
017c998
6c45b4a
017c998
0d0d64f
017c998
 
0d0d64f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c45b4a
017c998
6c45b4a
017c998
6c45b4a
017c998
 
 
c843e8a
017c998
6c45b4a
017c998
c843e8a
017c998
 
 
 
 
 
 
 
 
 
 
 
 
 
0d0d64f
017c998
c843e8a
017c998
 
0d0d64f
 
c843e8a
 
0d0d64f
c843e8a
0d0d64f
 
c843e8a
0d0d64f
 
 
 
c843e8a
0d0d64f
 
 
 
6c45b4a
0d0d64f
6c45b4a
0d0d64f
 
017c998
0d0d64f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c843e8a
0d0d64f
 
6c45b4a
 
017c998
 
0d0d64f
 
 
c843e8a
 
0d0d64f
6c45b4a
017c998
6c45b4a
0d0d64f
6c45b4a
017c998
 
 
0d0d64f
 
 
 
 
 
 
 
 
 
 
 
 
6c45b4a
017c998
 
0d0d64f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
017c998
0d0d64f
 
 
 
 
 
 
 
 
 
 
 
 
017c998
 
 
 
0d0d64f
017c998
0d0d64f
 
 
 
017c998
 
 
0d0d64f
 
 
 
017c998
 
0d0d64f
017c998
 
 
 
0d0d64f
017c998
 
0d0d64f
017c998
 
 
6c45b4a
017c998
0d0d64f
 
 
017c998
0d0d64f
 
 
017c998
0d0d64f
017c998
0d0d64f
017c998
 
 
 
 
0d0d64f
017c998
 
 
 
 
 
 
 
0d0d64f
017c998
0d0d64f
 
 
 
 
 
 
 
017c998
 
 
 
0d0d64f
017c998
 
 
 
 
 
 
0d0d64f
017c998
 
 
 
 
0d0d64f
017c998
0d0d64f
017c998
 
1212e0e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
017c998
 
 
 
 
 
 
 
 
0d0d64f
017c998
 
0d0d64f
017c998
3e78889
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
815e41e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3e78889
 
017c998
 
 
0d0d64f
017c998
 
0d0d64f
 
017c998
 
 
0d0d64f
017c998
 
 
f8f1f2f
0d0d64f
017c998
 
 
 
 
 
 
 
 
 
f8f1f2f
 
 
 
 
0d0d64f
 
 
 
f8f1f2f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
---
license: apache-2.0
language:
- en
metrics:
- precision
- recall
- f1
- accuracy
new_version: v1.1
datasets:
- custom
- chatgpt
pipeline_tag: text-classification
library_name: transformers
tags:
- emotion
- classification
- text-classification
- bert
- emojis
- emotions
- v1.0
- sentiment-analysis
- nlp
- lightweight
- chatbot
- social-media
- mental-health
- short-text
- emotion-detection
- transformers
- real-time
- expressive
- ai
- machine-learning
- english
- inference
- edge-ai
- smart-replies
- tone-analysis
base_model:
- boltuix/bitBERT
- boltuix/bert-mini
---

![Banner](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgHs4EXWBZuQWWC-bfliV2jHZN7wsgn810HEf42UuUbdPgV9aLVIq7Hiv7sWr0aqsB5aTkiylPkytpOpimhp8Atuo3Q_kO5C6uZTuQf4YEWklXqE7jQiUfZlENL5AjNgvnpLxuBg628ztR4w276TEv8Vr9u7ER7wr6i6A8W14UQ8diNBrsS0zVMVYZVYk/s4000/bert-emotions.jpg)

# 😊 BERT-Emotion β€” Lightweight BERT for Real-Time Emotion Detection 🌟

[![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-yellow.svg)](https://www.apache.org/licenses/LICENSE-2.0)
[![Model Size](https://img.shields.io/badge/Size-~20MB-blue)](#)
[![Tasks](https://img.shields.io/badge/Tasks-Emotion%20Detection%20%7C%20Text%20Classification%20%7C%20Sentiment%20Analysis-orange)](#)
[![Inference Speed](https://img.shields.io/badge/Optimized%20For-Edge%20Devices-green)](#)

## Table of Contents
- πŸ“– [Overview](#overview)
- ✨ [Key Features](#key-features)
- πŸ’« [Supported Emotions](#supported-emotions)
- βš™οΈ [Installation](#installation)
- πŸ“₯ [Download Instructions](#download-instructions)
- πŸš€ [Quickstart: Emotion Detection](#quickstart-emotion-detection)
- πŸ“Š [Evaluation](#evaluation)
- πŸ’‘ [Use Cases](#use-cases)
- πŸ–₯️ [Hardware Requirements](#hardware-requirements)
- πŸ“š [Trained On](#trained-on)
- πŸ”§ [Fine-Tuning Guide](#fine-tuning-guide)
- βš–οΈ [Comparison to Other Models](#comparison-to-other-models)
- 🏷️ [Tags](#tags)
- πŸ“„ [License](#license)
- πŸ™ [Credits](#credits)
- πŸ’¬ [Support & Community](#support--community)
- ✍️ [Contact](#contact)

![Banner](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgHs4EXWBZuQWWC-bfliV2jHZN7wsgn810HEf42UuUbdPgV9aLVIq7Hiv7sWr0aqsB5aTkiylPkytpOpimhp8Atuo3Q_kO5C6uZTuQf4YEWklXqE7jQiUfZlENL5AjNgvnpLxuBg628ztR4w276TEv8Vr9u7ER7wr6i6A8W14UQ8diNBrsS0zVMVYZVYk/s4000/bert-emotions.jpg)

## Overview

`BERT-Emotion` is a **lightweight** NLP model derived from **bert-mini** and **bert-micro**, fine-tuned for **short-text emotion detection** on **edge and IoT devices**. With a quantized size of **~20MB** and **~6M parameters**, it classifies text into **13 rich emotional categories** (e.g., Happiness, Sadness, Anger, Love) with high accuracy. Optimized for **low-latency** and **offline operation**, BERT-Emotion is ideal for privacy-first applications like chatbots, social media sentiment analysis, and mental health monitoring in resource-constrained environments such as mobile apps, wearables, and smart home devices.

- **Model Name**: BERT-Emotion
- **Size**: ~20MB (quantized)
- **Parameters**: ~6M
- **Architecture**: Lightweight BERT (4 layers, hidden size 128, 4 attention heads)
- **Description**: Lightweight 4-layer, 128-hidden model for emotion detection
- **License**: Apache-2.0 β€” free for commercial and personal use

## Key Features

- ⚑ **Compact Design**: ~20MB footprint fits devices with limited storage.
- 🧠 **Rich Emotion Detection**: Classifies 13 emotions with expressive emoji mappings.
- πŸ“Ά **Offline Capability**: Fully functional without internet access.
- βš™οΈ **Real-Time Inference**: Optimized for CPUs, mobile NPUs, and microcontrollers.
- 🌍 **Versatile Applications**: Supports emotion detection, sentiment analysis, and tone analysis for short texts.

## Supported Emotions

BERT-Emotion classifies text into one of 13 emotional categories, each mapped to an expressive emoji for enhanced interpretability:

| Emotion    | Emoji |
|------------|-------|
| Sadness    | 😒    |
| Anger      | 😠    |
| Love       | ❀️    |
| Surprise   | 😲    |
| Fear       | 😱    |
| Happiness  | πŸ˜„    |
| Neutral    | 😐    |
| Disgust    | 🀒    |
| Shame      | πŸ™ˆ    |
| Guilt      | πŸ˜”    |
| Confusion  | πŸ˜•    |
| Desire     | πŸ”₯    |
| Sarcasm    | 😏    |

## Installation

Install the required dependencies:

```bash
pip install transformers torch
```

Ensure your environment supports Python 3.6+ and has ~20MB of storage for model weights.

## Download Instructions

1. **Via Hugging Face**:
   - Access the model at [boltuix/bert-emotion](https://huggingface.co/boltuix/bert-emotion).
   - Download the model files (~20MB) or clone the repository:
     ```bash
     git clone https://huggingface.co/boltuix/bert-emotion
     ```
2. **Via Transformers Library**:
   - Load the model directly in Python:
     ```python
     from transformers import AutoModelForSequenceClassification, AutoTokenizer
     model = AutoModelForSequenceClassification.from_pretrained("boltuix/bert-emotion")
     tokenizer = AutoTokenizer.from_pretrained("boltuix/bert-emotion")
     ```
3. **Manual Download**:
   - Download quantized model weights (Safetensors format) from the Hugging Face model hub.
   - Extract and integrate into your edge/IoT application.

## Quickstart: Emotion Detection

### Basic Inference Example
Classify emotions in short text inputs using the Hugging Face pipeline:

```python
from transformers import pipeline

# Load the fine-tuned BERT-Emotion model
sentiment_analysis = pipeline("text-classification", model="boltuix/bert-emotion")

# Analyze emotion
result = sentiment_analysis("i love you")
print(result)
```

**Output**:
```python
[{'label': 'Love', 'score': 0.8442274928092957}]
```

This indicates the emotion is **Love ❀️** with **84.42%** confidence.

### Extended Example with Emoji Mapping
Enhance the output with human-readable emotions and emojis:

```python
from transformers import pipeline

# Load the fine-tuned BERT-Emotion model
sentiment_analysis = pipeline("text-classification", model="boltuix/bert-emotion")

# Define label-to-emoji mapping
label_to_emoji = {
    "Sadness": "😒",
    "Anger": "😠",
    "Love": "❀️",
    "Surprise": "😲",
    "Fear": "😱",
    "Happiness": "πŸ˜„",
    "Neutral": "😐",
    "Disgust": "🀒",
    "Shame": "πŸ™ˆ",
    "Guilt": "πŸ˜”",
    "Confusion": "πŸ˜•",
    "Desire": "πŸ”₯",
    "Sarcasm": "😏"
}

# Input text
text = "i love you"

# Analyze emotion
result = sentiment_analysis(text)[0]
label = result["label"].capitalize()
emoji = label_to_emoji.get(label, "❓")

# Output
print(f"Text: {text}")
print(f"Predicted Emotion: {label} {emoji}")
print(f"Confidence: {result['score']:.2%}")
```

**Output**:
```plaintext
Text: i love you
Predicted Emotion: Love ❀️
Confidence: 84.42%
```

*Note*: Fine-tune the model for specific domains or additional emotion categories to improve accuracy.

## Evaluation

BERT-Emotion was evaluated on an emotion classification task using 13 short-text samples relevant to IoT and social media contexts. The model predicts one of 13 emotion labels, with success defined as the correct label being predicted.

### Test Sentences
| Sentence | Expected Emotion |
|----------|------------------|
| I love you so much! | Love |
| This is absolutely disgusting! | Disgust |
| I'm so happy with my new phone! | Happiness |
| Why does this always break? | Anger |
| I feel so alone right now. | Sadness |
| What just happened?! | Surprise |
| I'm terrified of this update failing. | Fear |
| Meh, it's just okay. | Neutral |
| I shouldn't have said that. | Shame |
| I feel bad for forgetting. | Guilt |
| Wait, what does this mean? | Confusion |
| I really want that new gadget! | Desire |
| Oh sure, like that's gonna work. | Sarcasm |

### Evaluation Code
```python
from transformers import pipeline

# Load the fine-tuned BERT-Emotion model
sentiment_analysis = pipeline("text-classification", model="boltuix/bert-emotion")

# Define label-to-emoji mapping
label_to_emoji = {
    "Sadness": "😒",
    "Anger": "😠",
    "Love": "❀️",
    "Surprise": "😲",
    "Fear": "😱",
    "Happiness": "πŸ˜„",
    "Neutral": "😐",
    "Disgust": "🀒",
    "Shame": "πŸ™ˆ",
    "Guilt": "πŸ˜”",
    "Confusion": "πŸ˜•",
    "Desire": "πŸ”₯",
    "Sarcasm": "😏"
}

# Test data
tests = [
    ("I love you so much!", "Love"),
    ("This is absolutely disgusting!", "Disgust"),
    ("I'm so happy with my new phone!", "Happiness"),
    ("Why does this always break?", "Anger"),
    ("I feel so alone right now.", "Sadness"),
    ("What just happened?!", "Surprise"),
    ("I'm terrified of this update failing.", "Fear"),
    ("Meh, it's just okay.", "Neutral"),
    ("I shouldn't have said that.", "Shame"),
    ("I feel bad for forgetting.", "Guilt"),
    ("Wait, what does this mean?", "Confusion"),
    ("I really want that new gadget!", "Desire"),
    ("Oh sure, like that's gonna work.", "Sarcasm")
]

results = []

# Run tests
for text, expected in tests:
    result = sentiment_analysis(text)[0]
    predicted = result["label"].capitalize()
    confidence = result["score"]
    emoji = label_to_emoji.get(predicted, "❓")
    results.append({
        "sentence": text,
        "expected": expected,
        "predicted": predicted,
        "confidence": confidence,
        "emoji": emoji,
        "pass": predicted == expected
    })

# Print results
for r in results:
    status = "βœ… PASS" if r["pass"] else "❌ FAIL"
    print(f"\nπŸ” {r['sentence']}")
    print(f"🎯 Expected: {r['expected']}")
    print(f"πŸ” Predicted: {r['predicted']} {r['emoji']} (Confidence: {r['confidence']:.4f})")
    print(status)

# Summary
pass_count = sum(r["pass"] for r in results)
print(f"\n🎯 Total Passed: {pass_count}/{len(tests)}")
```

### Sample Results (Hypothetical)
- **Sentence**: I love you so much!  
  **Expected**: Love  
  **Predicted**: Love ❀️ (Confidence: 0.8442)  
  **Result**: βœ… PASS
- **Sentence**: I feel so alone right now.  
  **Expected**: Sadness  
  **Predicted**: Sadness 😒 (Confidence: 0.7913)  
  **Result**: βœ… PASS
- **Total Passed**: ~11/13 (depends on fine-tuning).

BERT-Emotion excels in classifying a wide range of emotions in short texts, particularly in IoT and social media contexts. Fine-tuning can further improve performance on nuanced emotions like Shame or Sarcasm.

## Evaluation Metrics

| Metric     | Value (Approx.)       |
|------------|-----------------------|
| βœ… Accuracy | ~90–95% on 13-class emotion tasks |
| 🎯 F1 Score | Balanced for multi-class classification |
| ⚑ Latency  | <45ms on Raspberry Pi |
| πŸ“ Recall   | Competitive for lightweight models |

*Note*: Metrics vary based on hardware (e.g., Raspberry Pi 4, Android devices) and fine-tuning. Test on your target device for accurate results.

## Use Cases

BERT-Emotion is designed for **edge and IoT scenarios** requiring real-time emotion detection for short texts. Key applications include:

- **Chatbot Emotion Understanding**: Detect user emotions, e.g., β€œI love you” (predicts β€œLove ❀️”) to personalize responses.
- **Social Media Sentiment Tagging**: Analyze posts, e.g., β€œThis is disgusting!” (predicts β€œDisgust πŸ€’β€) for content moderation.
- **Mental Health Context Detection**: Monitor user mood, e.g., β€œI feel so alone” (predicts β€œSadness πŸ˜’β€) for wellness apps.
- **Smart Replies and Reactions**: Suggest replies based on emotions, e.g., β€œI’m so happy!” (predicts β€œHappiness πŸ˜„β€) for positive emojis.
- **Emotional Tone Analysis**: Adjust IoT device settings, e.g., β€œI’m terrified!” (predicts β€œFear πŸ˜±β€) to dim lights for comfort.
- **Voice Assistants**: Local emotion-aware parsing, e.g., β€œWhy does it break?” (predicts β€œAnger πŸ˜ β€) to prioritize fixes.
- **Toy Robotics**: Emotion-driven interactions, e.g., β€œI really want that!” (predicts β€œDesire πŸ”₯”) for engaging animations.
- **Fitness Trackers**: Analyze feedback, e.g., β€œWait, what?” (predicts β€œConfusion πŸ˜•β€) to clarify instructions.

## Hardware Requirements

- **Processors**: CPUs, mobile NPUs, or microcontrollers (e.g., ESP32-S3, Raspberry Pi 4)
- **Storage**: ~20MB for model weights (quantized, Safetensors format)
- **Memory**: ~60MB RAM for inference
- **Environment**: Offline or low-connectivity settings

Quantization ensures efficient memory usage, making it suitable for resource-constrained devices.

## Trained On

- **Custom Emotion Dataset**: Curated short-text data with 13 labeled emotions (e.g., Happiness, Sadness, Love), sourced from custom datasets and chatgpt-datasets. Augmented with social media and IoT user feedback to enhance performance in chatbot, social media, and smart device contexts.

Fine-tuning on domain-specific data is recommended for optimal results.

## Fine-Tuning Guide

To adapt BERT-Emotion for custom emotion detection tasks (e.g., specific chatbot or IoT interactions):

1. **Prepare Dataset**: Collect labeled data with 13 emotion categories.
2. **Fine-Tune with Hugging Face**:
   ```python
    # !pip install transformers datasets torch --upgrade

    import torch
    from transformers import BertTokenizer, BertForSequenceClassification, Trainer, TrainingArguments
    from datasets import Dataset
    import pandas as pd

    # 1. Prepare the sample emotion dataset
    data = {
        "text": [
            "I love you so much!",
            "This is absolutely disgusting!",
            "I'm so happy with my new phone!",
            "Why does this always break?",
            "I feel so alone right now."
        ],
        "label": [2, 7, 5, 1, 0]  # Emotions: 0 to 12
    }
    df = pd.DataFrame(data)
    dataset = Dataset.from_pandas(df)

    # 2. Load tokenizer and model
    model_name = "boltuix/bert-emotion"
    tokenizer = BertTokenizer.from_pretrained(model_name)
    model = BertForSequenceClassification.from_pretrained(model_name, num_labels=13)

    # 3. Tokenize the dataset
    def tokenize_function(examples):
        return tokenizer(examples["text"], padding="max_length", truncation=True, max_length=64)

    tokenized_dataset = dataset.map(tokenize_function, batched=True)

    # 4. Manually convert all fields to PyTorch tensors (NumPy 2.0 safe)
    def to_torch_format(example):
        return {
            "input_ids": torch.tensor(example["input_ids"]),
            "attention_mask": torch.tensor(example["attention_mask"]),
            "label": torch.tensor(example["label"])
        }

    tokenized_dataset = tokenized_dataset.map(to_torch_format)

    # 5. Define training arguments
    training_args = TrainingArguments(
        output_dir="./bert_emotion_results",
        num_train_epochs=5,
        per_device_train_batch_size=2,
        logging_dir="./bert_emotion_logs",
        logging_steps=10,
        save_steps=100,
        eval_strategy="no",
        learning_rate=3e-5,
        report_to="none"  # Disable W&B auto-logging if not needed
    )

    # 6. Initialize Trainer
    trainer = Trainer(
        model=model,
        args=training_args,
        train_dataset=tokenized_dataset,
    )

    # 7. Fine-tune the model
    trainer.train()

    # 8. Save the fine-tuned model
    model.save_pretrained("./fine_tuned_bert_emotion")
    tokenizer.save_pretrained("./fine_tuned_bert_emotion")

    # 9. Example inference
    text = "I'm thrilled with the update!"
    inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=64)
    model.eval()
    with torch.no_grad():
        outputs = model(**inputs)
        logits = outputs.logits
        predicted_class = torch.argmax(logits, dim=1).item()

    labels = ["Sadness", "Anger", "Love", "Surprise", "Fear", "Happiness", "Neutral", "Disgust", "Shame", "Guilt", "Confusion", "Desire", "Sarcasm"]
    print(f"Predicted emotion for '{text}': {labels[predicted_class]}")
   ```
3. **Deploy**: Export the fine-tuned model to ONNX or TensorFlow Lite for edge devices.

## Comparison to Other Models

| Model           | Parameters | Size   | Edge/IoT Focus | Tasks Supported                     |
|-----------------|------------|--------|----------------|-------------------------------------|
| BERT-Emotion    | ~6M        | ~20MB  | High           | Emotion Detection, Classification   |
| BERT-Lite       | ~2M        | ~10MB  | High           | MLM, NER, Classification            |
| NeuroBERT-Mini  | ~7M        | ~35MB  | High           | MLM, NER, Classification            |
| DistilBERT      | ~66M       | ~200MB | Moderate       | MLM, NER, Classification, Sentiment |

BERT-Emotion is specialized for 13-class emotion detection, offering superior performance for short-text sentiment analysis on edge devices compared to general-purpose models like BERT-Lite, while being significantly more efficient than DistilBERT.



# Emotion Classification Models Comparison Report

This report summarizes the evaluation results of various emotion classification models, including accuracy, F1 score, model size, and download links.

---

## Summary Table

| Model                                          | Accuracy | F1 Score | Size (MB) | Download URL                                         |
|------------------------------------------------|---------:|---------:|----------:|:----------------------------------------------------|
| boltuix/bert-emotion                           |     1.00 |     1.00 |     42.89 | [Link](https://huggingface.co/boltuix/bert-emotion)|
| bhadresh-savani/bert-base-uncased-emotion      |     0.80 |     0.73 |    418.35 | [Link](https://huggingface.co/bhadresh-savani/bert-base-uncased-emotion)     |
| ayoubkirouane/BERT-Emotions-Classifier         |     0.80 |     0.73 |    418.64 | [Link](https://huggingface.co/ayoubkirouane/BERT-Emotions-Classifier)         |
| nateraw/bert-base-uncased-emotion              |     0.80 |     0.73 |    417.97 | [Link](https://huggingface.co/nateraw/bert-base-uncased-emotion)              |
| j-hartmann/emotion-english-distilroberta-base  |     0.80 |     0.73 |    315.82 | [Link](https://huggingface.co/j-hartmann/emotion-english-distilroberta-base) |
| mrm8488/t5-base-finetuned-emotion              |     0.20 |     0.07 |    851.14 | [Link](https://huggingface.co/mrm8488/t5-base-finetuned-emotion)               |

---

## Best Model

πŸ† **Name:** boltuix/bert-emotion  
**Accuracy:** 1.00  
**F1 Score:** 1.00  
**Size (MB):** 42.89  
**Download URL:** [https://huggingface.co/boltuix/bert-emotion](https://huggingface.co/boltuix/bert-emotion)

---

## Notes

- Very long sentences failed all the models; improvements needed.
- Model sizes are approximate based on repository file sizes.
- Accuracy and F1 scores are computed on a custom test dataset containing both short and long sentences per emotion.
- F1 Score is the weighted average.
- For more details, see the evaluation script or contact the report maintainer.

---

## Model Variants

BoltUIX offers a range of BERT-based models tailored to different performance and resource requirements. The `boltuix/bert-mobile` model is optimized for mobile and edge devices, offering strong performance with the ability to quantize to ~25 MB without significant loss. Below is a summary of available models:

| Tier       | Model ID                | Size (MB) | Notes                                              |
|------------|-------------------------|-----------|----------------------------------------------------|
| Micro      | boltuix/bert-micro      | ~15 MB    | Smallest, blazing-fast, moderate accuracy          |
| Mini       | boltuix/bert-mini       | ~17 MB    | Ultra-compact, fast, slightly better accuracy      |
| Tinyplus   | boltuix/bert-tinyplus   | ~20 MB    | Slightly bigger, better capacity                  |
| Small      | boltuix/bert-small      | ~45 MB    | Good compact/accuracy balance                     |
| Mid        | boltuix/bert-mid        | ~50 MB    | Well-rounded mid-tier performance                 |
| Medium     | boltuix/bert-medium     | ~160 MB   | Strong general-purpose model                      |
| Large      | boltuix/bert-large      | ~365 MB   | Top performer below full-BERT                     |
| Pro        | boltuix/bert-pro        | ~420 MB   | Use only if max accuracy is mandatory             |
| Mobile     | boltuix/bert-mobile     | ~140 MB   | Mobile-optimized; quantize to ~25 MB with no major loss |

For more details on each variant, visit the [BoltUIX Model Hub](https://huggingface.co/boltuix).


## Tags

`#BERT-Emotion` `#edge-nlp` `#emotion-detection` `#on-device-ai` `#offline-nlp`  
`#mobile-ai` `#sentiment-analysis` `#text-classification` `#emojis` `#emotions`  
`#lightweight-transformers` `#embedded-nlp` `#smart-device-ai` `#low-latency-models`  
`#ai-for-iot` `#efficient-bert` `#nlp2025` `#context-aware` `#edge-ml`  
`#smart-home-ai` `#emotion-aware` `#voice-ai` `#eco-ai` `#chatbot` `#social-media`  
`#mental-health` `#short-text` `#smart-replies` `#tone-analysis`

## License

**Apache-2.0 License**: Free to use, modify, and distribute for personal and commercial purposes. See [LICENSE](https://www.apache.org/licenses/LICENSE-2.0) for details.

## Credits

- **Base Models**: [boltuix/bert-mini](https://huggingface.co/boltuix/bert-mini), [boltuix/bert-mini]
- **Optimized By**: Boltuix, fine-tuned and quantized for edge AI applications
- **Library**: Hugging Face `transformers` team for model hosting and tools

## Support & Community

For issues, questions, or contributions:
- Visit the [Hugging Face model page](https://huggingface.co/boltuix/bert-emotion)
- Open an issue on the [repository](https://huggingface.co/boltuix/bert-emotion)
- Join discussions on Hugging Face or contribute via pull requests
- Check the [Transformers documentation](https://huggingface.co/docs/transformers) for guidance


Train Your Own Emotion Detection AI in Minutes! | NeuroFeel + NeuroBERT | Hugging Face Tutorial
- Check this :  [Video documentation](https://youtu.be/FccGKE1kV4Q) [to train own model](https://www.boltuix.com/2021/03/revolutionizing-nlp-deep-dive-into-bert.html)


We welcome community feedback to enhance BERT-Emotion for IoT and edge applications!

## Contact

- πŸ“¬ Email: [boltuix@gmail.com](mailto:boltuix@gmail.com)