<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Publishing DTD v1.1 20151215//EN" "http://jats.nlm.nih.gov/publishing/1.1/JATS-journalpublishing1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mml="http://www.w3.org/1998/Math/MathML" xml:lang="en" article-type="research-article" dtd-version="1.1">
<front>
<journal-meta>
<journal-id journal-id-type="pmc">JAI</journal-id>
<journal-id journal-id-type="nlm-ta">JAI</journal-id>
<journal-id journal-id-type="publisher-id">JAI</journal-id>
<journal-title-group>
<journal-title>Journal on Artificial Intelligence</journal-title>
</journal-title-group>
<issn pub-type="epub">2579-003X</issn>
<issn pub-type="ppub">2579-0021</issn>
<publisher>
<publisher-name>Tech Science Press</publisher-name>
<publisher-loc>USA</publisher-loc>
</publisher>
</journal-meta>
<article-meta>
<article-id pub-id-type="publisher-id">72531</article-id>
<article-id pub-id-type="doi">10.32604/jai.2025.072531</article-id>
<article-categories>
<subj-group subj-group-type="heading">
<subject>Article</subject>
</subj-group>
</article-categories>
<title-group>
<article-title>Why Transformers Outperform LSTMs: A Comparative Study on Sarcasm Detection</article-title>
<alt-title alt-title-type="left-running-head">Why Transformers Outperform LSTMs: A Comparative Study on Sarcasm Detection</alt-title>
<alt-title alt-title-type="right-running-head">Why Transformers Outperform LSTMs: A Comparative Study on Sarcasm Detection</alt-title>
</title-group>
<contrib-group>
<contrib id="author-1" contrib-type="author">
<name name-style="western"><surname>Bari</surname><given-names>Palak</given-names></name></contrib>
<contrib id="author-2" contrib-type="author">
<name name-style="western"><surname>Bedi</surname><given-names>Gurnur</given-names></name></contrib>
<contrib id="author-3" contrib-type="author">
<name name-style="western"><surname>Joshi</surname><given-names>Khushi</given-names></name></contrib>
<contrib id="author-4" contrib-type="author" corresp="yes">
<name name-style="western"><surname>Jawale</surname><given-names>Anupama</given-names></name><email>anupama.jawale@nmcce.ac.in</email></contrib>
<aff id="aff-1"><institution>Department of Information Technology, Narsee Monjee College of Commerce and Economics</institution>, <addr-line>Mumbai, 400056, Maharashtra</addr-line>, <country>India</country></aff>
</contrib-group>
<author-notes>
<corresp id="cor1"><label>&#x002A;</label>Corresponding Author: Anupama Jawale. Email: <email>anupama.jawale@nmcce.ac.in</email></corresp>
</author-notes>
<pub-date date-type="collection" publication-format="electronic">
<year>2025</year>
</pub-date>
<pub-date date-type="pub" publication-format="electronic">
<day>14</day><month>11</month><year>2025</year>
</pub-date>
<volume>7</volume>
<issue>1</issue>
<fpage>499</fpage>
<lpage>508</lpage>
<history>
<date date-type="received">
<day>29</day>
<month>08</month>
<year>2025</year>
</date>
<date date-type="accepted">
<day>27</day>
<month>10</month>
<year>2025</year>
</date>
</history>
<permissions>
<copyright-statement>&#x00A9; 2025 The Authors.</copyright-statement>
<copyright-year>2025</copyright-year>
<copyright-holder>Published by Tech Science Press.</copyright-holder>
<license xlink:href="https://creativecommons.org/licenses/by/4.0/">
<license-p>This work is licensed under a <ext-link ext-link-type="uri" xlink:type="simple" xlink:href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</ext-link>, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.</license-p>
</license>
</permissions>
<self-uri content-type="pdf" xlink:href="TSP_JAI_72531.pdf"></self-uri>
<abstract>
<p>This study investigates sarcasm detection in text using a dataset of 8095 sentences compiled from MUStARD and HuggingFace repositories, balanced across sarcastic and non-sarcastic classes. A sequential baseline model (LSTM) is compared with transformer-based models (RoBERTa and XLNet), integrated with attention mechanisms. Transformers were chosen for their proven ability to capture long-range contextual dependencies, whereas LSTM serves as a traditional benchmark for sequential modeling. Experimental results show that RoBERTa achieves 0.87 accuracy, XLNet 0.83, and LSTM 0.52. These findings confirm that transformer architectures significantly outperform recurrent models in sarcasm detection. Future work will incorporate multimodal features and error analysis to further improve robustness.</p>
</abstract>
<kwd-group kwd-group-type="author">
<kwd>Attention mechanism</kwd>
<kwd>LSTM</kwd>
<kwd>natural language processing</kwd>
<kwd>sarcasm detection</kwd>
<kwd>sentiment analysis</kwd>
<kwd>transformer models</kwd>
<kwd>RoBERTa</kwd>
<kwd>XLNet</kwd>
</kwd-group>
</article-meta>
</front>
<body>
<sec id="s1">
<label>1</label>
<title>Introduction</title>
<p>Sarcasm [<xref ref-type="bibr" rid="ref-1">1</xref>] is a subtle form of communication in which literal and intended meanings diverge, making it particularly difficult for NLP systems to detect. Unlike sentiment expressed directly, sarcastic statements rely heavily on contextual cues and often resemble non-sarcastic text. This poses challenges for sentiment analysis in social media, reviews, and dialogue systems. Moreover, sarcasm may be expressed by visual cues, such as facial expressions and gestures. Prosodic qualities function as aural markers of sarcasm [<xref ref-type="bibr" rid="ref-2">2</xref>]. A proficient speaker can convey sarcasm with ease, and it is essential to develop both visual and auditory recognition of this form of expression. A straightforward assertion such as &#x201C;Funny is all I have&#x201D; may be understood as sarcastic based on the relevant vocal or visual indicators present. Recent work has applied both traditional models (e.g., SVM, LSTM) and transformer-based architectures (e.g., BERT, DeBERTa, ChatGPT) to sarcasm detection, with transformers generally outperforming recurrent models. However, systematic comparisons across different architectures under controlled settings remain limited [<xref ref-type="bibr" rid="ref-3">3</xref>]. Emotions significantly influence the identification of sarcasm, as the essence of this phenomenon is rooted in human comprehension. Determining the level of human intelligence presents challenges for devices; however, successful training and testing can enhance their capabilities, making them more effective and advantageous.</p>
<p>In this study, a corpus of 8095 sentences is constructed by combining the MUStARD dataset with sarcasm data from HuggingFace repositories. Three representative models: LSTM (baseline sequential model), RoBERTa, and XLNet (transformer-based models), are compared, each with and without attention mechanisms [<xref ref-type="bibr" rid="ref-4">4</xref>].</p>
<p>Developing an NLP system typically requires the manual establishment of rules and linguistic resources, a process that can be both time-consuming and specialized. In contrast, Large Language Models (LLMs) [<xref ref-type="bibr" rid="ref-5">5</xref>] utilize automated training on extensive datasets, necessitating considerable computational resources and expertise in deep learning techniques. This approach significantly accelerates the process compared to traditional NLP methods [<xref ref-type="bibr" rid="ref-6">6</xref>]. LLMs provide a distinct advantage in this regard and have been incorporated into this research study.</p>
</sec>
<sec id="s2">
<label>2</label>
<title>Contributions</title>
<p>Our contributions are fourfold: (i) development of a consolidated sarcasm detection dataset; (ii) comparative evaluation of sequential and transformer architectures; (iii) inclusion of error analysis to highlight cases where transformers outperform LSTMs; and (iv) statistical significance testing of observed performance improvements.</p>
</sec>
<sec id="s3">
<label>3</label>
<title>Related Work</title>
<p>Sarcasm detection has been a growing area of interest due to its complex nature, particularly in the context of social media, where brief, informal, and multimodal expressions dominate. Prior studies have approached sarcasm detection through various traditional, deep learning, and multimodal techniques. The related work in this domain can be summarized as follows.</p>
<p>i. Text-based approach</p>
<p>Early sarcasm detection relied on traditional ML models such as SVM and logistic regression, often using lexical, pragmatic, and sentiment features. Traditional machine learning techniques also remain relevant. Study [<xref ref-type="bibr" rid="ref-7">7</xref>] found SVM to be the most effective model for sarcasm detection on Twitter, with performance enhanced by lexical, pragmatic, and part-of-speech features. A hybrid CNN-SVM approach further improved performance by incorporating both lexical and personal information. A two-phase sarcasm detection framework was proposed in [<xref ref-type="bibr" rid="ref-8">8</xref>], where Phase 1 utilizes models such as BERT and fastText to determine whether a statement belongs to humorous or non-humorous categories. Ensemble methods including Random Forest, Support Vector Machines (SVM), and Logistic Regression were employed to improve detection efficiency. In Phase 2, deep learning models like TD-LSTM and TC-LSTM analyzed sarcasm within humorous phrases by focusing on sentence context, word-level semantics, and sarcasm target recognition.</p>
<p>The research [<xref ref-type="bibr" rid="ref-9">9</xref>] utilized a variety of lexical, pragmatic, and sentiment-based features and found that Bi-directional LSTM outperformed CNN and LSTM models, with accuracies of 86.32% and 82.91%, respectively. Deep learning methods including CNNs, LSTMs, and Bi-LSTMs later improved performance by modeling sequential context. Significant progress has also been made with hybrid and optimized models. The DLNLP-SA model [<xref ref-type="bibr" rid="ref-10">10</xref>], which uses N-gram feature extraction, MHSA-GRU, and Metaheuristic Feature Optimization (MFO), achieved an outstanding 97.61% accuracy and over 94% F1 score. The model was especially effective on Twitter and dialogue datasets and focused on negative emotional cues to detect sarcasm. Furthermore, the study in [<xref ref-type="bibr" rid="ref-11">11</xref>] experimented with various deep learning models including CNN, LSTM, and GRU, combined with pre-trained word embeddings such as Word2Vec, GloVe, and fastText. The best performing models used an 80:20 train-validation split, showing a gradual accuracy improvement: CNN &#x003C; LSTM &#x003C; Bi-LSTM, with Bi-LSTM delivering the highest accuracy.</p>
<p>ii. Transformer-based models</p>
<p>Together, these studies underscore the growing sophistication of sarcasm detection models, particularly those that leverage deep learning, multimodal signals, context-aware attention, and hybrid architectures. However, the field still faces key challenges such as language diversity, implicit meaning detection, and fine-grained context modeling, indicating that further innovation is needed in both model design and dataset development. Multimodal approaches have also demonstrated significant promise. A study in [<xref ref-type="bibr" rid="ref-12">12</xref>] used RoBERTa and RCNN to identify snark and irony, highlighting the utility of transformer-based architectures.</p>
<p>Several innovations have been proposed to enhance multimodal sarcasm detection. The MMOE (Multimodal Mixtures of Experts) framework was developed to better handle multiple input modalities, while MOSES (MOdelling Stand rESponse) [<xref ref-type="bibr" rid="ref-13">13</xref>] integrated deep neural networks with natural language explanations to identify sarcasm and related emotional content in dialogues. In [<xref ref-type="bibr" rid="ref-14">14</xref>], image-text incongruity was leveraged using ResNet and co-attention mechanisms, achieving a 6.14% increase in F1 score over baseline models. Transformer-based and aspect-based sentiment analysis methods have also been shown effective for sarcasm detection [<xref ref-type="bibr" rid="ref-13">13</xref>&#x2013;<xref ref-type="bibr" rid="ref-17">17</xref>]. These approaches address the challenges posed by implicit signals and contextual nuances. Notably, MOSES, CLFA, and ChatGPT have all contributed significantly to this domain, advancing affective computing and sarcasm understanding.</p>
<p>iii. Multimodal approaches</p>
<p>Sarcasm is not only textual but often conveyed through audio and visual signals. The MUStARD dataset [<xref ref-type="bibr" rid="ref-10">10</xref>] enabled multimodal sarcasm detection, where models incorporating text, audio, and video outperform text-only baselines by large margins, such as Ref. [<xref ref-type="bibr" rid="ref-18">18</xref>] emphasized that multimodal models, especially those using both audio and video inputs, outperform unimodal ones in sarcasm identification tasks. The MUStARD dataset [<xref ref-type="bibr" rid="ref-19">19</xref>] provides sarcastic audiovisual sentences and has been pivotal in benchmarking performance. The study noted a 12.9% improvement in F1 score when using multimodal models compared to text-only baselines. In another study, Ref. [<xref ref-type="bibr" rid="ref-20">20</xref>] proposed a BiGRU framework using Bayesian priors to model sarcasm in diverse contexts, outperforming models like CASCADE. In [<xref ref-type="bibr" rid="ref-21">21</xref>], a CNN-based sarcasm detector was enhanced with user embeddings, reflecting individual user behavior patterns.</p>
<p>iv. Hybrid and optimized frameworks.</p>
<p>Language diversity introduces further complexity. According to [<xref ref-type="bibr" rid="ref-22">22</xref>], while English corpora are abundant, sarcasm recognition in regional or code-switched languages presents significant challenges. A novel context-sensitive sentiment analysis method, RO-TGANN (Remora-Optimized Twofold Gated Attention Neural Network), was proposed in [<xref ref-type="bibr" rid="ref-23">23</xref>], focusing on accurate sentiment and context modeling.</p>
<p>Psycholinguistic factors have also been considered. Study [<xref ref-type="bibr" rid="ref-24">24</xref>] explored how sentiment, mood, and personality traits influence sarcasm recognition by deep CNNs. In multilingual and code-switching scenarios, Ref. [<xref ref-type="bibr" rid="ref-25">25</xref>] demonstrated that Hierarchical Attention Networks (HAN) improved Hindi-English sarcasm detection by 4.7% in F1 score, highlighting the value of modeling language-switch patterns.</p>
<p>Visual modalities have also been explored further. For instance, Ref. [<xref ref-type="bibr" rid="ref-26">26</xref>] incorporated contextual linkages and utterance sequences in video-based sentiment analysis using LSTM-based models. The model in [<xref ref-type="bibr" rid="ref-27">27</xref>] introduced Image-Text Contrastive (ITC) and Image-Text Matching (ITM) auxiliary tasks to enhance multimodal performance. Meanwhile, the Hyphen Model [<xref ref-type="bibr" rid="ref-28">28</xref>] integrated hyperbolic Fourier co-attention and hierarchical graph structures to model public sentiment from source posts and comments.</p>
<p>Despite significant progress, two limitations remain: (i) insufficient systematic comparisons between traditional recurrent models (e.g., LSTM) and transformers under controlled conditions, and (ii) limited attention to reproducibility, error analysis, and statistical validation. This study addresses these gaps by evaluating LSTM, RoBERTa, and XLNet on a unified sarcasm corpus, providing both quantitative and qualitative comparisons.</p>
</sec>
<sec id="s4">
<label>4</label>
<title>Methodology</title>
<p>A dataset of 8095 sentences is compiled by combining MUStARD with a publicly available sarcasm corpus from HuggingFace. The dataset is approximately balanced between sarcastic and non-sarcastic classes. Text was preprocessed by lowercasing, removing special symbols, normalizing punctuation, and handling emojis. Transformers (RoBERTa, XLNet) used their respective HuggingFace tokenizers, while LSTM was trained on sequences padded and indexed with pre-trained GloVe embeddings. The dataset is split into 80% training, and 20% testing sets, stratified by class distribution to maintain balance.</p>
<p>In this research study, three representative architectures: (i) LSTM, a sequential baseline for text classification; (ii) RoBERTa, a transformer optimized for robust pre-training; and (iii) XLNet, a permutation-based transformer that captures bidirectional context are compared. Attention layers were applied to enhance token-level importance weighting.</p>
<p>For LSTM, Adam optimizer is used with a learning rate of 1e&#x2212;3, batch size of 32, dropout rate of 0.5, and trained for 15 epochs. For transformers, AdamW is used with learning rate 2e&#x2212;5, batch size of 16, and fine-tuned for 5 epochs. Cross-entropy loss was used for all models. Evaluation metrics included accuracy, precision, recall, and F1 score.</p>
<p>This flowchart in <xref ref-type="fig" rid="fig-1">Fig. 1</xref> represents a machine learning pipeline that incorporates an attention mechanism and multiple deep learning models to optimize decision-making. The process starts with the Start Node, initializing the system. The Attention Mechanism enhances model performance by focusing on important input data, improving accuracy in NLP tasks.</p>
<fig id="fig-1">
<label>Figure 1</label>
<caption>
<title>Proposed methodology</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="JAI_72531-fig-1.tif"/>
</fig>
<p>In the Model Selection phase, the system chooses between RoBERTa, LSTM, and XLNet based on the highest probability of better choice.</p>
<p>RoBERTa is a transformer-based model optimized for NLP, LSTM is a recurrent neural network (RNN) designed for sequential data processing, and XLNet improves upon BERT using autoregressive training. Once a model is selected, it moves to the Training Phase, where it learns patterns from labeled data, followed by the Testing Phase, where its performance is evaluated using metrics like accuracy and F1-score.</p>
<p><bold>Attention Mechanism</bold></p>
<p>Attention is a technique that allows neural networks to focus on important parts of the input sequence when making predictions. It is widely used in transformers, machine translation, NLP, and vision models. Instead of treating all input words equally, attention assigns different weights to different words based on their relevance to the current output, as described in Algorithm 1.</p>
<fig id="fig-3">
<graphic mimetype="image" mime-subtype="tif" xlink:href="JAI_72531-fig-3.tif"/>
</fig>
<p><bold>RoBERTa</bold></p>
<p>RoBERTa stands for Robustly Optimized BERT Pretraining Approach, a transformer-based model for natural language understanding which is an optimized and scaled up version of BERT. The foundation is BERT and is designed to improve performance by using hyperparameters and pretraining processes. Algorithm 2 describes working of RoBERTa, as follows.</p>
<fig id="fig-4">
<graphic mimetype="image" mime-subtype="tif" xlink:href="JAI_72531-fig-4.tif"/>
</fig>
<p><bold>LSTM</bold></p>
<p>LSTM has an attention mechanism which helps to improve performance, especially the one with sequential input data, natural language processing or time-series forecasting. This combination helps the model&#x2019;s ability to handle long-range dependencies and select important information from sequence, making it suitable for machine translation, text classification, and time series forecasting. Algorithm 3 describes LSTM gate updates and attention algorithm used in this research.</p>
<fig id="fig-5">
<graphic mimetype="image" mime-subtype="tif" xlink:href="JAI_72531-fig-5.tif"/>
</fig>
<p><bold>XLNet</bold></p>
<p>XLNet is a transformer model which combines the best of two worlds: built on strengths of autoregressive models (GPT) and autoencoding models (BERT). It is designed to overcome limitations of BERT leading to better performance on NLP tasks. It uses the Transformer-XL architecture (an improvement on the original Transformer) that allows the model to better handle long-range dependencies and capture more contextual information (As presented in Algorithm 4).</p>
<fig id="fig-6">
<graphic mimetype="image" mime-subtype="tif" xlink:href="JAI_72531-fig-6.tif"/>
</fig>
<p>Next, the trained model generates Model Weights, which store learned information. If multiple models are used, their outputs are combined in the Integration of Model Outputs step using ensemble techniques for better accuracy. The system then accepts Input from UI, allowing real-time user interaction. The model processes the input and moves to Generating the Best Output, selecting the most relevant prediction. Finally, the Final Decision step delivers the optimized result, which could be a classification, recommendation, or another actionable output.</p>
<p>This pipeline efficiently integrates attention mechanisms, multiple deep learning models, and output fusion techniques to enhance accuracy and reliability in NLP and machine learning-based decision-making. Experimental setup for this framework is explained in next section.</p>
</sec>
<sec id="s5">
<label>5</label>
<title>Experimental Setup</title>
<p><bold>Dataset</bold></p>
<p>Initially the models were trained using a dataset consisting of 3648 rows and further evaluating the model by using the test dataset. Later to improve the accuracy in the models, a new dataset was created by combining the old dataset with a dataset downloaded from a repository uploaded on the hugging face, an open-source platform.</p>
<p>The final dataset which has been used to train all the three models (XLNET, RoBERTa and LSTM) consists of a total 8095 rows. The dataset has been split into two, train dataset and test dataset with the ratio of 80:20.</p>
<p><bold>User Interface</bold></p>
<p>A simple user interface is also designed using HTML/CSS and Django framework. Django is used as the web framework to manage the backend logic, routing, and rendering of web pages. It handles the HTTP requests, processes the input entered by the user and returns responses to the client accordingly. Pre-trained models are called through this interface for sarcasm detection of the input provided by user (<xref ref-type="fig" rid="fig-2">Fig. 2</xref>).</p>
<fig id="fig-2">
<label>Figure 2</label>
<caption>
<title>Interface design</title>
</caption>
<graphic mimetype="image" mime-subtype="tif" xlink:href="JAI_72531-fig-2.tif"/>
</fig>
<p>Manual test cases have been designed to test the performance and accuracy of these models. Description of the same is provided in section below.</p>
</sec>
<sec id="s6">
<label>6</label>
<title>Results and Discussion</title>
<p>Results of experimental work are presented in <xref ref-type="table" rid="table-1">Table 1</xref> as follows. Models were trained with the configurations described in <xref ref-type="sec" rid="s3">Section 3</xref>. Each experiment was repeated five times with different random seeds, and results are reported as mean &#x00B1; standard deviation.</p>
<table-wrap id="table-1">
<label>Table 1</label>
<caption>
<title>Performance comparison of different models</title>
</caption>
<table>
<colgroup>
<col align="center"/>
<col align="center"/>
<col align="center"/>
<col align="center"/>
<col align="center"/>
</colgroup>
<thead>
<tr>
<th>Model</th>
<th>Accuracy</th>
<th>Precision</th>
<th>Recall</th>
<th>F1 Score</th>
</tr>
</thead>
<tbody>
<tr>
<td>LSTM</td>
<td>0.525 &#x00B1; 0.012</td>
<td>0.525 &#x00B1; 0.015</td>
<td>1.00 &#x00B1; 0.000</td>
<td>0.689 &#x00B1; 0.008</td>
</tr>
<tr>
<td>LSTM &#x002B; Attention</td>
<td>0.530 &#x00B1; 0.010</td>
<td>0.280 &#x00B1; 0.013</td>
<td>0.530 &#x00B1; 0.011</td>
<td>0.689 &#x00B1; 0.007</td>
</tr>
<tr>
<td>RoBERTa</td>
<td>0.874 &#x00B1; 0.006</td>
<td>0.852 &#x00B1; 0.007</td>
<td>0.920 &#x00B1; 0.005</td>
<td>0.885 &#x00B1; 0.005</td>
</tr>
<tr>
<td>RoBERTa &#x002B; Attention</td>
<td>0.871 &#x00B1; 0.007</td>
<td>0.880 &#x00B1; 0.006</td>
<td>0.870 &#x00B1; 0.007</td>
<td>0.870 &#x00B1; 0.005</td>
</tr>
<tr>
<td>XLNet</td>
<td>0.832 &#x00B1; 0.009</td>
<td>0.850 &#x00B1; 0.010</td>
<td>0.802 &#x00B1; 0.008</td>
<td>0.903 &#x00B1; 0.007</td>
</tr>
<tr>
<td>XLNet &#x002B; Attention</td>
<td>0.986 &#x00B1; 0.004</td>
<td>0.986 &#x00B1; 0.004</td>
<td>0.986 &#x00B1; 0.003</td>
<td>0.985 &#x00B1; 0.004</td>
</tr>
</tbody>
</table>
</table-wrap>
<p>The results reveal a clear performance disparity between transformer-based architectures (XLNet, RoBERTa) and the sequential baseline (LSTM) in sarcasm detection. Transformers exhibit a superior capacity to capture long-range contextual dependencies and semantic nuances, which are critical for identifying sarcastic intent. In contrast, the LSTM model demonstrates a sequential bias, processing input linearly and often missing implicit cues of irony. The notably low precision score (0.28) for LSTM &#x002B; Attention indicates model overfitting to superficial lexical correlations rather than contextual semantics. Conversely, the self-attention mechanisms in XLNet and RoBERTa effectively encode inter-token dependencies, enhancing recognition of tonal and contextual shifts. Attention integration yielded a substantial gain for XLNet (F1: 0.903 &#x2192; 0.985) but produced marginal or adverse effects in RoBERTa and LSTM, suggesting that XLNet&#x2019;s permutation-based objective inherently benefits from attention refinement over contextually salient tokens.</p>
</sec>
<sec id="s7">
<label>7</label>
<title>Conclusion</title>
<p>This research successfully developed a sarcasm detection system, using a hybrid model integrating LSTM networks, RoBERTa, and XLNet, enhanced with an attention mechanism. The primary goal is to improve sentiment analysis by accurately identifying sarcasm in text, a significant challenge for NLP. The hybrid approach leverages the strengths of each model: RoBERTa excels in contextual understanding, XLNet captures bidirectional context, and LSTM models sequential data, all refined by the attention mechanism. Experimental results showed RoBERTa achieving the highest accuracy (0.87), followed by XLNet (0.83), and LSTM (0.52), highlighting RoBERTa&#x2019;s superior performance in this application, before integration of attention mechanism. However, this study confirms that transformers inherently outperform LSTMs in sarcasm detection due to their superior contextual modeling and pretraining advantages. While attention mechanisms can further refine performance (XLNet with highest performance of 0.98), their utility depends on the base architecture. For practical applications, RoBERTa offers a balance of efficiency and accuracy, whereas XLNet &#x002B; Attention represent the state-of-the-art for research benchmarks. Future work should address computational efficiency and multimodal integration to bridge the gap between laboratory performance and real-world usability.</p>
</sec>
<sec id="s8">
<label>8</label>
<title>Limitations and Future Work</title>
<p>This study&#x2019;s primary limitations include (i) the computational cost of fine-tuning large transformer models; (ii) the moderate dataset size, which restricts generalizability; and (iii) the absence of multimodal sarcasm analysis that incorporates audio or visual cues. Future work will address these constraints by leveraging multimodal fusion frameworks and exploring lightweight transformer variants for efficient deployment.</p>
</sec>
</body>
<back>
<ack>
<p>Authors are thankful to Dr. Neha Kushe for the technical support provided in carrying out this research work.</p>
</ack>
<sec>
<title>Funding Statement</title>
<p>The authors received no specific funding for this study.</p>
</sec>
<sec>
<title>Author Contributions</title>
<p>The authors confirm contribution to the paper as follows: Study conception: Palak Bari and Anupama Jawale; data collection: Gurnur Bedi and Khushi Joshi; analysis and interpretation of results: Anupama Jawale and Palak Bari; drafting manuscript: Palak Bari, Gurnur Bedi, Khushi Joshi and Anupama Jawale. All authors reviewed the results and approved the final version of the manuscript.</p>
</sec>
<sec sec-type="data-availability">
<title>Availability of Data and Materials</title>
<p>Data is available from authors on request.</p>
</sec>
<sec>
<title>Ethics Approval</title>
<p>Not applicable.</p>
</sec>
<sec sec-type="COI-statement">
<title>Conflicts of Interest</title>
<p>The authors declare no conflicts of interest to report regarding the present study.</p>
</sec>
<ref-list content-type="authoryear">
<title>References</title>
<ref id="ref-1"><label>[1]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Riloff</surname> <given-names>E</given-names></string-name>, <string-name><surname>Qadir</surname> <given-names>A</given-names></string-name>, <string-name><surname>Surve</surname> <given-names>P</given-names></string-name>, <string-name><surname>De Silva</surname> <given-names>L</given-names></string-name>, <string-name><surname>Gilbert</surname> <given-names>N</given-names></string-name>, <string-name><surname>Huang</surname> <given-names>R</given-names></string-name></person-group>. <article-title>Sarcasm as contrast between a positive sentiment and negative situation</article-title>. In: <conf-name>Proceedings of the 2013 Conference on Empirical Methods in Natural Language Processing; 2013 Oct 18&#x2013;21</conf-name>; <publisher-loc>Seattle, WA, USA</publisher-loc>. p. <fpage>704</fpage>&#x2013;<lpage>14</lpage>. doi:<pub-id pub-id-type="doi">10.18653/v1/d13-1066</pub-id>.</mixed-citation></ref>
<ref id="ref-2"><label>[2]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Brentari</surname> <given-names>D</given-names></string-name>, <string-name><surname>Gonz&#x00E1;lez</surname> <given-names>C</given-names></string-name>, <string-name><surname>Seidl</surname> <given-names>A</given-names></string-name>, <string-name><surname>Wilbur</surname> <given-names>R</given-names></string-name></person-group>. <article-title>Sensitivity to visual prosodic cues in signers and nonsigners</article-title>. <source>Lang Speech</source>. <year>2011</year>;<volume>54</volume>(<issue>1</issue>):<fpage>49</fpage>&#x2013;<lpage>72</lpage>. doi:<pub-id pub-id-type="doi">10.1177/0023830910388011</pub-id>; <pub-id pub-id-type="pmid">21524012</pub-id></mixed-citation></ref>
<ref id="ref-3"><label>[3]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Poria</surname> <given-names>S</given-names></string-name></person-group>. <article-title>Soujanyaporia/MUStARD [Internet]</article-title>. <year>2025</year> <comment>[cited 2025 May 10]</comment>. Available from: <ext-link ext-link-type="uri" xlink:href="https://github.com/soujanyaporia/MUStARD">https://github.com/soujanyaporia/MUStARD</ext-link>.</mixed-citation></ref>
<ref id="ref-4"><label>[4]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Chimote</surname> <given-names>AK</given-names></string-name></person-group>. <article-title>An approach to detect sentence level sarcasm using deep learning techniques</article-title>. <source>Biosci Biotech Res Comm</source>. <year>2020</year>;<volume>13</volume>(<issue>14</issue>):<fpage>125</fpage>&#x2013;<lpage>8</lpage>. doi:<pub-id pub-id-type="doi">10.21786/bbrc/13.14/30</pub-id>.</mixed-citation></ref>
<ref id="ref-5"><label>[5]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Rahaman</surname> <given-names>A</given-names></string-name>, <string-name><surname>Kuri</surname> <given-names>R</given-names></string-name>, <string-name><surname>Islam</surname> <given-names>S</given-names></string-name>, <string-name><surname>Hossain</surname> <given-names>MJ</given-names></string-name>, <string-name><surname>Kabir</surname> <given-names>MH</given-names></string-name></person-group>. <article-title>Sarcasm detection in tweets: a feature-based approach using supervised machine learning models</article-title>. <source>Int J Adv Comput Sci Appl</source>. <year>2021</year>;<volume>12</volume>(<issue>6</issue>):<fpage>454</fpage>&#x2013;<lpage>60</lpage>. doi:<pub-id pub-id-type="doi">10.14569/ijacsa.2021.0120651</pub-id>.</mixed-citation></ref>
<ref id="ref-6"><label>[6]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Chaudhari</surname> <given-names>P</given-names></string-name>, <string-name><surname>Chandankhede</surname> <given-names>C</given-names></string-name></person-group>. <article-title>Literature survey of sarcasm detection</article-title>. In: <conf-name>Proceedings of the 2017 International Conference on Wireless Communications, Signal Processing and Networking (WiSPNET); 2017 Mar 22&#x2013;24</conf-name>; <publisher-loc>Chennai, India</publisher-loc>. p. <fpage>2041</fpage>&#x2013;<lpage>6</lpage>. doi:<pub-id pub-id-type="doi">10.1109/WiSPNET.2017.8300120</pub-id>.</mixed-citation></ref>
<ref id="ref-7"><label>[7]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Sarsam</surname> <given-names>SM</given-names></string-name>, <string-name><surname>Al-Samarraie</surname> <given-names>H</given-names></string-name>, <string-name><surname>Alzahrani</surname> <given-names>AI</given-names></string-name>, <string-name><surname>Wright</surname> <given-names>B</given-names></string-name></person-group>. <article-title>Sarcasm detection using machine learning algorithms in Twitter: a systematic review</article-title>. <source>Int J Mark Res</source>. <year>2020</year>;<volume>62</volume>(<issue>5</issue>):<fpage>578</fpage>&#x2013;<lpage>98</lpage>. doi:<pub-id pub-id-type="doi">10.1177/1470785320921779</pub-id>.</mixed-citation></ref>
<ref id="ref-8"><label>[8]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Parameswaran</surname> <given-names>P</given-names></string-name>, <string-name><surname>Trotman</surname> <given-names>A</given-names></string-name>, <string-name><surname>Liesaputra</surname> <given-names>V</given-names></string-name>, <string-name><surname>Eyers</surname> <given-names>D</given-names></string-name></person-group>. <article-title>Detecting the target of sarcasm is hard: really?</article-title> <source>Inf Process Manag</source>. <year>2021</year>;<volume>58</volume>(<issue>4</issue>):<fpage>102599</fpage>. doi:<pub-id pub-id-type="doi">10.1016/j.ipm.2021.102599</pub-id>.</mixed-citation></ref>
<ref id="ref-9"><label>[9]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Kumar</surname> <given-names>A</given-names></string-name>, <string-name><surname>Garg</surname> <given-names>G</given-names></string-name></person-group>. <article-title>Empirical study of shallow and deep learning models for sarcasm detection using context in benchmark datasets</article-title>. <source>J Ambient Intell Humaniz Comput</source>. <year>2023</year>;<volume>14</volume>(<issue>5</issue>):<fpage>5327</fpage>&#x2013;<lpage>42</lpage>. doi:<pub-id pub-id-type="doi">10.1007/s12652-019-01419-7</pub-id>.</mixed-citation></ref>
<ref id="ref-10"><label>[10]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Rahaman Wahab Sait</surname> <given-names>A</given-names></string-name>, <string-name><surname>Khairi Ishak</surname> <given-names>M</given-names></string-name></person-group>. <article-title>Deep learning with natural language processing enabled sentimental analysis on sarcasm classification</article-title>. <source>Comput Syst Sci Eng</source>. <year>2023</year>;<volume>44</volume>(<issue>3</issue>):<fpage>2553</fpage>&#x2013;<lpage>67</lpage>. doi:<pub-id pub-id-type="doi">10.32604/csse.2023.029603</pub-id>.</mixed-citation></ref>
<ref id="ref-11"><label>[11]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Goel</surname> <given-names>P</given-names></string-name>, <string-name><surname>Jain</surname> <given-names>R</given-names></string-name>, <string-name><surname>Nayyar</surname> <given-names>A</given-names></string-name>, <string-name><surname>Singhal</surname> <given-names>S</given-names></string-name>, <string-name><surname>Srivastava</surname> <given-names>M</given-names></string-name></person-group>. <article-title>Sarcasm detection using deep learning and ensemble learning</article-title>. <source>Multimed Tools Appl</source>. <year>2022</year>;<volume>81</volume>(<issue>30</issue>):<fpage>43229</fpage>&#x2013;<lpage>52</lpage>. doi:<pub-id pub-id-type="doi">10.1007/s11042-022-12930-z</pub-id>.</mixed-citation></ref>
<ref id="ref-12"><label>[12]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Potamias</surname> <given-names>RA</given-names></string-name>, <string-name><surname>Siolas</surname> <given-names>G</given-names></string-name>, <string-name><surname>Stafylopatis</surname> <given-names>AG</given-names></string-name></person-group>. <article-title>A transformer-based approach to irony and sarcasm detection</article-title>. <source>Neural Comput Appl</source>. <year>2020</year>;<volume>32</volume>(<issue>23</issue>):<fpage>17309</fpage>&#x2013;<lpage>20</lpage>. doi:<pub-id pub-id-type="doi">10.1007/s00521-020-05102-3</pub-id>.</mixed-citation></ref>
<ref id="ref-13"><label>[13]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Kumar</surname> <given-names>S</given-names></string-name>, <string-name><surname>Mondal</surname> <given-names>I</given-names></string-name>, <string-name><surname>Akhtar</surname> <given-names>MS</given-names></string-name>, <string-name><surname>Chakraborty</surname> <given-names>T</given-names></string-name></person-group>. <article-title>Explaining (sarcastic) utterances to enhance affect understanding in multimodal dialogues</article-title>. <comment>arXiv:2211.11049. 2022</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.2211.11049</pub-id>.</mixed-citation></ref>
<ref id="ref-14"><label>[14]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Gupta</surname> <given-names>S</given-names></string-name>, <string-name><surname>Shah</surname> <given-names>A</given-names></string-name>, <string-name><surname>Shah</surname> <given-names>M</given-names></string-name>, <string-name><surname>Syiemlieh</surname> <given-names>L</given-names></string-name>, <string-name><surname>Maurya</surname> <given-names>C</given-names></string-name></person-group>. <article-title>FiLMing multimodal sarcasm detection with attention</article-title>. <comment>arXiv:2110.00416. 2021</comment>. doi:<pub-id pub-id-type="doi">10.48550/arXiv.2110.0041</pub-id>.</mixed-citation></ref>
<ref id="ref-15"><label>[15]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Shangipour Ataei</surname> <given-names>T</given-names></string-name>, <string-name><surname>Javdan</surname> <given-names>S</given-names></string-name>, <string-name><surname>Minaei-Bidgoli</surname> <given-names>B</given-names></string-name></person-group>. <article-title>Applying transformers and aspect-based sentiment analysis approaches on sarcasm detection</article-title>. In: <conf-name>Proceedings of the Second Workshop on Figurative Language Processing; 2020 Jul 9</conf-name>; <publisher-name>Online</publisher-name>. p. <fpage>67</fpage>&#x2013;<lpage>71</lpage>. doi:<pub-id pub-id-type="doi">10.18653/v1/2020.figlang-1.9</pub-id>.</mixed-citation></ref>
<ref id="ref-16"><label>[16]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Zhang</surname> <given-names>M</given-names></string-name>, <string-name><surname>Chang</surname> <given-names>K</given-names></string-name>, <string-name><surname>Wu</surname> <given-names>Y</given-names></string-name></person-group>. <article-title>Multi-modal semantic understanding with contrastive cross-modal feature alignment</article-title>. <comment>arXiv:2403.06355. 2024</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.2403.06355</pub-id>.</mixed-citation></ref>
<ref id="ref-17"><label>[17]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Amin</surname> <given-names>MM</given-names></string-name>, <string-name><surname>Mao</surname> <given-names>R</given-names></string-name>, <string-name><surname>Cambria</surname> <given-names>E</given-names></string-name>, <string-name><surname>Schuller</surname> <given-names>BW</given-names></string-name></person-group>. <article-title>A wide evaluation of ChatGPT on affective computing tasks</article-title>. <comment>arXiv:2308.13911. 2023</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.2308.13911</pub-id>.</mixed-citation></ref>
<ref id="ref-18"><label>[18]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Kumar</surname> <given-names>S</given-names></string-name>, <string-name><surname>Kulkarni</surname> <given-names>A</given-names></string-name>, <string-name><surname>Akhtar</surname> <given-names>MS</given-names></string-name>, <string-name><surname>Chakraborty</surname> <given-names>T</given-names></string-name></person-group>. <article-title>When did you become so smart, oh wise one?! Sarcasm explanation in multi-modal multi-party dialogues</article-title>. <comment>arXiv:2203.06419. 2022</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.2203.06419</pub-id>.</mixed-citation></ref>
<ref id="ref-19"><label>[19]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Castro</surname> <given-names>S</given-names></string-name>, <string-name><surname>Hazarika</surname> <given-names>D</given-names></string-name>, <string-name><surname>P&#x00E9;rez-Rosas</surname> <given-names>V</given-names></string-name>, <string-name><surname>Zimmermann</surname> <given-names>R</given-names></string-name>, <string-name><surname>Mihalcea</surname> <given-names>R</given-names></string-name>, <string-name><surname>Poria</surname> <given-names>S</given-names></string-name></person-group>. <article-title>Towards multimodal sarcasm detection (an_Obviously_perfect paper)</article-title>. <comment>arXiv:1906.01815. 2019</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.1906.01815</pub-id>.</mixed-citation></ref>
<ref id="ref-20"><label>[20]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Kolchinski</surname> <given-names>YA</given-names></string-name>, <string-name><surname>Potts</surname> <given-names>C</given-names></string-name></person-group>. <article-title>Representing social media users for sarcasm detection</article-title>. <comment>arXiv:1808.08470. 2018</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.1808.08470</pub-id>.</mixed-citation></ref>
<ref id="ref-21"><label>[21]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Amir</surname> <given-names>S</given-names></string-name>, <string-name><surname>Wallace</surname> <given-names>BC</given-names></string-name>, <string-name><surname>Lyu</surname> <given-names>H</given-names></string-name>, <string-name><surname>Silva</surname> <given-names>PCMJ</given-names></string-name></person-group>. <article-title>Modelling context with user embeddings for sarcasm detection in social media</article-title>. <comment>arXiv:1607.00976. 2016</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.1607.00976</pub-id>.</mixed-citation></ref>
<ref id="ref-22"><label>[22]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Kumar</surname> <given-names>Y</given-names></string-name>, <string-name><surname>Goel</surname> <given-names>N</given-names></string-name></person-group>. <article-title>AI-based learning techniques for sarcasm detection of social media tweets: state-of-the-art survey</article-title>. <source>SN Comput Sci</source>. <year>2020</year>;<volume>1</volume>(<issue>6</issue>):<fpage>318</fpage>. doi:<pub-id pub-id-type="doi">10.1007/s42979-020-00336-3</pub-id>.</mixed-citation></ref>
<ref id="ref-23"><label>[23]</label><mixed-citation publication-type="journal"><person-group person-group-type="author"><string-name><surname>Marriwala</surname> <given-names>NK</given-names></string-name>, <string-name><surname>Shukla</surname> <given-names>VK</given-names></string-name>, <string-name><surname>William</surname> <given-names>P</given-names></string-name>, <string-name><surname>Guleria</surname> <given-names>K</given-names></string-name>, <string-name><surname>Sobti</surname> <given-names>R</given-names></string-name>, <string-name><surname>Sharma</surname> <given-names>S</given-names></string-name></person-group>. <article-title>Detection of viral messages in twitter using context-based sentiment analysis framework</article-title>. <source>Int J Inf Technol</source>. <year>2024</year>;<volume>16</volume>(<issue>8</issue>):<fpage>5069</fpage>&#x2013;<lpage>75</lpage>. doi:<pub-id pub-id-type="doi">10.1007/s41870-024-02084-6</pub-id>.</mixed-citation></ref>
<ref id="ref-24"><label>[24]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Poria</surname> <given-names>S</given-names></string-name>, <string-name><surname>Cambria</surname> <given-names>E</given-names></string-name>, <string-name><surname>Hazarika</surname> <given-names>D</given-names></string-name>, <string-name><surname>Vij</surname> <given-names>P</given-names></string-name></person-group>. <article-title>A deeper look into sarcastic tweets using deep convolutional neural networks</article-title>. <comment>arXiv:1610.08815. 2016</comment>. doi:<pub-id pub-id-type="doi">10.48550/arXiv.1610.08815</pub-id>.</mixed-citation></ref>
<ref id="ref-25"><label>[25]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Bansal</surname> <given-names>S</given-names></string-name>, <string-name><surname>Garimella</surname> <given-names>V</given-names></string-name>, <string-name><surname>Suhane</surname> <given-names>A</given-names></string-name>, <string-name><surname>Patro</surname> <given-names>J</given-names></string-name>, <string-name><surname>Mukherjee</surname> <given-names>A</given-names></string-name></person-group>. <article-title>Code-switching patterns can be an effective route to improve performance of downstream NLP applications: a case study of humour, sarcasm and hate speech detection</article-title>. In: <conf-name>Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics; 2020 Jul 5&#x2013;10</conf-name>; <publisher-name>Online</publisher-name>. p. <fpage>1018</fpage>&#x2013;<lpage>23</lpage>. doi:<pub-id pub-id-type="doi">10.18653/v1/2020.acl-main.96</pub-id>.</mixed-citation></ref>
<ref id="ref-26"><label>[26]</label><mixed-citation publication-type="conf-proc"><person-group person-group-type="author"><string-name><surname>Poria</surname> <given-names>S</given-names></string-name>, <string-name><surname>Cambria</surname> <given-names>E</given-names></string-name>, <string-name><surname>Hazarika</surname> <given-names>D</given-names></string-name>, <string-name><surname>Majumder</surname> <given-names>N</given-names></string-name>, <string-name><surname>Zadeh</surname> <given-names>A</given-names></string-name>, <string-name><surname>Morency</surname> <given-names>LP</given-names></string-name></person-group>. <article-title>Context-dependent sentiment analysis in user-generated videos</article-title>. In: <conf-name>Proceedings of the 55th Annual Meeting of the Association forComputational Linguistics; 2017 Jul 30&#x2013;Aug 4</conf-name>; <publisher-loc>Vancouver, BC, Canada</publisher-loc>. p. <fpage>873</fpage>&#x2013;<lpage>83</lpage>. doi:<pub-id pub-id-type="doi">10.18653/v1/p17-1081</pub-id>.</mixed-citation></ref>
<ref id="ref-27"><label>[27]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Villegas</surname> <given-names>DS</given-names></string-name>, <string-name><surname>Preo&#x0163;iuc-Pietro</surname> <given-names>D</given-names></string-name>, <string-name><surname>Aletras</surname> <given-names>N</given-names></string-name></person-group>. <article-title>Improving multimodal classification of social media posts by leveraging image-text auxiliary tasks</article-title>. <comment>arXiv:2309.07794. 2024</comment>. doi:<pub-id pub-id-type="doi">10.48550/arXiv.2309.07794</pub-id>.</mixed-citation></ref>
<ref id="ref-28"><label>[28]</label><mixed-citation publication-type="other"><person-group person-group-type="author"><string-name><surname>Grover</surname> <given-names>K</given-names></string-name>, <string-name><surname>Phaneendra Angara</surname> <given-names>SM</given-names></string-name>, <string-name><surname>Akhtar</surname> <given-names>MS</given-names></string-name>, <string-name><surname>Chakraborty</surname> <given-names>T</given-names></string-name></person-group>. <article-title>Public wisdom matters! discourse-aware hyperbolic Fourier co-attention for social-text classification</article-title>. <comment>arXiv:2209.13017. 2022</comment>. doi:<pub-id pub-id-type="doi">10.48550/arxiv.2209.13017</pub-id>.</mixed-citation></ref>
</ref-list>
</back></article>