NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

In and Out-of-Domain Text Adversarial Robustness via Label Smoothing

Yahan Yang, Soham Dan, Dan Roth, Insup Lee

Introduction: The Fragility of Modern NLP

State-of-the-art NLP models are notoriously fragile. An attacker can often flip a model's prediction by making tiny, human-imperceptible changes to the text, such as replacing a few words with their synonyms. For instance, changing "excitement" to "exhilaration" in a specific context might cause a sentiment classifier to flip its prediction from negative to positive, despite the semantic meaning remaining largely unchanged.

An example of a text adversarial attack where a synonym substitution flips the model's sentiment prediction.

Beyond fragility, modern neural networks are often "overconfident," assigning high probability to incorrect predictions. This paper investigates whether Label Smoothing (LS), a common regularization technique used to improve calibration, can provide an "implicit" defense against these discrete, text-based adversarial attacks.

Methodology: Softening the Targets

The researchers evaluated two primary smoothing strategies across foundational models like BERT, distilBERT, and ALBERT:

  1. Standard Label Smoothing (LS): Instead of training on "hard" one-hot targets (e.g., 100% 'Positive'), the target is "smoothed" by distributing a probability mass ($\alpha$) across all other classes.
  2. Adversarial Label Smoothing (ALS): The smoothing probability is specifically assigned to the class the model currently considers least likely, increasing uncertainty during training.

These models were tested against black-box attacks (TextFooler, BAE) and white-box attacks (SemAttack) on standard benchmarks including SST-2, Yelp, AG News, and SNLI.

The core finding is that overconfidence is a primary vector for adversarial vulnerability. By forcing the model to be less certain during training, it becomes harder for an attacker to find a small perturbation that pushes the model into a high-confidence wrong answer.

Unlike adversarial training, which is computationally expensive because it requires generating adversarial examples during every training step, label smoothing is an "implicit" defense that adds zero overhead. Furthermore, when attacks do succeed against smoothed models, they often result in lower-quality adversarial text with higher perplexity, meaning the model forces the attacker to make more obvious, "noisier" changes to succeed.

Results and Analysis

The authors found that a smoothing factor of $\alpha = 0.45$ generally provided the best balance between accuracy and robustness. As $\alpha$ increases, the Attack Success Rate (ASR) consistently declines across various model architectures and datasets.

Attack Success Rate (ASR) decreases as the label smoothing factor $\alpha$ increases across different models and datasets.

Key empirical results include:

  • Significant Drop in Attack Success Rate (ASR): On the SST-2 dataset using BERT, the success rate of SemAttack dropped from 86.41% to 54.05% with label smoothing.
  • Stable Clean Accuracy: Robustness did not come at the cost of performance; clean accuracy typically remained within 0.1% to 0.2% of the baseline.
  • Reduced Adversarial Confidence: On successful attacks, the average confidence of smoothed models was significantly lower (e.g., dropping from ~78% to ~63% on SST-2), making errors easier to flag in safety-critical systems.
  • Out-of-Domain (OOD) Resilience: Label smoothing helps maintain higher adversarial resistance even under distribution shifts (e.g., transferring from Movie Reviews to SST-2).

Conclusion and Future Work

Label smoothing is a "free" and effective defense for enhancing the robustness of transformer-based NLP models in both in-domain and out-of-domain scenarios. While this study focused on word-level attacks, future work should explore character-level or sentence-level perturbations. Additionally, combining label smoothing with explicit defenses like adversarial training could yield additive benefits for model security.

Summary updated

BibTeX
@inproceedings{yang2023out,
  author = {Yahan Yang and Soham Dan and Dan Roth and Insup Lee},
  title = {{In and Out-of-Domain Text Adversarial Robustness via Label Smoothing}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-short.58},
}
Figure