Alert-ME: An Explainability-Driven Defense Against Adversarial Examples in Transformer-Based Text Classification
- 22 October 2025
- journal article
- Published by Institute of Electrical and Electronics Engineers (IEEE) in IEEE Transactions on Dependable and Secure Computing
- Vol. 23 (2) , 2085-2099
Abstract
Transformer-based Text Classifiers (TTC), exemplified by models like BERT, Roberta, T5, and GPT, have showcased impressive proficiency in Natural Language Processing (NLP). Nonetheless, their vulnerability to adversarial examples (AEs) presents a substantial security concern. Existing efforts to fortify model robustness either entail high computational costs or lack transparency and interpretability. This paper introduces a holistic framework called Explainability-driven Detection, Identification, and Transformation (EDIT) to address the shortcomings of prevailing inference-time defenses. (i) EDIT employs explainability methodologies (e.g., attention maps, integrated gradients) and frequency features for automated detection and identification of perturbed words while providing insights into the model's decision-making process. (ii) Building upon detection, EDIT purifies detected adversarial examples through an optimal transformation mechanism that utilizes pre-trained embeddings and model feedback to find the best replacements for identified perturbed words. (iii) To integrate human intelligence, the framework automates the process and triggers alerts for a security analyst to ensure secure safeguards and enable proactive human feedback. We comprehensively evaluate our framework on BERT and ROBERTA, trained on four SOTA text classification datasets: IMDB, YELP, AGNEWS, and SST2. We also assess our framework against seven SOTA Word Substitution Attacks (WSA) at character, word, and multi-levels of granularity. The results show that EDIT achieves an average F-score and balanced accuracy of 89.69% and 89.70%, respectively, across all datasets and classifiers. Compared to four SOTA inference defenses, our detector is 1.22 times better in balanced accuracy (BAL_ACC) and 1.33 times better in F1-Score. It also excels in operational efficiency, being about 83 times faster in feature extraction. The identification module outperforms techniques like ReplaceScore, FreqScore, and ExplainScore, achieving 1.125 times better BAL_ACC and Recall, 1.142 times higher AUC, 1.120 times greater Precision, and 1.149 times improved F1-Score. It significantly reduces false positives and negatives by approximately 1.537 and 1.172 times, respectively. Our transformation module effectively converts adversarial examples into non-adversarial counterparts with an accuracy of 91%. EDIT identifies the necessity for human intervention with an average median accuracy of 89%. With alerts integrated, EDIT achieves an average median accuracy of 90% across all evaluated datasets, models, and types of attacks, all while maintaining computational efficiency, averaging 6.94 seconds.Keywords
All Related Versions
This publication has 44 references indexed in Scilit:
- Knowledge Mining in Cybersecurity: From Attack to Defense2022
- Generic Attention-model Explainability for Interpreting Bi-Modal and Encoder-Decoder Transformers2021
- D-Fence: A Flexible, Efficient, and Comprehensive Phishing Email Detection System2021
- Transformer Interpretability Beyond Attention Visualization2021
- MALCOM: Generating Malicious Comments to Attack Neural Fake News Detection Models2020
- Detection by Attack: Detecting Adversarial Samples by Undercover Attack2020
- Layer-Wise Relevance Propagation: An Overview2019
- The impact of class imbalance in classification performance metrics based on the binary confusion matrixPattern Recognition, 2019
- Black-Box Generation of Adversarial Text Sequences to Evade Deep Learning Classifiers2018
- Word2VecNatural Language Engineering, 2016