Introduction
State-of-the-art Natural Language Processing (NLP) models, particularly those based on the transformer architecture, exhibit a notable fragility when faced with adversarial perturbations. A "textual adversarial attack"—the strategic replacement of a few words with synonyms—can frequently induce incorrect model predictions even when the semantic content remains unchanged for human readers. A primary driver of this vulnerability is model "overconfidence," where models assign near-certainty to incorrect labels under attack. This paper investigates whether Label Smoothing (LS), a common regularization technique used to calibrate model confidence, can serve as an effective, low-cost defense against discrete, word-level adversarial attacks in both in-domain and out-of-domain (OOD) scenarios.
Methodology
The research evaluates the impact of softening target labels during the fine-tuning of pre-trained models like BERT, distilBERT, and ALBERT. Two variants were tested:
- Standard Label Smoothing (LS): Distributes a smoothing factor $\alpha$ uniformly across non-target classes.
- Adversarial Label Smoothing (ALS): Assigns the uncertainty $\alpha$ specifically to the label the model currently deems least likely.
Models were subjected to three distinct word-level attacks: TextFooler (TF) and BAE (black-box synonym replacement) and SemAttack (a white-box embedding-space search). Evaluation spanned multiple benchmarks, including sentiment analysis (SST-2, Yelp, MR), topic classification (AG News), and natural language inference (SNLI, MNLI). OOD resilience was tested by transferring models between related datasets (e.g., training on SST-2 and testing on Yelp).
Results and Discussion
The empirical results demonstrate that label smoothing acts as a potent "free" defense, requiring no additional computational overhead during training while significantly enhancing robustness. As the smoothing factor $\alpha$ increases, the Attack Success Rate (ASR) consistently declines across various model architectures and datasets.
Deflating Overconfidence and Increasing Attack Cost
The core mechanism behind this robustness is the mitigation of overconfidence. By softening decision boundaries, LS forces adversarial attacks to work harder to find successful perturbations. Successful attacks against LS-trained models typically result in adversarial text with higher perplexity and lower semantic similarity to the original input. Furthermore, even when an attack succeeds, the model's confidence in the erroneous prediction is significantly lower (often by 10-15%) compared to standard models.
Performance Across Benchmarks
Quantitative analysis reveals substantial improvements in robustness with minimal impact on standard performance. For instance, on the SST-2 dataset using BERT, the success rate of the white-box SemAttack dropped from 86.41% to 54.05% when using a smoothing factor of $\alpha=0.45$. Crucially, this gain in robustness did not come at the expense of "clean" accuracy, which remained stable or even slightly improved in some cases.
Conclusion
Label smoothing is a highly effective and computationally efficient method for improving the adversarial robustness of NLP models. Its benefits are remarkably stable, persisting even when models are deployed in out-of-domain environments. While this study focused on word-level substitutions within the BERT family, the findings suggest that calibration-based defenses are a promising avenue for securing large-scale language models. Future research should explore the efficacy of LS against character-level or sentence-level attacks and its applicability to generative architectures like GPT-4.
Summary updated