Watch this step-by-step guide to train your machine learning model! 🎥
Click the image above to watch the tutorial!
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.
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 | 😏 |
NeuroFeel is derived from NeuroBERT, a lightweight transformer model optimized for edge computing. Key architectural details:
This architecture ensures NeuroFeel delivers high accuracy for emotion detection while maintaining compatibility with resource-constrained devices like Raspberry Pi, ESP32, or mobile NPUs.
Install the required dependencies:
pip install transformers torch
Ensure your environment supports Python 3.6+ and has ~25MB of storage for model weights.
Via Hugging Face:
git clone https://huggingface.co/boltuix/NeuroFeel
Via Transformers Library:
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model = AutoModelForSequenceClassification.from_pretrained("boltuix/NeuroFeel")
tokenizer = AutoTokenizer.from_pretrained("boltuix/NeuroFeel")
Manual Download:
Dataset Download:
Classify emotions in short text inputs using the Hugging Face pipeline:
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:
[{'label': 'Love', 'score': 0.8563215732574463}]
This indicates the emotion is Love ❤️ with 85.63% confidence.
Enhance the output with human-readable emotions and emojis:
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:
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.
| 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.
NeuroFeel is tailored for edge and IoT scenarios requiring real-time emotion detection for short texts. Key applications include:
Quantization ensures efficient memory usage, making NeuroFeel ideal for resource-constrained devices.
NeuroFeel was fine-tuned on a custom emotion dataset augmented with ChatGPT-generated data to enhance diversity and robustness. Key training details:
Fine-tuning on domain-specific data is recommended to optimize performance for specific use cases (e.g., mental health apps or smart home devices).
To adapt NeuroFeel for custom emotion detection tasks:
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")
| 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.
#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
Apache-2.0 License: Free to use, modify, and distribute for personal and commercial purposes. See LICENSE for details.
transformers team for model hosting and toolsFor issues, questions, or contributions:
We welcome community feedback to enhance NeuroFeel for IoT and edge applications!