Generalization in NLI : Ways (Not) To Go Beyond Simple Heuristics (2021)

Abstract: Much of recent progress in NLU was shown to be due to models’ learning dataset-specific heuristics. We conduct a case study of generalization in NLI (from MNLI to the adversarially constructed HANS dataset) in a range of BERT-based architectures (adapters, Siamese Transformers, HEX debiasing), as well as with subsampling the data and increasing the model size. We report 2 successful and 3 unsuccessful strategies, all providing insights into how Transformer-based models learn to generalize.

## introduction many popular nlp datasets contain spurious patterns, which get learned instead of the actual task @xcite @xcite . this raises the issue of learning methods that would avoid that problem. we present a case study of generalization to adversarial data in natural language inference (nli), reporting both positive and negative results for a range of bert-based approaches. ## methodology data. nli is a 3-class classification task: does the premise entails, contradicts, or is neutral with respect to the hypothesis? mnli @xcite is one of the most popular resources for this task, but it has been shown to suffer from both annotation artifacts @xcite and annotator bias @xcite . a cartography @xcite ) map of mnli (fig. 1 ) suggests that most of its examples are easy to learn, which explains why vanilla finetuning with modern models is sufficient to achieve high accuracy on mnli benchmark. we measure generalization of models fine-tuned on mnli with hans @xcite , a synthetic dataset targeting lexical overlap, subsequence and constituent heuristics. according to mccoy et al. ( 2019b ), a model trained on mnli is likely to learn these heuristics and thus predict the "entailment" label for most hans examples. e.g. it would incorrectly predict that "the doctor was paid by the actor" entails "the doctor paid the actor", simply because these sentences contain the same words. see appendix a for more examples. methodology. we experiment with variants foot_0 of bert @xcite , roberta @xcite , and albert @xcite . our implementation foot_1 is based on transformers @xcite and pytorch @xcite , and for two experiments we also report results with a custom pytorch-lightning trainer foot_2 . hans has 30k examples used only for testing, where we report the accuracy foot_3 . mnli test set is not public, and we report accuracy on the "matched" dev set (20k examples, 393k for training). ## experiments there are two main directions for solving the generalization challenge: modifying the training distribution and the model itself. for the former we experimented with subsampling ( §3.1), and for the latter -with bottlenecking with siamese transformers ( §3.2) and adapters ( §3.3), explicit debiasing ( §3.4), and increasing model size ( §3.5). this section presents the motivation and setup for all experiments, and all the results are shown in §4. experiments. we partition mnli based on the training dynamics of roberta-large and bertbase, and train the respective models on varying amounts of "hard" and "ambiguous" examples (preceded by 25% of "easy" samples for 2 epochs). see appendix b for more details. ## related work several studies have reported successful generalization from mnli to hans. among data-based strategies, it has been achieved via augmenting mnli data with predicate-argument structures @xcite and syntactic transformations @xcite . although there are many reports of syntactic knowledge in pre-trained bert @xcite suggest that pre-training does not yield a strong inductive bias to use syntax in downstream tasks, and augmentation "nudges" the model towards that. theoretically, subsampling that reduces the saliency of spurious patterns should have a similar effect, but our cartography-based subsampling did not work consistently, possibly because mnli has little counter-evidence to spurious patterns, and the right subsample is hard to find reliably. we have additional negative results for subsampling with k-means clustering (see appendix d for details). the idea of using shallow models to identify biases before training and "teach" the model to treat them differently has been successfully explored by utama et al. (2020), @xcite , and @xcite . our negative results with hex debiasing after training complements these reports. our results corroborate that generalization is improved by larger models @xcite and longer fine-tuning @xcite . the latter work shows that this happens thanks to the few hanslike samples in mnli: they take longer to learn, and without them longer fine-tuning does not help. a general challenge for dl-based nlp research is variability due to extraneous factors. generalization from mnli to hans may be much improved simply with a lucky fine-tuning initialization @xcite . for qa crane (2018) show that there are many other external factors (down to linear algebra library version) that also play a role, and for transformers overall implementations make a big difference @xcite . our work provides an illustration of that phenomenon in nli. the reported hans performance of vanilla fine-tuned bert-base varies in the published studies from 50.0% to 62.5%. our pytorch-lightning implementation at 4 epochs achieves 69% (avg. of 16 runs), not due to any architectural differences. overall it also has higher variability between runs, possibly due to batch size differences. ## analysis: bias under low confidence our overall ratio of positive to negative results illustrates the difficulty of the spurious patterns problem. once the model learns that some pattern is a strong signal for a label, it will over-rely on it. but how much heuristic-matching evidence does it need? in this experiment we fine-tune the base versions of bert and roberta for 4 epochs. we use the dataset cartography to identify the "hard" training samples for both models. as shown in figure 1 , the classifier has overall low confidence for the "hard" samples. we corrupt these "hard " samples by inserting extra characters randomly in 30% content words in the sequence. for example: premise: do it now, ythink think' ubout bout it later hypothesis: zthink think about it now, do it late ( r later the corrupted sequences remain relatively readable for humans, but this reduces the signal from direct lexical matches seen by the model (even with bert tokenization). note that the model has already seen these samples 4 times before corruption. we repeated this experiment with substituting, deleting and swapping characters. since the classifier confidence for the "hard" examples is low, and the perturbations are random, they could be expected to just flip the predictions in random directions, equally across mnli labels. instead, with all corruption strategies and for both models we see the pattern shown in corruption labels bert roberta character entailment +18.2 +11.9 insert neural +13.78 +0.8 contradiction -28.89 -8.4 character entailment +35.5 +20.4 substitute neural +1.6 +5.9 contradiction -23.9 -17.6 character entailment +23.8 +18.1 swap neural -1.6 +3.3 contradiction -15.5 -13.9 character entailment +31.73 +18.4 delete neural -11.2 +5.8 contradiction -10.3 -16.3 ## conclusion most supervised datasets are biased in one way or the other, and task-independent techniques to improve nlp model generalization are crucial for further advances. we experimented with 5 strategies to improve generalization of bert-class models for nli task: explicit debiasing, bottlenecking the model, adapters, data subsampling, and increasing model size. we find the latter strategy the most promising, but we also report all the negative results, which contribute to the overall knowledge about generalization in bert-based models. c stabilizing hex here we provide more details about how hex is being used. the self-attention output from bert is pooled and passed through two mlp layers to get an individual representation of each input sequence, as shown in fig. 5. we feed the pooled representation of bert and the intermediate representation of cbow into two mlps to obtain vectors u and v . we use f to represent classification layer parameterized by ξ. the output vectors f @xmath0, v ]; ξ) and f @xmath1, v ]; ξ) are concatenated along the non-batch dimension. following @xcite , we project f a : we follow a slight variation of equation 2 to smoothen the process of optimization. the addition of λ hyper-parameter has been done to ensure that inverse is carried out on a non-singular matrix. the value of λ plays a significant role in determining how these representations are being learned. in our experiments, 1e -4 worked well and was used for initializing it after which it was set as a model's parameter. we observe that pseudo-inverse of process hard, so we make u and v square matrices to obtain inverse instead. additionally, during inference time, we directly feed outputs from the main network to the mlp layer to obtain logit vectors instead of using f l . it has been reported @xcite that this doesn't have any profound impact on the logit vector and makes inference faster. we also applied l1 and l2 normalization on u and v to account for differences in scale but did not see any noticeable improvement. we found that values of λ greater than 0.0001 do not aid the network in learning.