Adversarial Training for Machine Reading Comprehension with Virtual Embeddings

Ziqing Yang, Yiming Cui, Chenglei Si, Wanxiang Che, Ting Liu, Shijin Wang, Guoping Hu · DOI

Abstract

Adversarial training (AT) as a regularization method has proved its effectiveness on various tasks. Though there are successful applications of AT on some NLP tasks, the distinguishing characteristics of NLP tasks have not been exploited. In this paper, we aim to apply AT on machine reading comprehension (MRC) tasks. Furthermore, we adapt AT for MRC tasks by proposing a novel adversarial training method called PQAT that perturbs the embedding matrix instead of word vectors. To differentiate the roles of passages and questions, PQAT uses additional virtual P/Q-embedding matrices to gather the global perturbations of words from passages and questions separately. We test the method on a wide range of MRC tasks, including span-based extractive RC and multiple-choice RC. The results show that adversarial training is effective universally, and PQAT further improves the performance.

Introduction

Adversarial Training (AT) is a popular technique where models are trained on "adversarial examples"—inputs intentionally perturbed to confuse the system—to improve overall robustness and generalization. While successful in computer vision, applying AT to Natural Language Processing (NLP) is challenging because standard approaches treat words like independent pixels in an image.

Machine Reading Comprehension (MRC) has unique characteristics that this "pixel-wise" approach ignores. First, standard AT perturbs each instance of a word independently, even if the word (e.g., "rock") appears multiple times with the same semantic meaning. Second, words in a Passage (context) and a Question (query) serve different purposes. A model needs to distinguish between the context of the source text and the specific intent of the question. To bridge this gap, we propose a role-aware adversarial training regimen that respects the structure of MRC tasks.

Methodology: PQAT

The proposed method, PQAT (Passage/Question Adversarial Training), introduces two "virtual" embedding matrices, P and Q, during the training phase. Unlike standard word embedding layers that store actual vector representations, these virtual matrices are used solely to "gather" and store global perturbations.

Global and Role-Aware Perturbations

When the model encounters a word in a passage, it pulls a perturbation from matrix P. If the same word appears in the question, it pulls a different perturbation from matrix Q. This ensures that all instances of a word within a specific role share the same perturbation, forcing the model to be robust to the concept of the word rather than just its location in a sequence.

Figure 3: PQAT uses virtual P/Q-embedding matrices to apply distinct, global perturbations to words based on their role in the passage or question.

During training, the model performs a $K$-step gradient descent to find the "worst-case" perturbations for these matrices. The final input is a combination of the original word vector, a local perturbation, and the global role-aware perturbation. Crucially, these virtual matrices are discarded after training, resulting in zero overhead at inference.

Experimental Results

We evaluated PQAT across a diverse set of MRC benchmarks, including SQuAD 1.1 and 2.0 (extractive RC), HotpotQA (multi-hop reasoning), and RACE (multiple-choice RC).

Figure 4: Main results showing PQAT performance gains over RoBERTa baselines across SQuAD, HotpotQA, and RACE benchmarks.

As shown in the results, PQAT consistently outperformed both the baseline RoBERTa models and standard Adversarial Training. In the SQuAD 1.1 Base setting, PQAT improved the F1 score from 91.54 to 92.33. Significant improvements were also noted in HotpotQA (Joint F1 increased from 69.30 to 70.40) and RACE (Accuracy improved from 74.75% to 76.32%).

Beyond standard benchmarks, PQAT demonstrated superior robustness on adversarial datasets like AddSent, where it improved the F1 score by 5% over the baseline. This indicates that role-aware perturbations make the model significantly more resilient to distracting, irrelevant information.

Conclusion

PQAT adapts adversarial training to the specific needs of MRC by introducing virtual embedding matrices that account for word identity and input roles. By treating words as semantic concepts rather than isolated pixels, PQAT achieves state-of-the-art performance and enhanced robustness across various architectures and task types. This "virtual embedding" approach could potentially be extended to other NLP tasks with distinct input roles, such as Natural Language Inference or Machine Translation.

Summary updated

BibTeX
@inproceedings{yang2021adversarial,
  author = {Ziqing Yang and Yiming Cui and Chenglei Si and Wanxiang Che and Ting Liu and Shijin Wang and Guoping Hu},
  title = {{Adversarial Training for Machine Reading Comprehension with Virtual Embeddings}},
  booktitle = {SEM},
  year = {2021},
  doi = {10.18653/v1/2021.starsem-1.30},
}
Figure