Predicting Emotion Intensity in Text Using Transformer-Based Models (2025)

Abstract: Emotion intensity prediction in text enhances conversational AI by enabling a deeper understanding of nuanced human emotions, a crucial yet underexplored aspect of natural language processing (NLP). This study employs Transformer-based models to classify emotion intensity levels (0–3) for five emotions: anger, fear, joy, sadness, and surprise. The dataset, sourced from the SemEval shared task, was preprocessed to address class imbalance, and model training was performed using fine-tuned *bert-base-uncased*. Evaluation metrics showed that *sadness* achieved the highest accuracy (0.8017) and F1-macro (0.5916), while *fear* had the lowest accuracy (0.5690) despite a competitive F1-macro (0.5207). The results demonstrate the potential of Transformer-based models in emotion intensity prediction while highlighting the need for further improvements in class balancing and contextual representation.

## introduction emotion analysis in natural language processing (nlp) has emerged as a pivotal area of study, driven by the need to enhance human machine interaction across domains such as affective computing, digital healthcare, and conversational ai. while sentiment analysis provides a coarse-grained understanding of text polarity positive, negative, or neutral emotion analysis demands a finer lens, capable of discerning nuanced states like joy, anger, or sadness, and even their intensity. transformerbased models, with their ability to capture contextual dependencies, have revolutionized nlp tasks, yet predicting emotion intensity in text remains a complex challenge. this complexity arises from the subtle interplay of linguistic cues, contextual dynamics, and the inherent unpredictability of human emotions, particularly when constrained to a single language like english, where cultural and expressive variations further enrich the task. recent advancements in transformer-based architectures have begun to address these challenges by integrating innovative approaches to emotion recognition @xcite @xcite . these studies underscore a growing trend: enhancing transformer models with specialized techniques from sensory integration to handling unbalanced datasets offers a promising pathway to deepen the understanding of emotional nuances in text, particularly within a monolingual framework. this research aims to build on these foundations by exploring how transformer-based models can be optimized to predict emotion intensity in english textual data. while prior work has advanced emotion classification, the specific focus on intensity quantifying the strength of emotions like mild annoyance versus intense anger remains underexplored, especially in single language settings. by examining the strengths and limitations of existing models and proposing refinements, this study seeks to contribute to the evolving landscape of emotional ai. the investigation not only aligns with the interdisciplinary bridge between nlp and cognitive science but also addresses practical applications, such as improving real-time conversational systems, where accurately gauging emotion intensity could transform user experiences. ## literature review text detection and classification has evolved significantly in recent years, attracting considerable attention from researchers in the field of natural language processing (nlp). various classifiers and models have been explored, with several new, more accurate models developed by researchers, playing pivotal roles in a series of recent experiments (see @xcite @xcite @xcite . a range of traditional machine learning (ml) methods @xcite @xcite as well as deep learning (dl) models @xcite @xcite @xcite have been applied in recent years for text prediction across various domains. in their study, @xcite introduce sen-soryt5, an innovative model that integrates sensory knowledge into the t5 (text-to-text transfer transformer) framework to enhance emotion classification in natural language processing (nlp). unlike traditional approaches that often overlook the interplay between sensory perception and emotion, sensoryt5 embeds sensory knowledge within the model's attention mechanism, elevating its sensitivity to the nuanced emotional states conveyed in text. the authors demonstrate that this approach significantly outperforms state-of-the-art baselines, achieving a maximal improvement of 3.0 in both accuracy and f1 score across four emotion classification datasets. this advancement highlights the potential of leveraging neuro-cognitive resources, such as the intimate relationship between emotion and sensory experiences well documented in overlapping neural regions like the amygdala @xcite deepen the comprehension of emotional intensity and nuance in transformer-based models, suggesting a promising interdisciplinary bridge between nlp and cognitive science. pereira et al., 2024 provide a comprehensive survey on deep emotion recognition in conversations (erc), underscoring its critical role in advancing human-machine interaction through the lens of textual conversations. the authors highlight how recent progress in erc has unveiled both opportunities and challenges, such as capturing conversational context, modeling speaker and emotion dynamics, and interpreting informal language or sarcasm-elements vital for predicting emotion intensity in text. their review details prominent approaches leveraging pre-trained transformer language models to extract utterance representations, often combined with gated and graph neural networks to model inter-utterance interactions, achieving robust performance across benchmark datasets with diverse emotion taxonomies. notably, the survey emphasizes the efficacy of employing transformer-based architectures. @xcite propose a novel fuzzy multimodal transformer (fmmt) model designed to advance personalized emotion analysis by ad-dressing the limitations of existing state-of-theart transformer-based approaches in capturing the complexity and unpredictability of human emotions. unlike conventional models that struggle with intricate contextual semantics and input interdependencies, fmmt integrates audio, visual, and textual data through three specialized branches, enhancing its comprehension of emotional contexts within a single language framework. by incorporating fuzzy mathematical theory and a unique temporal embedding technique, the model effectively traces the evolution of emotional states and manages inherent uncertainties, offering a significant leap in emotion intensity prediction. experimental results demonstrate that fmmt outperforms baseline methods, with detailed performance comparisons and ablation studies validating its robustness. cross-linguistic speech emotion recognition (ser) has gained significant attention due to its wide range of applications. previous studies have primarily focused on adapting features, domains, and labels across languages while often overlooking underlying linguistic commonalities. recent work, such as phonetically-anchored domain adaptation for cross-lingual speech emotion recognition sultana et al., 2025, explores vowelphonetic constraints as anchors to enhance crosslingual ser. inspired by this, transformer-based models offer a promising alternative by leveraging self-attention mechanisms to capture deep contextual relationships in speech. this study builds on prior research by integrating transformer architectures for multi-class emotion detection, enhancing language adaptation with minimal supervision 3 methodology our study employs a systematic methodology to predict emotion intensity in english text using transformer-based models, focusing on a dataset comprising training, development, and test splits sourced from the dataset released by the task organizers muhammad et al., 2025b. the dataset contains textual samples annotated with intensity levels '0 to 3' for five emotions-anger, fear, joy, sadness, and surprise, the preview of the representation of the dataset per emotion and classes is displayed in the evaluation and optimization process involved iterative refinement to ensure robust performance. the development set served as a validation split to tune hyperparameters and assess model generalization, with sample predictions like "older sister. . . scumbag stacy" predicted as @xmath0, @xmath1. test predictions were finalized using the best-performing multiclass models, maintaining consistency with the single-language 'english' focus. all code was implemented in python using libraries like pandas, transformers, and scikit-learn, with results saved for subsequent analysis. ## result and discussion the implementation of the bert-based multi-class classification models yielded promising results in predicting emotion intensity across the five target emotions-anger, fear, joy, sadness, and surprisein english text. evaluation on the test set revealed varying performance, with anger achieving the highest accuracy 0.8403 and macro f1 score 0.3715, while fear showed the lowest accuracy 0.5876 despite a competitive f1 macro 0.5387, the full result displayed in these results underscore both the strengths and limitations of the transformer-based approach in this context. the superior performance on sadness and surprise f1 @xmath2.6614 for surprise) aligns with findings from zhao et al., 2024, who enhanced emotion classification through sensory integration. however, the lower performance on fear and joy, particularly for higher intensity levels, may stem from their underrepresentation in the training data, a challenge also noted by pereira et al., 2024 in handling unbalanced erc datasets. the multi-label experiment with bert-base-cased and optimized thresholds offered an alternative perspective, but its binary focus diverged from the study's intensity prediction goal, reinforcing the multi-class framework's relevance. future iterations could explore liu et al., 2024 fuzzy logic or hybrid architectures to better handle uncertainty and class imbalance, which can potentially elevate overall f1 scores. ## conclusion this study successfully demonstrated the application of bert model, in predicting emotion intensity in english text, achieving notable accuracy and f1 scores across a range of emotions while highlighting areas for refinement. we carried out experiment on some other ml classifiers like svm, lr but reported bert in the competition as it performed better on the development dataset, the methodology addressed data imbalance and contextual complexity, aligning with trends in advanced emotion analysis @xcite . the results, with sadness and surprise outperforming fear and joy, validate the potential of fine-tuned bert models for nuanced nlp tasks, offering practical implications for enhancing conversational ai systems where understanding emotional depth is critical. the generated predictions on the test set further affirm the approach's applicability, providing a foundation for real-time emotion intensity detection in single-language settings. nevertheless, the research also reveals limitations that pave the way for future exploration. the persistent challenge of minority class prediction, despite class weighting, suggests that additional techniques-such as data augmentation, ensemble methods, or @xcite fuzzy multi-modal strategies-could enhance performance, particularly for underrepresented intensity levels. this work contributes to the evolving intersection of nlp and cognitive science, echoing the interdisciplinary call from prior studies, and sets a baseline for extending intensity prediction to multilingual contexts or integrating multimodal inputs. ultimately, refining these models could bridge the gap between machine understanding and human emotional expression, advancing both theoretical and applied dimensions of emotional ai.