Domain-agnostic Question-Answering with Adversarial Training

Seanie Lee, Donggyu Kim, Jangwon Park

Introduction

Followed by the success of deep learning in various tasks, it becomes important to build a single model covering various domains without further fine-tuning to out-of-domain distribution. Because for real world application, a model is required to generalize to unseen sources of data.

In case of Question Answering (QA) task which is one of the promising areas in NLP, however, models outperforming human on SQuAD Rajpurkar et al. (2016) cannot generalize well to other datasets. Models rather overfit to a specific dataset and require additional training on other dataset to adapt to new domain Yogatama et al. (2019).

Thus, in order to build a domain-agnostic QA model which is capable of handling out-of-domain data, it is necessary for model to learn domain-invariant features rather than specific ones. In this paper, we apply adversarial training framework to train a QA model with domain-agnostic representation. As shown in Figure 1, the model is divided into two components, which are the QA model and the domain discriminator. The discriminator predicts domain label of hidden representation from QA model. During the training, the QA model tries to fool the discriminator so that the hidden representation becomes indistinguishable to the discriminator. Meanwhile the discriminator is trained to identify the domain label correctly. As a result, QA model can learn domain-invariant features. Our framework can be applied to any existing QA model because the architecture of QA model stays unchanged.

We train and validate our method on 12 datasets (6 datasets for training and 6 datasets for validation) which are provided by MRQA Shared Task. Each training dataset is considered different domain for adversarial learning in which QA model learns domain-invariant feature representation by competing with discriminator. Our experimental result shows that the proposed method improves performance compared to baseline.

Related Works

Pre-trained Language Model Recently, there have been several applications for using pre-trained language models, such as ELMo Peters et al. (2018), GPT Radford et al. (2018), or BERT Devlin et al. (2018) to transfer the knowledge from pre-training to various downstream NLP tasks.

BERT is pretrained with bidirectional encoder Vaswani et al. (2017) on large corpora. Unlike other auto-regressive language models (unidirectional or concatenation of forward and backward language model), BERT randomly masks some input tokens and predicts the masked tokens based on its context. The masked language model enables bidirectional representation, which leads to significant improvements on a number of NLP tasks, such as sentence classification, POS tagging or question answering.

Domain Generalization Even though many deep learning models surpass human-level performance on various task, they perform poorly on out-of-domain dataset. To address this problem, domain adaptation and domain generalization are proposed, making models more robust to out-of-domain data. The difference between domain adaptation and domain generalization is that for domain generalization, data from the target domain is not available during training.

Several methods for domain generalization exist. One of them is to train a model for each in-domain dataset. When testing on out-of-domain, select the most correlated in-domain dataset and use that model for inference Xu et al. (2014). Other works such as Ghifary et al. (2015); Muandet et al. (2013), model is trained to learn a domain-invariant feature by using multi-view autoencoders and mean map embedding-based techniques.

Other approaches Khosla et al. (2012); Li et al. (2017) break down parameters of a model into domain-specific and domain-agnostic components during training with in-domain dataset, and use the domain invariant parameters for predicting data from unseen target domain.

Recently, meta-learning has been proposed for domain generalization. Some methods Li et al. (2018a); Balaji et al. (2018); Li et al. (2019) leverage meta-learning framework for domain generalization. Adversarial Training The idea of adversarial training is originally proposed in the field of image generation Goodfellow et al. (2014), known as Generative Adversarial Network (GAN). GAN is also adopted in text generation Yu et al. (2017) with policy gradient for bypassing non-differentiable operation. The concept of adversarial training is not limited to the task of generation. It can be extended to text classification Chen et al. (2016); Liu et al. (2017); Chen and Cardie (2018), and relation extraction Wu et al. (2017). Likewise, attempts are made to get language-invariant features with adversarial training Chen et al. (2016); Zhang et al. (2017).

Adversarial training has been used for domain adaptation or domain generalization as well. In Domain-Adversarial Neural Network (DANN) Ganin et al. (2016), it has two classifiers: one classifies task-specific class labels, and the other classifies whether the data belong to source or target domain. Recently, One approach Li et al. (2018b) extends adversarial autoencoder by minimizing maximum mean discrepancy among different domains for domain-invariant feature representation.

