Masked Language Model Based Textual Adversarial Example Detection
Not on the map. Why?
Abstract (arXiv)
Adversarial attacks are a serious threat to the reliable deployment of machine learning models in safety-critical applications. They can misguide current models to predict incorrectly by slightly modifying the inputs. Recently, substantial work has shown that adversarial examples tend to deviate from the underlying data manifold of normal examples, whereas pre-trained masked language models can fit the manifold of normal NLP data. To explore how to use the masked language model in adversarial detection, we propose a novel textual adversarial example detection method, namely Masked Language Model-based Detection (MLMD), which can produce clearly distinguishable signals between normal examples and adversarial examples by exploring the changes in manifolds induced by the masked language model. MLMD features a plug and play usage (i.e., no need to retrain the victim model) for adversarial defense and it is agnostic to classification tasks, victim model's architectures, and to-be-defended attack methods. We evaluate MLMD on various benchmark textual datasets, widely studied machine learning models, and state-of-the-art (SOTA) adversarial attacks (in total 3*4*4 = 48 settings). Experimental results show that MLMD can achieve strong performance, with detection accuracy up to 0.984, 0.967, and 0.901 on AG-NEWS, IMDB, and SST-2 datasets, respectively. Additionally, MLMD is superior, or at least comparable to, the SOTA detection defenses in detection accuracy and F1 score. Among many defenses based on the off-manifold assumption of adversarial examples, this work offers a new angle for capturing the manifold change. The code for this work is openly accessible at urlhttps://github.com/mlmddetection/MLMDdetection.
Key facts. Cited by 5 papers in the map (data through 14 Oct 2026). Builds on 41 of its 56 references that are in the map. First posted on arXiv 18 Apr 2023.
Builds on
41 of 56 references.
References · 41
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2014Explaining and Harnessing Adversarial Examplescited by 7,364
- 2013Intriguing properties of neural networkscited by 5,155
- 2019ALBERT: A Lite BERT for Self-supervised Learning of Language Representationscited by 2,790
- 2015Character-level Convolutional Networks for Text Classificationcited by 2,330
- 2020Don't Stop Pretraining: Adapt Language Models to Domains and Taskscited by 1,565
- 2021Membership Inference Attacks From First Principlescited by 878
- 2016InfoGAN: Interpretable Representation Learning by Information Maximizing Generative Adversarial Netscited by 860
- 2019Is BERT Really Robust? A Strong Baseline for Natural Language Attack on Text Classification and Entailmentcited by 671
- 2017Adversarial Examples Are Not Easily Detected: Bypassing Ten Detection Methodscited by 546
- 2020BERT-ATTACK: Adversarial Attack Against BERT Using BERTcited by 491
- 2018Generating Natural Language Adversarial Examplescited by 424
29 more
- 2018TextBugger: Generating Adversarial Text Against Real-world Applicationscited by 381
- 2018Black-box Generation of Adversarial Text Sequences to Evade Deep Learning Classifierscited by 345
- 2020BAE: BERT-based Adversarial Examples for Text Classificationcited by 316
- 2020Pretrained Transformers Improve Out-of-Distribution Robustnesscited by 294
- 2018Adversarial Example Generation with Syntactically Controlled Paraphrase Networkscited by 286
- 2017MagNet: a Two-Pronged Defense against Adversarial Examplescited by 269
- 2017Generating Natural Adversarial Examplescited by 183
- 2019Combating Adversarial Misspellings with Robust Word Recognitioncited by 163
- 2020Contextualized Perturbation for Textual Adversarial Attackcited by 136
- 2019Text Processing Like Humans Do: Visually Attacking and Shielding NLP Systemscited by 101
- 2020SSMBA: Self-Supervised Manifold Based Data Augmentation for Improving Out-of-Domain Robustnesscited by 96
- 2020SAFER: A Structure-free Approach for Certified Robustness to Adversarial Word Substitutionscited by 73
- 2016A Boundary Tilting Persepective on the Phenomenon of Adversarial Examplescited by 70
- 2021Towards Robustness Against Natural Language Word Substitutionscited by 69
- 2019Learning to Discriminate Perturbations for Blocking Adversarial Attacks in Text Classificationcited by 57
- 2020Frequency-Guided Word Substitutions for Detecting Textual Adversarial Examplescited by 54
- 2020Generating Natural Language Attacks in a Hard Label Black Box Settingcited by 50
- 2020CAT-Gen: Improving Robustness in NLP Models via Controlled Adversarial Text Generationcited by 44
- 2021The Dimpled Manifold Model of Adversarial Examples in Machine Learningcited by 41
- 2019Natural Language Adversarial Defense through Synonym Encodingcited by 40
- 2021Unsupervised Out-of-Domain Detection via Pre-trained Transformerscited by 31
- 2020Defense against Adversarial Attacks in NLP via Dirichlet Neighborhood Ensemblecited by 28
- 2022"That Is a Suspicious Reaction!": Interpreting Logits Variation to Detect NLP Adversarial Attackscited by 24
- 2022Textual Manifold-based Defense Against Natural Language Adversarial Examplescited by 19
- 2021A Strong Baseline for Query Efficient Attacks in a Black Box Settingcited by 16
- 2021Detecting Textual Adversarial Examples through Randomized Substitution and Votecited by 8
- 2022Evaluating Membership Inference Through Adversarial Robustnesscited by 8
- 2021Self-Supervised Adversarial Example Detection by Disentangled Representationcited by 7
- 2022Rethinking Textual Adversarial Defense for Pre-trained Language Modelscited by 5
Built on by
Citing papers per year: 2023: 1; 2024: 0; 2025: 4.
5 papers.
- 2025BiMark: Unbiased Multilayer Watermarking for Large Language Modelscited by 21
- 2025Character-Level Perturbations Disrupt LLM Watermarkscited by 9
- 2025Exploring Gradient-Guided Masked Language Model to Detect Textual Adversarial Attackscited by 4
- 2025When Better Features Mean Greater Risks: The Performance-Privacy Trade-Off in Contrastive Learningcited by 3
- 2023Alert-ME: An Explainability-Driven Defense Against Adversarial Examples in Transformer-Based Text Classificationcited by 1
- 2025Character-Level Perturbations Disrupt LLM Watermarks11 Sep 2025
- 2025BiMark: Unbiased Multilayer Watermarking for Large Language Models19 Jun 2025
- 2025When Better Features Mean Greater Risks: The Performance-Privacy Trade-Off in Contrastive Learning6 Jun 2025
- 2025Exploring Gradient-Guided Masked Language Model to Detect Textual Adversarial Attacks8 Apr 2025
- 2023Alert-ME: An Explainability-Driven Defense Against Adversarial Examples in Transformer-Based Text Classification3 Jul 2023