Improving the Generalizability of Text-Based Emotion Detection by Leveraging Transformers with Psycholinguistic Features

Sourabh Zanwar, Daniel Wiechmann, Yu Qiao, Elma Kerz

Abstract

In recent years, there has been increased interest in building predictive models that harness natural language processing and machine learning techniques to detect emotions from various text sources, including social media posts, micro-blogs or news articles. Yet, deployment of such models in real-world sentiment and emotion applications faces challenges, in particular poor out-of-domain generalizability. This is likely due to domain-specific differences (e.g., topics, communicative goals, and annotation schemes) that make transfer between different models of emotion recognition difficult. In this work we propose approaches for text-based emotion detection that leverage transformer models (BERT and RoBERTa) in combination with Bidirectional Long Short-Term Memory (BiLSTM) networks trained on a comprehensive set of psycholinguistic features. First, we evaluate the performance of our models within-domain on two benchmark datasets GoEmotion (Demszky et al., 2020) and ISEAR (Scherer and Wallbott, 1994). Second, we conduct transfer learning experiments on six datasets from the Unified Emotion Dataset (Bostan and Klinger, 2018) to evaluate their out-of-domain robustness. We find that the proposed hybrid models improve the ability to generalize to out-of-distribution data compared to a standard transformer-based approach. Moreover, we observe that these models perform competitively on in-domain data.

Introduction

Text-Based Emotion Detection (TBED) is a critical component for developing emotionally intelligent systems, such as empathetic chatbots and mental health monitoring tools. While Transformer-based models like BERT and RoBERTa have set new benchmarks for accuracy, they often suffer from a "generalizability gap." A model optimized for Reddit comments often fails when applied to news headlines or personal diaries because deep learning models tend to overfit to domain-specific lexical quirks and annotation schemes. To achieve real-world utility, TBED models must move beyond simple vocabulary memorization toward an understanding of the underlying linguistic structures of human emotional expression.

Methodology

The researchers propose a hybrid architecture designed to merge contextual semantic intelligence with structural linguistic patterns. The system consists of two primary branches:

  1. Semantic Context Branch: Utilizes pre-trained BERT and RoBERTa models to capture deep, contextual word meanings.
  2. Psycholinguistic Branch: Extracts 435 features using an Automated Text Analysis (ATA) system. These features are categorized into four groups: morpho-syntactic complexity, lexical richness/sophistication, readability (e.g., SMOG index), and lexicon-based sentiment associations.

The integration of these branches is achieved by feeding the sequence of psycholinguistic features into a Bidirectional LSTM (BiLSTM). This allows the model to capture the structural flow and complexity of the text. The output of the BiLSTM is then concatenated with the Transformer's output before passing through final classification layers.

The proposed hybrid architecture combining Transformer-based semantic features with BiLSTM-processed psycholinguistic features.

Experimental Setup

The study evaluated performance across a wide range of datasets to measure both "within-domain" and "out-of-domain" robustness:

  • Primary Benchmarks: GoEmotions (58k Reddit comments) and ISEAR (3k personal reports).
  • Generalizability Testing: Six datasets from the Unified Emotion Dataset, including TEC (Twitter), CrowdFlower, Electoral-Tweets, SSEC, Emotion-Stimulus, and ISEAR_UED.

Results and Discussion

The hybrid models demonstrated significant improvements in robustness without sacrificing in-domain performance.

In-Domain Performance

On the GoEmotions dataset, the hybrid RoBERTa+PsyLing model achieved a macro-F1 of 71%, outperforming the standard RoBERTa baseline (69%) and significantly exceeding previous benchmarks (61.1%).

Out-of-Domain Generalizability

The hybrid approach's primary strength lies in its transfer learning capabilities. By incorporating psycholinguistic features—which are more stable across domains than raw vocabulary—the models maintained higher performance when tested on unfamiliar data. For example, on the affect-text dataset, the hybrid model showed marked improvements over standard Transformer approaches.

Transfer learning performance across various datasets, demonstrating the superior generalizability of the hybrid BERT+PsyLing and RoBERTa+PsyLing models.

Conclusion

This research highlights that psycholinguistic features are not merely redundant but provide a structural signal that complements the semantic power of Transformers. By forcing the model to consider linguistic complexity and readability, the authors provide a "universal anchor" for emotion detection. Future work will explore extending this framework to dimensional emotion models (Valence, Arousal, Dominance) and multi-task learning to further enhance granular insights and robustness.

Summary updated

Abstract

recent years, there has been increased interest in building predictive models that harness natural language processing and machine learning techniques to detect emotions from various text sources, including social media posts, micro-blogs or news articles. Yet, deployment of such models in real-world sentiment and emotion applications faces challenges, in particular poor out-of-domain generalizability. This is likely due to domain-specific differences (e.g., topics, communicative goals, and annotation schemes) that make transfer between different models of emotion recognition difficult. In this work we propose approaches for text-based emotion detection that leverage transformer models (BERT and RoBERTa) in combination with Bidirectional Long Short-Term Memory (BiLSTM) networks trained on a comprehensive set of psycholinguistic features. First, we evaluate the performance of our models within-domain on two benchmark datasets GoEmotion (Demszky et al., 2020) and ISEAR (Scherer and Wallbott, 1994). Second, we conduct transfer learning experiments on six datasets from the Unified Emotion Dataset (Bostan and Klinger, 2018) to evaluate their out-of-domain robustness. We find that the proposed hybrid models improve the ability to generalize to out-of-distribution data compared to a standard transformer-based approach. Moreover, we observe that these models perform competitively on in-domain data.'
BibTeX
@misc{zanwar2022improving,
  author = {Sourabh Zanwar and Daniel Wiechmann and Yu Qiao and Elma Kerz},
  title = {{Improving the Generalizability of Text-Based Emotion Detection by Leveraging Transformers with Psycholinguistic Features}},
  year = {2022},
  eprint = {2212.09465},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.09465},
}
Figure