This research presents an explainable, low-latency framework for emotion detection in social media text using distilled transformer models DistilBERT, BERT, and RoBERTa combined with token-level interpretability via SHAP. Using the GoEmotions dataset filtered to six core emotions (joy, sadness, anger, fear, surprise, and disgust), the models were fine-tuned through Optuna-based hyperparameter optimization with stratified 80/10/10 data splits. The results demonstrate competitive macro-F1 performance (DistilBERT = 0.816, BERT = 0.806, RoBERTa = 0.825) while maintaining low overall processing latency for batch inference. Beyond classification, this study contributes an analysis of cross-model consistency and explainability: certain emotions such as joy were recognized consistently (100% agreement across models), whereas sadness and fear exhibited variation, reflecting linguistic and contextual differences in emotional expression. The SHAP-based explainability highlighted overlapping and divergent token contributions across models, exposing where algorithmic architecture and training data led to different interpretive outcomes. This work concludes that DistilBERT offers an optimal trade-off between accuracy, interpretability, and runtime cost, and that explainability disagreement among models can illuminate deeper semantic and cultural complexities in emotional language.
Najm et al. (Thu,) studied this question.