Generative Adversarial Training Can Improve Neural Language Models

Sajad Movahedi, Azadeh ShakeryarXiv 2022 · DOI

Abstract

Neural language models, particularly Recurrent Neural Networks (RNNs), often struggle with generalization due to their tendency to overfit training data. While adversarial training (AT) is an effective regularization technique, traditional gradient-based methods typically double the computational cost. This paper introduces a more efficient approach that utilizes a small, secondary Generative Adversarial Network (GAN) to generate perturbations. This method achieves state-of-the-art performance on standard benchmarks with only a 20% increase in training time.

Introduction

Recurrent Neural Networks, specifically Long Short-Term Memory (LSTM) networks, are fundamental to language modeling but suffer from a persistent "generalization gap." Despite performing well on training sets, they often fail to generalize to unseen text. While dropout is a common remedy, Adversarial Training (AT) offers a more robust solution by adding small, calculated perturbations to input data. However, traditional AT methods like the Fast Gradient Sign Method (FGSM) require an additional back-propagation step to calculate optimal attacks, effectively doubling training time and limiting their scalability for large models.

Methods

The proposed framework replaces expensive gradient calculations with a GAN-based approach to generate adversarial noise.

The Adversarial Generator

Instead of relying on the main model's gradients, a secondary, single-layer LSTM acts as a generator. Its role is to produce a perturbation vector ($r_t$) for every word in a sequence, aiming to maximize the main model's prediction loss.

Joint Training and Efficiency

The main language model and the adversarial generator are trained jointly in a min-max game. To optimize performance and prevent the generator from overfitting, the authors employ an iterative method inspired by Monte Carlo simulations, applying different dropout masks to the generator's weights. Crucially, back-propagation is only performed on the first iteration of the adversarial network, treating the generator's weights as constant for subsequent iterations. This "efficiency trick" limits the computational overhead to approximately 20%.

Regularization

To ensure that perturbations do not alter the fundamental meaning of words, a regularization term ($L_{reg}$) is introduced. This keeps the magnitude of the noise proportional to the original word vector's norm.

Experimental Results

The method was evaluated using the AWD-LSTM (Asynchronized Weight-dropped LSTM) as a baseline on two standard benchmarks: the Penn Treebank (PTB) and WikiText2.

Perplexity results on PTB and WikiText2 benchmarks. The proposed method (AWD-LSTM + Adversarial Training) achieves the lowest (best) scores.

As shown in the table above, the proposed adversarial training significantly improved performance across both datasets. On PTB, the test perplexity dropped from 57.30 to 55.46. On WikiText2, it improved from 65.80 to 62.65. Notably, these results outperformed more complex architectures, including those derived from Neural Architecture Search (NAS) like DARTS, while maintaining high computational efficiency.

Discussion and Key Insights

The success of this approach highlights several key ideas:

  • Learning vs. Calculating Attacks: Neural networks can learn the distribution of effective adversarial "nudges" more efficiently than they can be calculated via gradients at every step.
  • Simplicity in Design: A simple single-layer LSTM generator was sufficient to improve a much more complex three-layer AWD-LSTM.
  • Overcoming Speed Barriers: By optimizing the back-propagation process, the authors demonstrate that adversarial robustness is achievable without doubling GPU costs.

Limitations and Future Work

While effective for RNNs, the scalability of this GAN-based perturbation method to Transformer architectures (e.g., GPT, BERT) remains an open question. Additionally, the method introduces new hyperparameters that may require careful tuning. Future research could explore even lighter-weight generators, such as simple feed-forward networks, to further reduce the 20% overhead.

Summary updated

BibTeX
@misc{movahedi2022generative,
  author = {Sajad Movahedi and Azadeh Shakery},
  title = {{Generative Adversarial Training Can Improve Neural Language Models}},
  year = {2022},
  eprint = {2211.09728},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2211.09728},
}
Figure