Improving the Adversarial Robustness of NLP Models by Information Bottleneck

Cenyuan Zhang, Xiang Zhou, Yixin Wan, Xiaoqing Zheng, Kai-Wei Chang, Cho-Jui Hsieh

Abstract

Existing studies have demonstrated that adversarial examples can be directly attributed to the presence of non-robust features, which are highly predictive, but can be easily manipulated by adversaries to fool NLP models. In this study, we explore the feasibility of capturing task-specific robust features, while eliminating the non-robust ones by using the information bottleneck theory. Through extensive experiments, we show that the models trained with our information bottleneck-based method are able to achieve a significant improvement in robust accuracy, exceeding performances of all the previously reported defense methods while suffering almost no performance drop in clean accuracy on SST-2, AGNEWS and IMDB datasets.

Introduction

Deep learning models in Natural Language Processing (NLP) are notoriously fragile. Small, semantics-preserving changes—such as replacing a word with its synonym (TextFooler) or swapping a few characters (TextBugger)—can completely flip a model's prediction. This vulnerability stems from "non-robust features": patterns in the data that are highly predictive for a specific dataset but are easily manipulated by an attacker. For example, a sentiment classifier might learn to rely on specific stylistic quirks rather than the actual sentiment of the words. The challenge is to build a "filter" that allows robust, task-relevant features to pass through while blocking the noisy, non-robust ones that adversaries exploit.

Methodology: The Information Bottleneck Approach

To address this, we propose a novel implementation of the Information Bottleneck (IB) principle. The IB principle seeks to find a representation $T$ that is as compressed as possible relative to the input $X$ (minimizing mutual information $I(X; T)$) while remaining as informative as possible about the target label $Y$ (maximizing mutual information $I(Y; T)$).

The IB Layer

Unlike previous attempts (such as InfoBERT) that placed a bottleneck at the initial embedding layer, our method inserts an IB layer between the final BERT output and the classifier. This placement is strategic; because BERT's higher layers contain more task-specific, contextualized information, the "filtering" process becomes more precise.

Variational Inference and Control

Since calculating mutual information is computationally difficult, we utilize a variational approximation. We minimize a loss function that combines standard Cross-Entropy (for prediction) with a Kullback-Leibler (KL) divergence term (for compression). A hyperparameter $\beta$ controls the "neck" of the bottleneck: a higher $\beta$ narrows the bottleneck, forcing more compression and filtering out more features. This method is "plug-and-play," meaning it can be combined with existing defenses like FreeLB (adversarial training) to further boost performance.

Experimental Setup

We evaluated the approach on three standard text classification benchmarks:

  1. SST-2: A binary sentiment analysis dataset of movie reviews.
  2. IMDB: A large-scale movie review sentiment dataset.
  3. AGNEWS: A four-class topic classification dataset (World, Sports, Business, Sci/Tech).

Key Results and Insights

Massive Robustness Gains

The IB-based model outperformed several state-of-the-art (SOTA) defense methods across all datasets and attack types. On the IMDB dataset under the TextFooler attack, a standard BERT-base model's accuracy plummeted to 0.8%. Our proposed IB model maintained 52.2% accuracy, which jumped to 64.3% when combined with FreeLB. Against character-level attacks like Deepwordbug, the model achieved 71.3% robust accuracy on IMDB, compared to just 24.3% for the baseline BERT model.

Preservation of Clean Accuracy

Historically, making a model robust often meant sacrificing "clean" accuracy (performance on un-attacked data). Our findings show that by filtering out irrelevant features, we can maintain—or even slightly improve—clean accuracy while drastically increasing robustness. In almost all tests, the accuracy on non-adversarial data remained within 0.1-0.5% of the baseline.

Feature Significance

By calculating "significance scores" for words, we demonstrated that the IB-enhanced model successfully ignores "stop words" and irrelevant modifiers (like "perhaps" or "the") and focuses its attention on high-impact sentiment words (like "joyless" or "slipshod"). Visualizations using t-SNE further confirmed that as the bottleneck narrows, the boundaries between classes become clearer and more distinct.

Conclusion and Limitations

This study demonstrates that the Information Bottleneck is a powerful tool for enhancing NLP robustness without the typical performance trade-offs. However, the model relies on finding the "sweet spot" for the hidden dimension size and the $\beta$ coefficient. If the bottleneck is too narrow, the model loses task-essential information. Future work will explore how this IB implementation performs on more complex NLP tasks like Natural Language Inference (NLI) or Question Answering (QA).

Summary updated

Abstract

Existing studies have demonstrated that adversarial examples can be directly attributed to the presence of non-robust features, which are highly predictive, but can be easily manipulated by adversaries to fool NLP models. In this study, we explore the feasibility of capturing task-specific robust features, while eliminating the non-robust ones by using the information bottleneck theory. Through extensive experiments, we show that the models trained with our information bottleneck-based method are able to achieve a significant improvement in robust accuracy, exceeding performances of all the previously reported defense methods while suffering almost no performance drop in clean accuracy on SST-2, AGNEWS and IMDB datasets.
BibTeX
@inproceedings{zhang2022improving,
  author = {Cenyuan Zhang and Xiang Zhou and Yixin Wan and Xiaoqing Zheng and Kai-Wei Chang and Cho-Jui Hsieh},
  title = {{Improving the Adversarial Robustness of NLP Models by Information Bottleneck}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.findings-acl.284},
}
Figure