Transformer-based Context-aware Sarcasm Detection in Conversation Threads from Social Media

Xiangjue Dong, Changmao Li, Jinho D. ChoiFig-Lang @ ACL 2020

Abstract

We present a transformer-based sarcasm detection model that accounts for the context from the entire conversation thread for more robust predictions. Our model uses deep transformer layers to perform multi-head attentions among the target utterance and the relevant context in the thread. The context-aware models are evaluated on two datasets from social media, Twitter and Reddit, and show 3.1% and 7.0% improvements over their baselines. Our best models give the F1-scores of 79.0% and 75.0% for the Twitter and Reddit datasets respectively, becoming one of the highest performing systems among 36 participants in this shared task.

Introduction

Sarcasm is a form of figurative language where the intended sentiment is the opposite of the surface-level meaning (e.g., saying "Great weather!" during a hurricane). In social media environments like Twitter and Reddit, detection is complicated by typos, slang, and emojis. Most previous research has focused on detecting sarcasm in a single "target" utterance in isolation. However, humans often struggle to identify sarcasm without knowing the preceding conversation. This paper demonstrates that providing a model with the full context of a conversation thread is essential for robust detection.

Examples of sarcastic conversation threads from Twitter and Reddit, illustrating the relationship between context (C) and target (T) utterances.

Methodology

The researchers compared two approaches using state-of-the-art Transformer architectures, specifically BERT-Large, RoBERTa-Large, and ALBERT-xxLarge:

  1. Target-oriented Model (TO): This baseline model analyzes only the specific target sentence. It uses a Transformer encoder to create an embedding, which is then passed through a linear decoder for binary classification.
  2. Context-aware Model (CA): This model concatenates the target sentence with preceding conversation utterances. This allows the Transformer’s multi-head attention mechanism to find relationships between the target sentence and earlier parts of the conversation.
Architectural diagrams for the target-oriented (TO) and context-aware (CA) models using Transformer Encoders.

Datasets and Evaluation

The models were evaluated on two social media datasets provided by a competitive NLP challenge:

  • Twitter: 5,000 training and 1,800 test examples, identified via hashtags like #sarcasm.
  • Reddit: 4,400 training and 1,800 test examples, sourced from the Self-Annotated Reddit Corpus.

Reddit conversations featured longer threads and more varied utterance lengths, making it a more difficult benchmark than Twitter.

Key Results and Insights

The context-aware RoBERTa-Large model was the top performer, achieving:

  • Twitter: 79.0% F1-score (a 3.1% improvement over the baseline).
  • Reddit: 75.0% F1-score (a 7.0% improvement over the baseline).

The significant boost on Reddit suggests that these conversations are more deeply "intertwined," where the meaning of a post is heavily dependent on the specific comment it responds to. Through error analysis, the authors found that while context is generally beneficial, it can occasionally introduce "noise" that confuses the model if the target sentence is already clear. Additionally, some subtle sarcasm remains difficult to detect as it requires external world knowledge or deeper reasoning.

Conclusion

This research confirms that the Transformer's ability to attend to specific keywords in previous turns of a conversation is vital for catching the incongruity that defines sarcasm. While context-aware models significantly outperform target-only baselines, future work should focus on integrating non-textual features and external knowledge bases to further improve detection of subtle, reasoning-based sarcasm.

Summary updated

BibTeX
@inproceedings{dong2020transformer,
  author = {Xiangjue Dong and Changmao Li and Jinho D. Choi},
  title = {{Transformer-based Context-aware Sarcasm Detection in Conversation Threads from Social Media}},
  booktitle = {Fig-Lang @ ACL},
  year = {2020},
  url = {https://openreview.net/forum?id=FMzzx0g_ns5},
}
Figure