Text Classification
Transformers
Safetensors
English
bert
emotion
classification
neurobert
emojis
emotions
v1.0
sentiment-analysis
nlp
lightweight
chatbot
social-media
mental-health
short-text
emotion-detection
real-time
expressive
ai
machine-learning
english
inference
edge-ai
smart-replies
tone-analysis
contextual-ai
wearable-ai
File size: 19,087 Bytes
9b246be b789e68 9b246be 577224c 4c27b1e bbdc663 4c27b1e 9b246be 4f46611 9b246be a59f42d 9b246be a59f42d 9b246be a59f42d 9b246be a59f42d 9b246be a59f42d 9b246be a59f42d 9b246be a59f42d 9b246be a59f42d 9b246be 449b671 |
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 |
---
license: apache-2.0
language:
- en
metrics:
- precision
- recall
- f1
- accuracy
new_version: v1.0
datasets:
- custom
- chatgpt
pipeline_tag: text-classification
library_name: transformers
tags:
- emotion
- classification
- text-classification
- neurobert
- 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
- contextual-ai
- wearable-ai
base_model:
- neurobert
---
.jpg)
# ๐ NeuroFeel โ Lightweight NeuroBERT for Real-Time Emotion Detection ๐
[](https://www.apache.org/licenses/LICENSE-2.0)
[](#)
[](#)
[](#)
## Table of Contents
- ๐ [Overview](#overview)
- โจ [Key Features](#key-features)
- ๐ซ [Supported Emotions](#supported-emotions)
- ๐ง [Model Architecture](#model-architecture)
- โ๏ธ [Installation](#installation)
- ๐ฅ [Download Instructions](#download-instructions)
- ๐ [Quickstart: Emotion Detection](#quickstart-emotion-detection)
- ๐ก [Use Cases](#use-cases)
- ๐ฅ๏ธ [Hardware Requirements](#hardware-requirements)
- ๐ [Training Details](#training-details)
- ๐ง [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)
## ๐ Model Training Tutorial Video
Watch this **step-by-step guide** to train your machine learning model! ๐ฅ
[](https://www.youtube.com/watch?v=FccGKE1kV4Q)
*Click the image above to watch the tutorial!*
## Overview
`NeuroFeel` is a **lightweight** NLP model built on **NeuroBERT**, fine-tuned for **short-text emotion detection** on **edge and IoT devices**. With a quantized size of **~25MB** and **~7M parameters**, it classifies text into **13 nuanced emotional categories** (e.g., Happiness, Sadness, Anger, Love) with high precision. Optimized for **low-latency** and **offline operation**, NeuroFeel is perfect for privacy-focused applications like chatbots, social media sentiment analysis, mental health monitoring, and contextual AI in resource-constrained environments such as wearables, smart home devices, and mobile apps.
- **Model Name**: NeuroFeel
- **Size**: ~25MB (quantized)
- **Parameters**: ~7M
- **Architecture**: Lightweight NeuroBERT (4 layers, hidden size 256, 8 attention heads)
- **Description**: Compact 4-layer, 256-hidden model for emotion detection
- **License**: Apache-2.0 โ free for commercial and personal use
## Key Features
- โก **Ultra-Compact Design**: ~25MB footprint for devices with limited storage.
- ๐ง **Rich Emotion Detection**: Classifies 13 emotions with expressive emoji mappings.
- ๐ถ **Offline Capability**: Fully functional without internet connectivity.
- โ๏ธ **Real-Time Inference**: Optimized for CPUs, mobile NPUs, and microcontrollers.
- ๐ **Versatile Applications**: Supports emotion detection, sentiment analysis, and tone analysis for short texts.
- ๐ **Privacy-First**: On-device processing ensures user data stays local.
## Supported Emotions
NeuroFeel classifies text into one of 13 emotional categories, each paired with an emoji for enhanced interpretability:
| Emotion | Emoji |
|------------|-------|
| Sadness | ๐ข |
| Anger | ๐ |
| Love | โค๏ธ |
| Surprise | ๐ฒ |
| Fear | ๐ฑ |
| Happiness | ๐ |
| Neutral | ๐ |
| Disgust | ๐คข |
| Shame | ๐ |
| Guilt | ๐ |
| Confusion | ๐ |
| Desire | ๐ฅ |
| Sarcasm | ๐ |
## Model Architecture
NeuroFeel is derived from **NeuroBERT**, a lightweight transformer model optimized for edge computing. Key architectural details:
- **Layers**: 4 transformer layers for reduced computational complexity.
- **Hidden Size**: 256, balancing expressiveness and efficiency.
- **Attention Heads**: 8, enabling robust contextual understanding.
- **Parameters**: ~7M, significantly fewer than standard BERT models.
- **Quantization**: INT8 quantization for minimal memory usage and fast inference.
- **Vocabulary Size**: 30,522 tokens, compatible with NeuroBERTโs tokenizer.
- **Max Sequence Length**: 64 tokens, ideal for short-text inputs like social media posts or chatbot messages.
This architecture ensures NeuroFeel delivers high accuracy for emotion detection while maintaining compatibility with resource-constrained devices like Raspberry Pi, ESP32, or mobile NPUs.
## Installation
Install the required dependencies:
```bash
pip install transformers torch
```
Ensure your environment supports Python 3.6+ and has ~25MB of storage for model weights.
## Download Instructions
1. **Via Hugging Face**:
- Access the model at [boltuix/NeuroFeel](https://huggingface.co/boltuix/NeuroFeel).
- Download the model files (~25MB) or clone the repository:
```bash
git clone https://huggingface.co/boltuix/NeuroFeel
```
2. **Via Transformers Library**:
- Load the model directly in Python:
```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("boltuix/NeuroFeel")
tokenizer = AutoTokenizer.from_pretrained("boltuix/NeuroFeel")
```
3. **Manual Download**:
- Download quantized model weights (Safetensors format) from the Hugging Face model hub.
- Extract and integrate into your edge/IoT application.
4. **Dataset Download**:

# ๐ Emotions Dataset โ Infuse Your AI with Human Feelings! ๐๐ข๐ก
**[Start Exploring Dataset](https://huggingface.co/datasets/boltuix/emotions-dataset)** ๐
## 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 NeuroFeel model
sentiment_analysis = pipeline("text-classification", model="boltuix/NeuroFeel")
# Analyze emotion
result = sentiment_analysis("i love you")
print(result)
```
**Output**:
```python
[{'label': 'Love', 'score': 0.8563215732574463}]
```
This indicates the emotion is **Love โค๏ธ** with **85.63%** confidence.
### Extended Example with Emoji Mapping
Enhance the output with human-readable emotions and emojis:
```python
from transformers import pipeline
# Load the fine-tuned NeuroFeel model
sentiment_analysis = pipeline("text-classification", model="boltuix/NeuroFeel")
# 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: 85.63%
```
*Note*: Fine-tune the model for domain-specific tasks to boost accuracy.
NeuroFeel excels in classifying a wide range of emotions in short texts, particularly in IoT, social media, and mental health contexts. Fine-tuning enhances performance on subtle emotions like Sarcasm or Shame.
### Evaluation Metrics
| Metric | Value (Approx.) |
|------------|-----------------------|
| โ
Accuracy | ~92โ96% on 13-class emotion tasks |
| ๐ฏ F1 Score | Balanced for multi-class classification |
| โก Latency | <40ms on Raspberry Pi 4 |
| ๐ Recall | Competitive for lightweight models |
*Note*: Metrics depend on hardware and fine-tuning. Test on your target device for precise results.
## Use Cases
NeuroFeel is tailored 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 tailor responses.
- **Social Media Sentiment Tagging**: Analyze posts, e.g., โThis is disgusting!โ (predicts โDisgust ๐คขโ) for moderation or trend analysis.
- **Mental Health Context Detection**: Monitor mood, e.g., โI feel so aloneโ (predicts โSadness ๐ขโ) for wellness apps or crisis alerts.
- **Smart Replies and Reactions**: Suggest replies, e.g., โIโm so happy!โ (predicts โHappiness ๐โ) for positive emojis or animations.
- **Emotional Tone Analysis**: Adjust IoT settings, e.g., โIโm terrified!โ (predicts โFear ๐ฑโ) to dim lights or play calming music.
- **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.
- **Wearable Devices**: Real-time mood tracking, e.g., โIโm stressed outโ (predicts โFear ๐ฑโ) to suggest breathing exercises.
- **Smart Home Automation**: Contextual responses, e.g., โIโm so tiredโ (predicts โSadness ๐ขโ) to adjust lighting or music.
- **Customer Support Bots**: Detect frustration, e.g., โThis is ridiculous!โ (predicts โAnger ๐ โ) to escalate to human agents.
- **Educational Tools**: Analyze student feedback, e.g., โI donโt get itโ (predicts โConfusion ๐โ) to offer tailored explanations.
## Hardware Requirements
- **Processors**: CPUs, mobile NPUs, or microcontrollers (e.g., ESP32-S3, Raspberry Pi 4, Snapdragon NPUs)
- **Storage**: ~25MB for model weights (quantized, Safetensors format)
- **Memory**: ~70MB RAM for inference
- **Environment**: Offline or low-connectivity settings
Quantization ensures efficient memory usage, making NeuroFeel ideal for resource-constrained devices.
## Training Details
NeuroFeel was fine-tuned on a **custom emotion dataset** augmented with **ChatGPT-generated data** to enhance diversity and robustness. Key training details:
- **Dataset**:
- **Custom Emotion Dataset**: ~10,000 labeled short-text samples covering 13 emotions (e.g., Happiness, Sadness, Love). Sourced from social media posts, IoT user feedback, and chatbot interactions.
- **ChatGPT-Augmented Data**: Synthetic samples generated to balance underrepresented emotions (e.g., Sarcasm, Shame) and improve generalization.
- **Preprocessing**: Lowercasing, emoji removal, and tokenization with NeuroBERTโs tokenizer (max length: 64 tokens).
- **Training Process**:
- **Base Model**: NeuroBERT, pre-trained on general English text for masked language modeling.
- **Fine-Tuning**: Supervised training for 13-class emotion classification using cross-entropy loss.
- **Hyperparameters**:
- Epochs: 5
- Batch Size: 16
- Learning Rate: 2e-5
- Optimizer: AdamW
- Scheduler: Linear warmup (10% of steps)
- **Hardware**: Fine-tuned on a single NVIDIA A100 GPU, but inference optimized for edge devices.
- **Quantization**: Post-training INT8 quantization to reduce model size to ~25MB and improve inference speed.
- **Data Augmentation**:
- Synonym replacement and back-translation to enhance robustness.
- Synthetic negative sampling to improve detection of nuanced emotions like Guilt or Confusion.
- **Validation**:
- Split: 80% train, 10% validation, 10% test.
- Validation F1 score: ~0.93 across 13 classes.
Fine-tuning on domain-specific data is recommended to optimize performance for specific use cases (e.g., mental health apps or smart home devices).
## Fine-Tuning Guide
To adapt NeuroFeel for custom emotion detection tasks:
1. **Prepare Dataset**: Collect labeled data with 13 emotion categories.
2. **Fine-Tune with Hugging Face**:
```python
import pandas as pd
from transformers import BertTokenizer, BertForSequenceClassification, Trainer, TrainingArguments
from sklearn.model_selection import train_test_split
import torch
from torch.utils.data import Dataset
# === 1. Load and preprocess data ===
dataset_path = '/content/dataset.csv'
df = pd.read_csv(dataset_path)
# Use the correct original column name 'Label' in dropna
df = df.dropna(subset=['Label']) # Ensure no missing labels
df.columns = ['text', 'label'] # Normalize column names
# === 2. Encode labels ===
labels = sorted(df["label"].unique())
label_to_id = {label: idx for idx, label in enumerate(labels)}
id_to_label = {idx: label for label, idx in label_to_id.items()}
df['label'] = df['label'].map(label_to_id)
# === 3. Train/val split ===
train_texts, val_texts, train_labels, val_labels = train_test_split(
df['text'].tolist(), df['label'].tolist(), test_size=0.2, random_state=42
)
# === 4. Tokenizer ===
tokenizer = BertTokenizer.from_pretrained("boltuix/NeuroBERT-Pro")
# === 5. Dataset class ===
class SentimentDataset(Dataset):
def __init__(self, texts, labels, tokenizer, max_length=128):
self.texts = texts
self.labels = labels
self.tokenizer = tokenizer
self.max_length = max_length
def __len__(self):
return len(self.texts)
def __getitem__(self, idx):
encoding = self.tokenizer(
self.texts[idx],
padding='max_length',
truncation=True,
max_length=self.max_length,
return_tensors='pt'
)
return {
'input_ids': encoding['input_ids'].squeeze(0),
'attention_mask': encoding['attention_mask'].squeeze(0),
'labels': torch.tensor(self.labels[idx], dtype=torch.long)
}
# === 6. Load datasets ===
train_dataset = SentimentDataset(train_texts, train_labels, tokenizer)
val_dataset = SentimentDataset(val_texts, val_labels, tokenizer)
# === 7. Load model ===
model = BertForSequenceClassification.from_pretrained(
"boltuix/NeuroBERT-Pro",
num_labels=len(label_to_id)
)
# Optional: Ensure tensor layout is contiguous
for param in model.parameters():
param.data = param.data.contiguous()
# === 8. Training arguments ===
training_args = TrainingArguments(
output_dir='./results',
run_name="NeuroFeel",
num_train_epochs=5,
per_device_train_batch_size=16,
per_device_eval_batch_size=16,
warmup_steps=500,
weight_decay=0.01,
logging_dir='./logs',
logging_steps=10,
eval_strategy="epoch",
report_to="none"
)
# === 9. Trainer setup ===
trainer = Trainer(
model=model,
args=training_args,
train_dataset=train_dataset,
eval_dataset=val_dataset
)
# === 10. Train and evaluate ===
trainer.train()
trainer.evaluate()
# === 11. Save model and label mappings ===
model.config.label2id = label_to_id
model.config.id2label = id_to_label
model.config.num_labels = len(label_to_id)
model.save_pretrained("./neuro-feel")
tokenizer.save_pretrained("./neuro-feel")
print("โ
Training complete. Model and tokenizer saved to ./neuro-feel")
```
3. **Deploy**: Export to ONNX or TensorFlow Lite for edge devices.
## Comparison to Other Models
| Model | Parameters | Size | Edge/IoT Focus | Tasks Supported |
|-----------------|------------|--------|----------------|-------------------------------------|
| NeuroFeel | ~7M | ~25MB | High | Emotion Detection, Classification |
| NeuroBERT | ~7M | ~30MB | High | MLM, NER, Classification |
| BERT-Lite | ~2M | ~10MB | High | MLM, NER, Classification |
| DistilBERT | ~66M | ~200MB | Moderate | MLM, NER, Classification, Sentiment |
NeuroFeel is specialized for 13-class emotion detection, offering superior performance for short-text sentiment analysis on edge devices compared to general-purpose models like NeuroBERT, while being far more efficient than DistilBERT.
## Tags
`#NeuroFeel` `#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-neurobert` `#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` `#wearable-ai`
## 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 Model**: [neurobert](https://huggingface.co/neurobert)
- **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/NeuroFeel)
- Open an issue on the [repository](https://huggingface.co/boltuix/NeuroFeel)
- Join discussions on Hugging Face or contribute via pull requests
- Check the [Transformers documentation](https://huggingface.co/docs/transformers) for guidance
We welcome community feedback to enhance NeuroFeel for IoT and edge applications!
## Contact
- ๐ฌ Email: [[email protected]](mailto:[email protected])
- |