Investigating the Generalizability of Pretrained Language Models across Multiple Dimensions: A Case Study of NLI and MRC (2024)

Abstract: Generalization refers to the ability of machine learning models to perform well on dataset distributions different from the one it was trained on. While several pre-existing works have characterized the generalizability of NLP models across different dimensions, such as domain shift, adversarial perturbations, or compositional variations, most studies were carried out in a stand-alone setting, emphasizing a single dimension of interest. We bridge this gap by systematically investigating the generalizability of pre-trained language models across different architectures, sizes, and training strategies, over multiple dimensions for the task of natural language inference and question answering. Our results indicate that model instances typically exhibit consistent generalization trends, i.e., they generalize equally well (or poorly) across most scenarios, and this ability is correlated with model architecture, base dataset performance, size, and training mechanism. We hope this research motivates further work in a) developing a multi-dimensional generalization benchmark for systematic evaluation and b) examining the reasons behind models’ generalization abilities. The code and data are available at https://github.com/sagnik/md-gen-nlp, and the trained models are released at https://huggingface.co/varun-v-rao.

## introduction a machine learning model's generalization capability is defined as its capacity to apply encoded knowledge and strategies from previous experience to new situations. this is a key desideratum of all machine learning models, but nlp models are particularly interesting as the generalization scenario in nlp goes beyond the simple train-test split. we present a comprehensive study of the generalization abilities of common models used in nlp. 2023 ) categorizes the generalization scenarios in nlp into six types. we chose three that cover many important scenarios. we trained models on snli and squad, and tested them on various datasets corresponding to these dimensions. the datasets were chosen so as not to confound the dimensions. for example, the compositional test dataset for mrc (musique) is a derivative of the source dataset squad -there is no domain shift, and the dataset does not contain robustness testing perturbations. following @xcite , we consider three types of generalization: 1. domain; 2. robustness; and 3. compositional. these three multi-faceted aspects cover many scenarios with practical significance (figure 1 ). the most common type of generalization is domain generalization, where the model is trained on one domain and tested on another. generally, domains in nlp are associated with sources as text from different sources have different linguistic styles @xcite . many standard nlp datasets have data points that can be solved by superficial cues, i.e., reasoning strategies unrelated to the expected causal mechanism of the task at hand. for example, in snli, @xcite shows that a negation operator in the premise is a strong predictor of the "contradiction" class, or in many cases, the models can use the hypothesis alone to predict the class label. likewise, @xcite observed that the answer phrase could be found in the first sentence of the context for several instances in popular extractive machine reading comprehension (mrc) datasets such as squad @xcite or hotpotqa @xcite . @xcite and @xcite also show that models are sometimes thrown off by semantics preserving perturbations that do not fool humans. models also need to generalize to these instanceswe refer to this as robustness generalization. the final type of generalization we explore is compositional. a model demonstrates compositional generalization when it can methodically combine previously learned components to correctly solve new inputs composed of these components. lake and baroni (2018) presents a classic example -if a model understands that "doxing" refers to jumping up and "daxing" refers to moving left, would it realize that "dox then dax" refers to jumping up and moving left? we train 3 instances each of the base and large versions of 4 models from 3 architecture families: encoder-only (eo), decoder-only (do), and encoder-decoder (ed) on two representative datasets of two nlu tasks: snli for natural language inference (nli) and squad for machine reading comprehension (mrc) using full-training and parameter efficient fine-tuning or peft @xcite in §2. subsequently, we test them on 15 datasets from these tasks that correspond to different types of generalizations in §3. with this extensive setup, we ask the following questions: previous work has studied generalization in stand-alone cases, e.g., the datasets we have used here. methods have been proposed to improve the generalization ability of both fully tuned and peft models by meta-learning (lake and baroni, 2023) or multi-task learning @xcite . benchmarks such as unified qa @xcite have also been developed to test generalization. despite this rich history, less effort has been spent on developing a systematic categorization of generalization and studying how models generalize across such categories. models need to generalize across all scenarios, and not just be robust against domain shift or compositional variations. this work is a step in this direction. our comprehensive analysis highlights that model instances exhibit consistent generalization prowess across the board and that models from certain architectures or sizes are more generalizable than others. this is certainly not comprehensive, questions remain open about the choice and size of the base dataset, new model architectures, and most importantly, the reason behind a model's generalization ability which we defer for future work. ## tasks, datasets & models we consider two representative nlu tasks: nli and mrc. the nli task involves determining if the meaning of one text fragment (hypothesis) can be inferred from another (premise). independent of any specific application, this task is designed to encapsulate the essential inferences about the variability of semantic expression frequently required for various settings @xcite . mrc is another common task -many nlu tasks have been formulated as mrc @xcite or models trained on mrc format data have shown good performance on nlu tasks @xcite . we use the extractive version of mrc, where the input consists of a context (passage) and a question, and the answer has to be extracted from the context. ## conclusion & future work we present a systematic study on the multidimensional (domain, robustness, and compositional) generalization abilities of common models used in nlp. our main conclusions are: 1. generalizability is a model instance characteristic and not generalization type-dependent -an instance typically does not generalize well in one dimension and poorly in others. 2. it is well correlated with model size, and certain architectures and training strategies generalize better than others. 3. certain dimensions of generalization is harder to achieve compared to the others. we hope to inspire future work that looks further into the multi-dimensional aspect of generalizability and tries to understand why certain models generalize better than others.