Proposed Methodology

We assume that there exists domain invariant feature representation such that QA model generalize well to predict answer on unseen out-of-domain. In order to adapt to out-of-domain, adversarial learning procedure is leveraged for learning domain-invariant representation. We present our proposed method in detail in the following sections.

We formulate the task as follows: given the KK in-domain datasets Di\mathcal{D}_{i} , consisting of triplets of passage c\mathbf{c}, question q\mathbf{q}, and answer y\mathbf{y}, where Di={ci(k),qi(k),yi(k)}i=1Nk\mathcal{D}_{i}=\{\mathbf{c}^{(k)}_{i},\mathbf{q}^{(k)}_{i},\mathbf{y}^{(k)}_{i}\}^{N_{k}}_{i=1}. The model learned from {Di}i=1K\{\mathcal{D}_{i}\}_{i=1}^{K} predicts answer yjl\mathbf{y}^{l}_{j} from cjl,qjl\mathbf{c}^{l}_{j},\mathbf{q}^{l}_{j} for each LL out-of-domain datasets {Dj}j=1L\{\mathcal{D}_{j}\}^{L}_{j=1}.

2 Prediction Model

Our method can be applied to any QA models which learn representation in the joint embedding space of passage and question. In this paper, we use BERT for QA because it is pre-trained on a large corpus and known to be generalized on several different tasks. As for standard QA task, the model is trained to minimize negative log-likelihood of answer y\mathbf{y} for all the given in-domain datasets, where N,yi,sN,\mathbf{y}_{i,s}, and yi,e\mathbf{y}_{i,e} are respectively the total number of in-domain data, the start position and the end position of answer in the passage.

3 Adversarial Training

Minimizing the cross-entropy as in equation (1) does not ensure that the model will generalize on unseen domain. Rather it tends to overfit to certain datasets. Inspired by GAN Goodfellow et al. (2014), we propose a simple yet effective method to regularize the model such that it learns domain-invariant features.

In the adversarial training procedure, QA model learns to make the discriminator to be uncertain about its prediction. On the other hand, the discriminator is trained to classify the joint embedding of question and passage from QA model into the given KK domains. If the QA model can project question and passage into an embedding space where the discriminator cannot tell the difference between embeddings from different KK domains, we assume the QA model learns domain-invariant feature representation.

For the QA model, it tries to maximize the entropy of Pϕ(li(k)∣hi(k))P_{\phi}(l^{(k)}_{i}|h^{(k)}_{i}). In other words, it minimizes Kullback-Leibler (KL) divergence between uniform distribution over KK classes denoted as U(l)\mathcal{U}(l) and the discriminator’s prediction as in equation (3). Then the final loss for QA model is LQA+λLadv\mathcal{L}_{QA}+\lambda\mathcal{L}_{adv} where λ\lambda is a hyper-parameter for controlling the importance of the adversarial loss. In our experiments, we alternate between optimizing QA model and discriminator.

Experiments and Result

We validate our adversarial model for MRQA Shared Task with 6 different out-of-domain datasets, which are BioASQ (BA) Tsatsaronis et al. (2012), DROP (DP) Dua et al. (2019), DuoRC (DR) Saha et al. (2018), RACE (RA) Lai et al. (2017), RelationExtraction (RE) Levy et al. (2017), and TextbookQA (TQ) Kembhavi et al. (2017). Table 1 shows the statistics and description of these datasets. Each dataset has about 1k samples. However, the number of samples from each dataset varies. Thus, we use stratified sampling in order to make class-balanced stochastic mini-batch having certain amount of samples from all domains. We use maximum sequence length of 64 and 384 for question and passage respectively. But some examples are longer than 384. Therefore each passage is split into several chunks with a window size of 128. We discard samples without answers because all questions are considered to be answerable from given context in MRQA shared task.

