Subspace Defense: Discarding Adversarial Perturbations by Learning a Subspace for Clean Signals

Rui Zheng, Yuhao Zhou, Zhiheng Xi, Tao Gui, Qi Zhang, Xuanjing Huang

Abstract

Deep neural networks (DNNs) are notoriously vulnerable to adversarial attacks that place carefully crafted perturbations on normal examples to fool DNNs. To better understand such attacks, a characterization of the features carried by adversarial examples is needed. In this paper, we tackle this challenge by inspecting the subspaces of sample features through spectral analysis. We first empirically show that the features of either clean signals or adversarial perturbations are redundant and span in low-dimensional linear subspaces respectively with minimal overlap, and the classical low-dimensional subspace projection can suppress perturbation features out of the subspace of clean signals. This makes it possible for DNNs to learn a subspace where only features of clean signals exist while those of perturbations are discarded, which can facilitate the distinction of adversarial examples. To prevent the residual perturbations that is inevitable in subspace learning, we propose an independence criterion to disentangle clean signals from perturbations. Experimental results show that the proposed strategy enables the model to inherently suppress adversaries, which not only boosts model robustness but also motivates new directions of effective adversarial defense.

Introduction

Pre-trained Language Models (PLMs) like BERT, while powerful, exhibit significant fragility when faced with adversarial perturbations—small, intentional changes to input text that can drastically alter model predictions. Traditional defenses like Adversarial Training (AT) are computationally intensive, while Information Bottleneck methods are often mathematically complex. This research introduces "Subspace Defense," a method that exploits the geometric structure of feature spaces to "purify" signals by projecting them onto a learned low-dimensional subspace where clean signals reside and adversarial noise is excluded.

Theoretical Foundation: Spectral Analysis

The core insight of this work is that clean signals and adversarial perturbations occupy distinct, low-dimensional linear subspaces with minimal overlap. By performing Singular Value Decomposition (SVD) on feature representations, the authors demonstrate that both signals are redundant.

Spectral analysis and performance across different subspace dimensions (indices).

As shown in Figure 2(a), the singular values for clean signals and perturbations decay rapidly, confirming their low-dimensional nature. Crucially, Figure 2(b) and 2(c) illustrate the impact of the subspace dimension (Index) on model performance. While clean accuracy remains stable across a range of dimensions, robustness is highly sensitive, peaking at very low dimensions where the overlap with adversarial noise is minimized.

Proposed Methodology

The Subspace Defense is implemented as a Subspace Learning Module integrated into the model architecture, consisting of three main components:

  1. Linear Projection Bottleneck: Two linear layers project high-dimensional features into a small $r$-dimensional subspace and back. The choice of a linear structure is deliberate; unlike non-linear autoencoders, linear projections are more rigid and less likely to inadvertently reconstruct complex adversarial noise.
  2. Hilbert-Schmidt Independence Criterion (HSIC): To prevent residual noise from leaking into the clean subspace, HSIC is used as a loss function. It measures the statistical independence between the retained features and the discarded ones, enforcing effective disentanglement.
  3. Training Objective: The model is trained using a combination of standard adversarial loss, reconstruction loss (to ensure signal fidelity), and the HSIC independence loss.

Experimental Results

The method was evaluated on six NLP benchmarks (SST-2, IMDB, AGNews, QNLI, MNLI, QQP) against state-of-the-art attacks like BERT-Attack, TextFooler, and TextBugger.

Comparison of original adversarial examples and their projected versions, showing significant suppression of perturbation magnitude.

As visualized in Figure 6, the projection effectively suppresses the magnitude of adversarial examples. Quantitatively, the Subspace Defense consistently outperformed baselines. For instance, on the IMDB dataset under TextFooler attack, the method achieved 78.6% accuracy, a massive improvement over the 5.3% of a standard fine-tuned model and surpassing the previous state-of-the-art (RobustT) by 7%. Importantly, clean accuracy was preserved within 1% of standard models.

Discussion and Conclusion

The "Minimal Overlap" discovery suggests that adversarial noise is geometrically localized. By leveraging linear bottlenecks, the Subspace Defense provides a computationally efficient alternative to traditional adversarial training, reaching peak robustness significantly faster.

However, the method is sensitive to the subspace dimension ($r$). If $r$ is too large, noise leaks in; if too small, signal is lost. Future work may explore this geometric approach in other modalities like computer vision to determine if this subspace separation is a universal property of deep learning representations.

Summary updated

Abstract

Deep neural networks (DNNs) are notoriously vulnerable to adversarial attacks that place carefully crafted perturbations on normal examples to fool DNNs. To better understand such attacks, a characterization of the features carried by adversarial examples is needed. In this paper, we tackle this challenge by inspecting the subspaces of sample features through spectral analysis. We first empirically show that the features of either clean signals or adversarial perturbations are redundant and span in low-dimensional linear subspaces respectively with minimal overlap, and the classical low-dimensional subspace projection can suppress perturbation features out of the subspace of clean signals. This makes it possible for DNNs to learn a subspace where only features of clean signals exist while those of perturbations are discarded, which can facilitate the distinction of adversarial examples. To prevent the residual perturbations that is inevitable in subspace learning, we propose an independence criterion to disentangle clean signals from perturbations. Experimental results show that the proposed strategy enables the model to inherently suppress adversaries, which not only boosts model robustness but also motivates new directions of effective adversarial defense.
BibTeX
@inproceedings{zheng2024subspace,
  author = {Rui Zheng and Yuhao Zhou and Zhiheng Xi and Tao Gui and Qi Zhang and Xuanjing Huang},
  title = {{Subspace Defense: Discarding Adversarial Perturbations by Learning a Subspace for Clean Signals}},
  booktitle = {International Conference on Computational Linguistics},
  year = {2024},
  url = {https://openreview.net/forum?id=lmzKC7ST3k},
}
Figure