Exploring Mode Connectivity for Pre-trained Language Models (2022)

Abstract: Recent years have witnessed the prevalent application of pre-trained language models (PLMs) in NLP. From the perspective of parameter space, PLMs provide generic initialization, starting from which high-performance minima could be found. Although plenty of works have studied how to effectively and efficiently adapt PLMs to high-performance minima, little is known about the connection of various minima reached under different adaptation configurations. In this paper, we investigate the geometric connections of different minima through the lens of mode connectivity, which measures whether two minima can be connected with a low-loss path. We conduct empirical analyses to investigate three questions: (1) how could hyperparameters, specific tuning methods, and training data affect PLM’s mode connectivity? (2) How does mode connectivity change during pre-training? (3) How does the PLM’s task knowledge change along the path connecting two minima? In general, exploring the mode connectivity of PLMs conduces to understanding the geometric connection of different minima, which may help us fathom the inner workings of PLM downstream adaptation. The codes are publicly available at https://github.com/thunlp/Mode-Connectivity-PLM.

## introduction recent years have witnessed the prevalent application of pre-trained language models (plms) in nlp @xcite , with the state-of-theart across various nlp tasks consistently being pushed @xcite @xcite . through large-scale self-supervised training, plms acquire versatile semantic @xcite and syntactic @xcite knowledge, which could be utilized when conducting transfer learning on downstream tasks. from the perspective of parameter space, plms provide generic initialization for downstream adaptation. starting from the initialization, many high-performance minima can be found through gradient-based optimization. up to now, plenty of works have studied how to effectively and efficiently adapt plms to high-performance minima, including adjusting hyperparameters @xcite , conducting transfer learning using auxiliary training data @xcite , tuning plms in a parameter-efficient way @xcite , etc. under different adaptation configurations, plms may finally reach local minima distributed in highly distinct regions. although these minima all correspond to excellent performance (low loss), little has been known about their geometric connection in the parameter space. a straightforward way to explore such geometric connection is to look into the loss landscape around different minima, which is inherently intractable due to the high dimensionality brought by the tremendous parameter size of plms. instead of probing the full landscape, we propose to investigate the relation of different minima through the lens of mode connectivity @xcite , which measures whether two different minima can be connected via a parametric path, along which the loss of the downstream task remains low. exploring the mode connectivity of plms contributes to understanding the geometric connection among different minima. such connection reflects the inherent relation of various adaptation configurations and may help us fathom the inner workings of plm downstream adaptation under different settings. to the best of our knowledge, systematic studies for the mode connectivity of plms are still lacking. in this paper, we first investigate what factors may affect plm's mode connectivity by answering the following research questions: we first consider the mode connectivity when different minima are trained on the same dataset. we investigate the effects of several hyperparameters (e.g., training data order, initialization of the tunable parameters, training steps, etc.) on plm's mode connectivity, and find that among these factors, initialization has the greatest impact. in addition, we show that fine-tuning leads to better mode connectivity than parameter-efficient delta tuning (e.g., adapter @xcite ). then we extend the connectivity analysis to minima trained on different datasets. we demonstrate that: (1) the mode connectivity is good for two minima trained on data belonging to the same distribution, but without overlap of specific instances. this means instead of memorizing training data, plms learn advanced task-level knowledge during training, and mode connectivity originates from the high overlap of task knowledge of two minima. beyond exploring the effects that could affect plm's mode connectivity, we also study the intrinsic properties of model solutions between two minima, which leads to the third question: in the experiments, we observe that for two minima obtained independently on two tasks, when traversing from the minima trained on a source task to that of a target task, a plm suffers from catastrophic forgetting @xcite on the source task, and gradually absorbs the knowledge from the target task. besides, plms prioritize forgetting those elusive source knowledge and acquiring easy-to-grasp target knowledge. in general, to fathom the connection of minima reached under different settings, we conduct empirical studies on the mode connectivity of plms. we also show that our findings may have potential significance in broad research areas, such as designing better ensemble methods for plms, understanding the task-level transferability of plms and revealing the mechanism of plm downstream adaptation. we expect our evaluation setup and findings could inspire more future works in this field. ## related work adaptation strategies of plms. to effectively and efficiently utilize the knowledge learned during pre-training, many strategies have been developed to better tune a plm, including: (1) hyperparameter search, which aims to find an optimal hyperparameter configuration through traditional grid search or modern automated search @xcite ; (2) pre-finetuning, which trains plms on intermediate auxiliary tasks before fine-tuning on a target task @xcite . in this way, plms achieve better downstream performance by taking advantage of cross-dataset knowledge transfer; (3) prompt learning, which casts downstream tasks into the form of the pre-training objective by leveraging natural language prompts @xcite . prompt learning exhibits superior performance especially under the few-shot and zero-shot scenarios; (4) delta tuning (also known as parameter-efficient tuning). optimizing all the parameters of a plm is computationally cumbersome. as a lightweight alternative, delta tuning optimizes only a few tunable parameters and keeps other parameters frozen, achieving comparable performance to fine-tuning @xcite . although plenty of adaptation strategies have been developed to better tune a plm, little is understood about the connection of local minima reached under different training configurations. in this work, we take the first step by utilizing mode connectivity as the analysis tool. mode connectivity for neural networks. despite being extremely high-dimensional, the loss landscape of neural networks exhibits a simple geometric pattern of mode connectivity @xcite @xcite . it is shown that starting from different initialization, the local minima obtained by gradient-based optimizations are often connected by low-loss paths, along which high-performance solutions could be easily found and ensembled to achieve better performance @xcite . these paths are typically non-linear curves, which require a process of curve finding with task supervision. excellent mode connectivity indicates that different minima are not isolated points in the parameter space, but essentially form a connected manifold @xcite . @xcite further contend that from the same initialization, local minima obtained with different training data order can be connected by a linear low-loss path, reducing the burden of curve finding. such a phenomenon is dubbed as linear mode connectivity, which is closely related to lottery ticket hypothesis @xcite , and has direct implications for continual learning @xcite . compared with the nonlinear counterpart, linear mode connectivity is a stronger constraint, requiring that the convex combination of two minima stay in the same loss basin. previous works typically study mode connectivity using non-pretrained models in the field of computer vision. until recently, neyshabur et al. (2020) observe linear mode connectivity on pre-trained vision models. despite the great efforts spent, a systematic understanding of the mode connectivity of plms is still lacking. in this paper, we focus on investigating the effects that would influence plm's mode connectivity and analyze the knowledge variation along the connecting path. different from existing works that study mode connectivity for minima trained on the same dataset, we additionally extend the analysis to different datasets. ## mode connectivity evaluation preliminaries. consider adapting a plm on a downstream task, let c 1 and c 2 be two distinct sets of training configurations that may differ in hyperparameters or data. we use c 1 and c 2 to train two copies of the plm independently. the specific tuning method determines the tunable parameters θ 0 . after training, θ 0 is adapted to θ c 1 ∈ r |θ 0 | and θ c 2 ∈ r |θ 0 | , respectively, where |θ 0 | denotes the total number of tunable parameters. ## empirical analysis in this section, we conduct experiments to investigate the aforementioned research questions. q1. (a) how could different hyperparameters and the specific tuning method affect the mode connectivity of plms? we first investigate the effects of several hyperparameters that could affect plm's mode connectivity, including (1) training data order, initialization of tunable parameters, training step (main paper), (2) learning rate and batch size (appendix b.1). to explore the effects of the specific tuning method, we experiment with both fine-tuning and a representative delta tuning method, i.e., adapter @xcite . adapter inserts tunable modules into a plm and keeps other parameters fixed during adaptation. unless otherwise specified, we mainly conduct the experiments using t5 base (raffel et al., 2020), and choose two representative nlp tasks (mnli @xcite and record @xcite ). ## discussion weight averaging. the property of linear mode connectivity is related to recent explorations of weight averaging @xcite @xcite , which combines independently fine-tuned models in the parameter space. in this way, the knowledge from multiple models can be merged. our findings have direct implications for designing better weight averaging methods: (1) for two minima, weight averaging can be seen as choosing the midpoint on the linear path. we have shown that a non-linear curve may have better mode connectivity under certain cases. this implicates that linear interpolation may not find the optimal combination despite its simplicity; instead, there may exist better methods to ensemble weights (see experiments in appendix b.8); (2) our findings on the effects of different training configurations can also inspire choosing more appropriate models (with better mode connectivity) to ensemble. task-level transferability. although plms are demonstrated to have excellent cross-task transferability @xcite @xcite , it is still under-explored why plms have such an ability. our findings that pre-training implicitly pulls the task boundary closer may help explain this phenomenon. since the optimal regions of various tasks are packed closely, plms are easier to traverse across the task boundary, without getting blocked by a loss barrier. knowledge quantification. investigating the knowledge variation along the connecting path helps better understand how different model knowledge is merged. quantifying the task knowledge of various models may also provide insights for research topics like knowledge distillation @xcite and knowledge transfer @xcite . while we use training data memorization as a rough estimate for task knowledge, it would be interesting to explore whether there exist more granular methods, such as knowledge probing @xcite . ## conclusions in this paper, we conduct empirical analyses on the mode connectivity of plms, aiming to fathom the connection of minima reached under different settings. we investigate how different downstream adaptation configurations and pre-training affect plm's mode connectivity. in addition, we explore the knowledge variation along the path connecting different minima. in general, exploring the mode connectivity of plms contributes to understanding the inner workings of plm downstream adaptation. we expect our evaluation setup and analyses could inspire more future explorations in this field.