Adversarial Data Augmentation for Task-Specific Knowledge Distillation of Pre-trained Transformers

Minjia Zhang, Uma-Naresh Niranjan, Yuxiong HeAAAI 2022

Introduction

Large-scale Transformer models like BERT and GPT have set new benchmarks in Natural Language Processing. However, their immense size poses significant challenges for deployment in resource-constrained environments. Knowledge Distillation (KD) has emerged as a primary technique to address this, where a compact "student" model is trained to replicate the behavior of a large "teacher" model.

While effective, KD often requires extensive data to bridge the performance gap between teacher and student. Traditional Data Augmentation (DA) methods, such as those used in TinyBERT, rely on discrete word-level substitutions. These methods suffer from high computational overhead due to synonym searches and often produce linguistically incoherent samples. This paper introduces AD² (Adversarial Data Augmentation for Distillation), a framework that moves augmentation into the continuous embedding space to improve both efficiency and performance.

Methodology: The AD² Framework

AD² shifts the focus from editing raw text to applying adversarial perturbations directly to word embeddings. This approach allows the model to explore the semantic neighborhood of the input data more effectively and efficiently.

Overview of the AD² framework, illustrating the adversarial perturbation process in the embedding space.

Key Components:

  1. Adversarial Perturbation: Instead of discrete token swapping, AD² adds a calculated noise vector ($\delta$) to the student's input embeddings (including token, position, and segment embeddings).
  2. Worst-Case Objective: Using Projected Gradient Ascent (PGA), the framework identifies the specific noise that maximizes the divergence between the student's output and the teacher's "soft labels." This creates "hard" examples that target the student's current learning gaps.
  3. Teacher-Anchored Learning: The student is trained to match the teacher's distribution even under these adversarial conditions. This ensures the student learns robust features rather than just memorizing the training set.
  4. Efficiency via PGA-1: The authors demonstrate that a single step of gradient ascent (PGA-1) is sufficient to generate effective adversarial samples, drastically reducing the computational cost compared to multi-step attacks or traditional DA.

Experimental Setup

The framework was evaluated on the GLUE (General Language Understanding Evaluation) benchmark, covering tasks in sentiment analysis (SST-2), linguistic acceptability (CoLA), and various forms of inference and similarity (MNLI, QNLI, RTE, QQP, MRPC, STS-B). The experiments focused on task-specific distillation, utilizing only the labeled data provided for each downstream task.

Key Results and Discussion

AD² demonstrates significant improvements over existing state-of-the-art distillation methods in both accuracy and training speed.

  • High Performance Fidelity: A 6-layer student model distilled with AD² retains 99.6% of the performance of a 12-layer BERT-base teacher. On average, it outperforms other task-specific KD baselines by 1.2 points across GLUE tasks.
  • Massive Speedup: By avoiding the expensive kNN searches required for synonym-based augmentation, AD² is 8.6x to 28x faster than TinyBERT's augmentation method.
Comparison of training time (in hours) between TinyBERT and AD² across various GLUE tasks, highlighting the efficiency of adversarial augmentation.
  • Regularization and Generalization: On specific tasks like QQP and RTE, the AD² student actually surpassed the performance of the original BERT-base teacher. This suggests that the adversarial training process acts as a powerful regularizer, helping the model generalize better than standard fine-tuning.
  • Effectiveness in Low-Resource Scenarios: The method proved particularly potent on smaller datasets like CoLA and RTE, where data scarcity typically leads to overfitting. By generating "hard" virtual examples, AD² forces the student to learn the underlying logic of the teacher rather than simple patterns.

Conclusion

AD² provides a highly efficient and effective alternative to traditional data augmentation for knowledge distillation. By leveraging continuous adversarial perturbations, it achieves superior performance while significantly reducing training time. As a "plug-and-play" module, it can be combined with various KD strategies to push the boundaries of model compression in NLP.

Summary updated

BibTeX
@inproceedings{zhang2022adversarial,
  author = {Minjia Zhang and Uma-Naresh Niranjan and Yuxiong He},
  title = {{Adversarial Data Augmentation for Task-Specific Knowledge Distillation of Pre-trained Transformers}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2022},
  doi = {10.1609/aaai.v36i10.21423},
}
Figure