Abstract
Sarcasm is a linguistic expression often used to communicate the opposite of what is said, usually something that is very unpleasant with an intention to insult or ridicule. Inherent ambiguity in sarcastic expressions make sarcasm detection very difficult. In this work, we focus on detecting sarcasm in textual conversations from various social networking platforms and online media. To this end, we develop an interpretable deep learning model using multi-head self-attention and gated recurrent units. Multi-head self-attention module aids in identifying crucial sarcastic cue-words from the input, and the recurrent units learn long-range dependencies between these cue-words to better classify the input text. We show the effectiveness of our approach by achieving state-of-the-art results on multiple datasets from social networking platforms and online media. Models trained using our proposed approach are easily interpretable and enable identifying sarcastic cues in the input text which contribute to the final classification score. We visualize the learned attention weights on few sample input texts to showcase the effectiveness and interpretability of our model.
Introduction
Detecting sarcasm in text is a significant challenge in Natural Language Processing (NLP) due to the inherent ambiguity of sarcastic expressions. Unlike humans, who rely on vocal cues and facial expressions, machines must identify sarcasm solely from textual content. Traditional methods often fail to capture the subtle nuances of informal online communication. This paper presents a novel deep learning architecture that is both highly accurate and interpretable, addressing the "black box" nature of many modern models.
Proposed Architecture
The proposed model follows a three-stage pipeline designed to extract semantic meaning, identify local cues, and understand global context.
1. Word Embeddings
Input text is first transformed into dense vector representations. The architecture is flexible, supporting various pre-trained embeddings such as BERT, GloVe, or FastText to capture initial semantic relationships.
2. Multi-Head Self-Attention (MHSA)
The core of the model's interpretability is the MHSA layer. By utilizing multiple attention heads, the model can simultaneously focus on different linguistic features—such as intensifiers ("totally"), hyperbolic adjectives, or punctuation marks—that serve as sarcastic cues.
3. Bi-directional Gated Recurrent Units (Bi-GRUs)
While attention identifies important words, Bi-GRUs process the sequence in both directions to learn long-range dependencies. This allows the model to detect contradictions between words at opposite ends of a sentence, a common hallmark of sarcasm.
Experimental Results
To evaluate robustness, the model was tested on five diverse datasets including Twitter (2013 & 2017), Reddit (SARC 2.0), internet argument dialogues, and news headlines. The proposed model achieved state-of-the-art (SOTA) performance across all tested datasets. Notably, on the Twitter 2013 dataset, the model reached an F1-score of 98.7, representing a significant improvement over previous benchmarks.
Interpretability and Discussion
A key feature of this approach is its interpretability. By visualizing the learned attention weights, researchers can see exactly which "cue-words" triggered the sarcasm classification. The model consistently places high weights on intensifiers (e.g., "totally," "just") and punctuation when they appear in incongruous contexts.
Ablation studies further showed that performance typically peaks between 3 and 5 attention layers. In deeper layers, the attention tends to spread out across the whole sentence, suggesting that the primary sarcastic signal is captured early in the network's processing.
Conclusion
By combining the interpretability of multi-head self-attention with the sequential learning capabilities of Bi-GRUs, this research provides a powerful tool for sarcasm detection. The model not only sets new performance benchmarks but also offers insights into the linguistic markers of sarcasm in digital media, paving the way for more transparent and reliable NLP systems.
Summary updated