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 and ISEAR. Second, we conduct transfer learning experiments on six datasets from the Unified Emotion Dataset 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 of sentiment analysis, with applications ranging from healthcare chatbots to financial market prediction. Despite the success of state-of-the-art Transformer models like BERT and RoBERTa, these systems often struggle with "generalizability." A model trained on Reddit comments (e.g., GoEmotions) frequently fails when applied to news headlines or personal diaries due to shifts in vocabulary, communicative intent, and annotation styles.

While Transformers excel at capturing semantic meaning ("what" is said), they can be brittle when data distributions shift. This paper proposes that psycholinguistic features—measuring stylistic elements like sentence complexity, lexical diversity, and readability—can serve as a stable "linguistic anchor." By integrating these features, we aim to capture "how" emotions are expressed, which tends to be more consistent across different domains.

Methodology: Fusing Semantics and Stylistics

The core contribution of this work is a hybrid architecture that fuses two distinct streams of linguistic information.

1. The Transformer Stream

We utilize pre-trained BERT-base and RoBERTa-base models to extract semantic features. Rather than relying solely on a final classification layer, the transformer outputs are passed through a Bidirectional Long Short-Term Memory (BiLSTM) network. This allows the model to better capture sequence-level information and temporal dependencies within the text.

2. The Psycholinguistic (PsyLing) Stream

Simultaneously, we extract 435 psycholinguistic features using an automated text analysis system. These features are categorized into four primary groups:

  • Morpho-syntactic complexity: Including average clause length and frequency of embeddings.
  • Lexical richness and sophistication: Measuring vocabulary range and use of advanced terminology.
  • Readability: Utilizing established metrics like the Fry index and SMOG.
  • Lexicon-based features: Affect scores derived from ten dictionaries, such as LIWC and ANEW.

3. Hybrid Fusion

As shown in the architecture diagram below, the 435 features are processed by a dedicated 2-layer BiLSTM. The resulting 256-dimensional vector is concatenated with the output from the transformer stream and fed into a final fully connected (FC) layer for classification.

The proposed hybrid architecture fusing a pre-trained language model with a psycholinguistic feature stream.

Experimental Setup

We evaluated our models using eight datasets to test both within-domain and out-of-domain performance:

  • In-Domain Benchmarks: GoEmotions (58k Reddit comments) and ISEAR (7.6k personal reports).
  • Transfer Learning: Six diverse datasets from the Unified Emotion Dataset, including news headlines (AffectiveText), tweets (CrowdFlower, TEC, Electoral-Tweets), and personal reports (SSEC, Emotion-Stimulus).

Results and Analysis

Our experiments demonstrate that the hybrid approach consistently outperforms standalone Transformer models, particularly in terms of robustness.

In-Domain Performance

On the GoEmotions dataset, the hybrid RoBERTa+PsyLing model achieved a macro-F1 score of 71%, surpassing the standard RoBERTa baseline of 69%. As shown in the table below, while the PsyLing features alone are insufficient for high-accuracy detection (averaging ~45% F1), they provide a complementary signal that enhances the Transformer's performance.

In-domain performance comparison on GoEmotion and ISEAR datasets.

Out-of-Domain Robustness

The most significant gains were observed in transfer learning scenarios. When trained on GoEmotions and tested on out-of-distribution datasets, the hybrid models showed relative F1 score increases of up to 7%. This suggests that stylistic "fingerprints" captured by psycholinguistic features are indeed more stable across domains than specific semantic keywords.

Conclusion

By combining the semantic power of Transformers with the stylistic stability of psycholinguistic features, we have developed a more robust framework for text-based emotion detection. Our hybrid models not only perform competitively on standard benchmarks but also show superior generalizability to new domains. Future research will explore dimensional models and multi-task learning to further refine these hybrid systems.

Summary updated

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 and ISEAR. Second, we conduct transfer learning experiments on six datasets from the Unified Emotion Dataset 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