Abstract
This paper introduces Adversarial Contrastive Learning (ADCL), a novel approach to enhancing the robustness of BERT-based models against word-substitution attacks. By leveraging self-supervised contrastive learning with on-the-fly "hard positive" adversarial examples, the method improves model resilience without requiring labeled data. Experimental results demonstrate significant reductions in attack success rates, particularly when combined with traditional supervised adversarial training.
Introduction
Large-scale pretrained language models like BERT are highly effective but remain vulnerable to word substitution-based attacks. In these scenarios, replacing just a few words with synonyms can cause the model to misclassify text. While adversarial training (AT) is the standard defense, it is often computationally expensive and heavily dependent on labeled data. The proposed Adversarial Contrastive Learning (ADCL) framework addresses these challenges by teaching models to align the representations of original and perturbed sentences in a self-supervised manner.
Methodology
The core of ADCL is the use of contrastive learning to pull similar examples together in vector space while pushing dissimilar ones apart.
Key technical innovations include:
- Geometry Attack: A highly efficient word-level attack that utilizes the gradient of the contrastive loss to identify directions that maximize model confusion. It is 4 to 10 times faster than existing attacks like TextFooler.
- Hard Positive Generation: Adversarial versions of inputs are generated on-the-fly during training to serve as "hard positives."
- MoCo Framework: A Momentum Contrast setup maintains a dynamic queue of negative examples, ensuring a robust and discriminative embedding space.
- Self-Supervision: The process is entirely self-supervised, allowing the model to be "robustified" using unlabeled text.
Experimental Setup
The method was evaluated on four standard benchmarks: AG’s News (topic classification), Yelp (sentiment), IMDB (sentiment), and DBpedia (topic classification). The researchers also explored out-of-domain performance by pre-training on DBpedia before fine-tuning on other tasks.
Results
The results indicate that ADCL significantly improves model robustness across various datasets and attack vectors.
Key findings include:
- ASR Reduction: On AG’s News, the Attack Success Rate (ASR) dropped from 86.2% for standard BERT to 76.5% with ADCL. Combining ADCL with supervised adversarial training (ADV) further reduced the ASR to 18.7%.
- Generalization: Training with the Geometry Attack provided defense against multiple other attack types (TextFooler, PWWS, BAE-R), demonstrating the transferability of the learned robustness.
- Representation Alignment: t-SNE analysis confirmed that ADCL effectively pulls clean and attacked sentence representations closer together, making the model invariant to perturbations.
Discussion and Future Work
While effective, ADCL performance is sensitive to MoCo queue size, as stale vectors can degrade results. Additionally, while the Geometry Attack is fast, scaling to massive datasets still requires substantial resources. Future work will focus on achieving "universal robustness" by scaling to larger, more diverse out-of-domain datasets to see if the benefits of self-supervised adversarial contrastive learning can be generalized further.
Summary updated