EMOTIONVERSE-2 / README.md
ayjays132's picture
Update README.md
39a8cda verified
metadata
license: apache-2.0
language:
  - en
pipeline_tag: text-classification
library_name: transformers
tags:
  - emotions
  - multi-task-learning
  - text-classification
  - sentiment-analysis
  - natural-language-processing
  - psychological-modeling
  - emotion-recognition
  - bert
  - deep-learning
  - emotion-embeddings
  - valence-arousal
  - emotion-ontology

🌌 EmotionVerse-2: Galactic Emotional Intelligence

Apache-2.0 BERT-base encoder Multi-Task (6 heads) Plutchik + Circumplex F1 Macro: 0.951 Coherence Index: 0.97 HF Transformers

EmotionVerse-2 unifies psychologically-grounded labeling (Plutchik) with a valence-arousal manifold, neural plasticity, and memory consolidation. It doesn’t just tag text—it resolves why it feels the way it does, across interlocking tasks that share a single encoder for maximal transfer.

✨ Revolutionary Emotional Paradigm

A single BERT encoder feeds six specialized heads—Primary, Secondary, Meta, Sentiment, Interaction, and Context—trained end-to-end with dynamic loss weighting. The result is emergent cross-task awareness: subtle shifts, mixed feelings, and psychologically consistent outputs.

  • 🚀 Unified Multi-Task Engine. One encoder; six heads. Joint optimization learns shared affective features while preserving task-specific finesse.
  • 🧬 Plutchik × Russell Fusion. Labels live in a combined categorical + circumplex space (valence, arousal, intensity), preserving family hierarchies and psychological distances.
  • 🔗 Adaptive Loss Balancing. Dynamic task weights + focal components lift rare emotions without destabilizing common ones.
  • 📊 Holistic Metrics. Per-task precision/recall/F1 plus a cross-task Emotion Coherence Index (valence-arousal similarity across heads).
View architecture diagram (SVG)
BERT Encoder w/ Circumplex Injector Neural Plasticity Gate GRU Memory Consolidator Primary Secondary Meta Sentiment Interaction Context

🏆 Grand Performance Showcase

The evaluation deliberately pits generalist GoEmotions models against a specialist trained on Plutchik’s eight core emotions. The “unfairness” is instructive: it exposes the cost of vocabulary mismatch and the power of a psychologically aligned label space.

🧠 Emotional Lexicons: Why Translation Fails

  • Missing Concepts. GoEmotions lacks dedicated pathways for Plutchik categories like Trust or Anticipation as defined here.
  • Forced Guesses. Inputs such as “I have complete faith in your plan” map to “Approval/Admiration,” not “Trust.” Close ≠ correct when precision matters.
  • Semantic Misalignment. The learned geometry of the label space differs; a round peg in a square hole.
ModelF1 Macro
EMOTIONVERSE-20.951 🌟
GoEmotions-RoBERTa0.024 🔻
GoEmotions-BERT0.012 📉
DistilBERT-Emotion0.007 👻
F1 Macro scores: EmotionVerse-2 0.951, GoEmotions-RoBERTa 0.024, GoEmotions-BERT 0.012, DistilBERT-Emotion 0.007 0.0 0.25 0.50 1.00 EmotionVerse-2 0.951 GoEmotions-RoBERTa 0.024 GoEmotions-BERT 0.012 DistilBERT-Emotion 0.007

💎 Nearly-Perfect Diagonal (Confusion Matrix)

Diagonal dominance indicates surgical separation of Plutchik classes; off-diagonals remain low and psychologically adjacent when present.

Predicted → Actual ↓ JoyTrustAntic.Surpr.AngerSad.FearDisg. JoyTrustAntic.Surpr.AngerSad.FearDisg.
Cross-task capability radar (SVG)
Precision Recall F1 Coherence Stability

🔬 Architecture & Emotional Data Synthesis

Core Modules

  • Neural Plasticity Gate. Reweights hidden states conditioned on intensity and local valence/arousal; supports context-sensitive adaptation.
  • Amygdala-Inspired Intensifier. Saturating non-linearity emphasizes high-arousal signals without drowning low-arousal nuance.
  • GRU Memory Consolidator. Injects sequential emotional context to stabilize predictions across turns or sentences.
  • Circumplex Injector. Concatenates/merges valence-arousal (+ intensity) vectors into token-level or pooled embeddings.