Note that the final evaluation shown in the Table 2 is conducted by MRQA organizers with additional 6 out-of-domain undisclosed private test datasets, which are BioProcess (BP) Scaria et al. (2013), ComplexWebQuestion (CQ) Talmor and Berant (2018), MCTest (MC) Richardson et al. (2013), QAMR (MR) Michael et al. (2017), QAST (ST) Jitkrittum et al. (2009) and TREC (TR) Voorhees (2001).

2 Implementation Details

We implement our model based on the HuggingFace’s open-source BERT implementationhttps://github.com/huggingface/transformers in Pytorch Paszke et al. (2017). The performance of the baseline in our experiment differs from the official baseline of MRQA, which is based on AllenNLP Gardner et al. (2018). We follow the hyperparameters as BERT for our model. In detail, we use "bert-base-uncased" with a learning rate 3e-5 and a batch size of 64. Additionally, our model requires one more hyperparameter λ\lambda, which indicates the importance of adversarial loss as described in the equation (3). We find out that the value of 1e-2 for λ\lambda gives the best result in our experiments. The baseline and adversarial model are trained on V100 GPU for about 5 GPU hours. For training, we use 6 in-domain datasets, which are SQuAD, TriviaQA Joshi et al. (2017), Natural Questions Kwiatkowski et al. (2019), HotpotQA Yang et al. (2018), SearchQA Dunn et al. (2017), and NewsQA Trischler et al. (2016) provided by MRQA. We select the best performing model on validation set, where models are trained for 1 or 2 epochs. The codes for our model are available at https://github.com/seanie12/mrqa.

3 Performance Comparison

Table 2 shows the performance evaluation results of models on out-of-domain datasets. In the table, the model trained with our adversarial learning is named with ’-adv’. The top of the table is the result of validation datasets while the bottom is the result of test datasets. As shown in the table, overall, the model with adversarial learning has better performance compared to the baseline in terms of both EM and F1 measures.

For validation datasets, the average F1 score of our model is about 1.51.5 point higher than the baseline. In detail, our model outperforms the baseline in DP, DR, RC, and RA dataset by large margin. But the adversarial learning degrades performance in BA and RE. We can see the same aspect in terms of EM score. Similar to the result of validation datasets, our model shows better performance in terms of EM (Exact Match) and F1 on the most of test datasets except for ST. Overall, our model has superior performance with considerable margin of over 22 point in F1.

Discussion

In this section, we discuss some trials that have failed to improve the performance but might be helpful for future works.

QA sample consists of a question, a passage, and an answer span. There could exist multiple answer spans because more than one phrase in the passage can be matched with the answer text. For simplicity, only the first occurrence of answer text is used for training in most of the baseline codes. However, considering context and semantic of the given question and answer, a certain phrase in the passage is more likely to be plausible answer span relevant to the question. In order to find the most plausible answer span, a question and sentences in the passage are encoded into fixed-size vectors with universal sentence encoder Cer et al. (2018). We choose the span in a sentence, which is the most similar to the question in terms of cosine similarity, as golden span. In our experiment, this approach boosts up the performance of some datasets but degrades the performance a lot in the other datasets.

2 Meta Learning

We apply meta learning to domain generalization Li et al. (2018a, 2019); Balaji et al. (2018) to simulate train/test domain shift. For every epoch, one dataset is randomly selected as virtual test domain. As described in Finn et al. (2017), QA model is trained to maximize meta objective, which leads to improve the performance in train domain, but also in test domain. But this requires to compute Hessian-vector products, which slows down the training. This is even worse for BERT because there are 110M parameters to fine-tune. Moreover, contrary to the previous works, the meta learning for domain generalization does not help improve the performance.

Conclusion

We leverage adversarial learning to learn domain-invariant features. In our experiments, the proposed method consistently improves the performance of baseline and it is applicable to any QA model. In future work, we will try adversarial learning for pre-training model with diverse set of domains.

Acknowledgments

We would like to thank Seonghan Ryu, Donghyeon Lee and Nicolas Remond for their valuable feedback, as well as the anonymous reviewers for their insightful comments.

References