Training Setup

  • Backbone: BERT-base uncased.
  • Optimization: AdamW, linear warmup/decay, mixed precision.
  • Loss: Weighted sum across heads with dynamic task weights; focal term for rare labels; label smoothing for stability.
  • Regularization: Dropout, stochastic depth on head adapters (if enabled), gradient clipping.

🚀 Psychologically-Informed Embeddings

Emotion labels are embedded vectors, not IDs. Selected dimensions:

  • Valence/Arousal Anchors. First two dims: positivity/negativity and activation.
  • Intensity Signal. Third dim calibrated from dataset statistics.
  • Family Centroids. Pull toward Plutchik family centers to preserve conceptual proximity.
  • Relationship Pull. Secondary affinities (e.g., Joy↔Anticipation) maintain a smooth manifold.

📊 Evaluation & Performance Horizons

  • Primary Head: Accuracy, Top-2 recall.
  • Secondary & Meta: Macro/Weighted F1.
  • Interaction & Context: Precision/Recall for communicative style cues.
  • Sentiment: Mixed-class accuracy with polarity overlap analysis.
  • Emotion Coherence Index: Cross-head valence/arousal agreement.

🛠️ Usage & Integration

Quickstart (Transformers)
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

name = "ayjays132/EmotionVerse-2" tok = AutoTokenizer.from_pretrained(name) mdl = AutoModelForSequenceClassification.from_pretrained(name)

text = "I’m thrilled yet anxious about tomorrow’s launch." batch = tok(text, return_tensors="pt", truncation=True, padding=True) with torch.no_grad(): out = mdl(**batch)

Example: Plutchik mapping & softmax
import torch.nn.functional as F

plutchik_labels = ["joy","trust","anticipation","surprise","anger","sadness","fear","disgust"] plutchik_logits = out.logits[:, :len(plutchik_labels)] # slice depends on export probs = F.softmax(plutchik_logits, dim=-1)[0].tolist()

for lbl, p in sorted(zip(plutchik_labels, probs), key=lambda x: -x[1]): print(f"{lbl:12s} {p:.3f}")

Batch inference with coherence check
def coherence(valence_arousal_primary, valence_arousal_sentiment):
    # cosine similarity across valence/arousal heads
    a, b = valence_arousal_primary, valence_arousal_sentiment
    return (a @ b) / ((a.norm()+1e-8) * (b.norm()+1e-8))

📂 EmotionVerse Dataset: Cosmic Fuel

The EmotionVerse dataset anchors this model with 3K+ entries annotated across six dimensions, including meta-emotional and contextual narratives.

📚 Reproducibility Snippets

Minimal training loop sketch
from torch.optim import AdamW
from torch.cuda.amp import autocast, GradScaler

scaler = GradScaler() optim = AdamW(mdl.parameters(), lr=3e-5, weight_decay=0.01)

for step, batch in enumerate(train_loader): with autocast(): out = mdl(**{k:v.to(mdl.device) for k,v in batch.items()}) # combine task losses (weights dynamically updated) loss = out.loss # if model returns weighted sum scaler.scale(loss).backward() scaler.step(optim); scaler.update(); optim.zero_grad()

Evaluation (macro F1) sketch
from sklearn.metrics import f1_score

  all_y, all_p = [], []

for batch in val_loader: with torch.no_grad(): out = mdl(**{k:v.to(mdl.device) for k,v in batch.items()}) logits = out.logits[:, :8] # primary head slice preds = logits.argmax(-1).cpu().tolist() all_p += preds; all_y += batch["labels"].tolist()

print("F1 Macro:", f1_score(all_y, all_p, average="macro"))

📜 Licensing

Released under the Apache 2.0 License. Use, modify, and ship with confidence.

🙏 Acknowledgements

Thanks to Hugging Face (transformers, datasets) and the research community advancing affective computing, psychological modeling, and trustworthy NLP.