Linear Connectivity Reveals Generalization Strategies
Anonymous Authors
Abstract
It is widely accepted in the mode connectivity literature that when two neural networks are trained similarly on the same data, they are connected by a path through parameter space over which test set accuracy is maintained.
Under some circumstances, including transfer learning from pretrained models, these paths are presumed to be linear.
In contrast to existing results, we find that among text classifiers (trained on MNLI, QQP, and CoLA), some pairs of finetuned models have large barriers of increasing loss on the linear paths between them.
On each task, we find distinct clusters of models which are linearly connected on the test loss surface, but are disconnected from models outside the cluster—models that occupy separate basins on the surface.
By measuring performance on existing diagnostic datasets, we find that these clusters correspond to different generalization strategies: one cluster behaves like a bag of words model under domain shift, while another cluster uses syntactic heuristics.
Our work demonstrates how the geometry of the loss surface can guide models towards different heuristic functions.
1. Introduction
Modern training methods are capable of discovering highperformance parameters for neural networks on a variety of tasks.
Although models trained with similar procedures tend to exhibit similar in-domain (ID) performance on these tasks, they exhibit diverse decision boundaries (Benton et al., 2021).
In particular, models with similar performance often differ when presented with examples that fall far from the training data manifold (Somepalli et al., 2022).
In NLP, generalization behavior is usually characterized structurally through the use of diagnostic challenge sets.
Previous studies of model behavior on out-of-distribution (OOD) linguistic structures show that finetuned models can exhibit variation in compositional generalization and performance on challenge sets (McCoy et al., 2020;
Zhou et al., 2020).
For example, in natural language inference tasks, some models seem to deploy strategies during OOD generalization that incorporate no position information at all (McCoy et al., 2019).
To the best of our knowledge, these different generalization behaviors have never been linked to the geometry of the loss surface.
In order to explore how barriers in the loss surface expose a model’s generalization strategy, we consider the case of text classification.
We focus in particular on Natural Language Inference (NLI;
Williams et al., 2018; Consortium et al., 1996), as well as paraphrase and grammatical acceptability tasks.
We find that NLI models tend to rely on one of two strategies, both of which exhibit similar loss on the test set.
We characterize these strategies as, roughly, syntax-aware and syntax-unaware .
They fall into two respective basins; the syntax-aware basin contains functions that tend to rely on heuristics around the behavior of constituents, while functions in the syntax-unaware basin rely on lexical bag-ofwords heuristics.
We find that in NLI and paraphrase tasks, models that perform similarly on the same challenge sets are linearly connected without barriers on the ID loss surface, but they tend to be disconnected from models with different generalization behavior.
Our main contributions are:
• We develop a metric based on linear mode connectivity, the convexity gap , and an accompanying method for clustering models into basins.
In contrast with existing work in computer vision (Neyshabur et al., 2020), we find that transfer learning can lead to different basins over different finetuning runs.
• We align the basins to specific generalization behaviors.
In NLI, they correspond to a preference for either syntactic or lexical overlap heuristics.
On a paraphrase task, basins likewise split on behavior under word order permutation.
• We confirm that these basins trap a portion of finetuning runs, which
become increasingly disconnected from the other models as they train.
Based on this behavior, it may be possible to predict heuristics from early connectivity.
2. Identifying generalization strategies
Finetuning on standard GLUE (Wang et al., 2018) datasets often leads to models that perform similarly on in-domain (ID) test sets (Sellam et al., 2021).
To evaluate the functional differences between these models, we need to evaluate their generalization to diagnostic datasets.
In this paper, we study the variation of performance on these existing diagnostic
[Figure]
datasets.
We will call models with poor performance on the generalization set heuristic models while those with high performance will be generalizing models .
We study three tasks with diagnostic sets: MNLI (Williams et al., 2018) with the diagnostic set HANS (McCoy et al., 2019), QQP (Wang et al., 2017) with PAWS-QQP (Zhang et al., 2019), and CoLA (Warstadt et al., 2018) with CoLA-OOD (the last task is in Appendix A).
Natural Language Inference NLI is a common testbed for NLP models. This binary classification task poses a challenge in modeling both syntax and semantics. The input to an NLI model is a pair of sentences such as: • Premise: The dog scared the cat.
• Hypothesis: The cat was scared by the dog.
Here, the label is positive or entailment , because the hypothesis can be inferred from the premise.
If the hypothesis were, “The dog was scared by the cat”, the label would be negative or non-entailment .
We use the MNLI (Williams et al., 2018) corpus, and inspect loss surfaces on the “matched” validation set.
NLI models often “cheat” by relying on heuristics, such as overlap between either individual lexical items or syntactic constituents shared by the premise and hypothesis.
If a model relies on lexical overlap, both the entailed and nonentailed examples above might be given positive labels, because all three sentences contain “scared”, “dog”, and “cat”.
McCoy et al.
(2019) responded to these shortcuts by creating HANS, a challenge set of sentence pairs that violate such heuristics:
• Lexical overlap (HANS-LO):
Entails any hypothesis containing the same words as the premise.
• Subsequence: Entails any hypothesis containing contiguous sequences of words from the premise.
• Constituent: Entails any hypothesis containing syntactic subtrees from the premise.
Unless otherwise specified, we use the non-entailing HANS subsets for measuring reliance on heuristics, so higher accuracy on HANS-LO indicates less reliance on lexical overlap.
Paraphrase Quora Question Pairs (QQP; Wang et al., 2017) is a common paraphrase corpus.
We use the PAWSQQP (Zhang et al., 2019) dataset as the diagnostic set for identifying different generalization behaviors learnt by the models.
PAWS-QQP contains QQP sentence pairs in which the words have been permuted in order to construct pairs that can mean different things, even though the set of tokens remains the same.
In other words, PAWS-QQP contains pairs that may violate a lexical overlap heuristic.
2.1. Experimental details
All models are initialized from bert-base-uncased with a linear classification head and finetuned using
Google’s default hyperparameters.
MNLI models are those provided by McCoy et al.
3. Linear Mode Connectivity
Models discovered by SGD are generally connected by paths over which the loss is maintained (Draxler et al., 2019).
If we limit such paths to be linear, connectivity is no longer guaranteed.
We may still find, however, that two parameter settings θ A and θ B , which achieve equal loss, can be connected by linear interpolation with- out any increase in loss (Goodfellow et al., 2015).
In other words, loss L ( θ α ; X train , Y train ) ≤ L ( θ A ; X train , Y train ) and
L ( θ α ; X train , Y train )
≤
L ( θ B ; X train , Y train ) in each parameter setting θ α defined by any scalar 0 ≤ α ≤ 1 :
[Equation]
A number of results suggest that high performance is closely tied to the linear mode connectivity of the models in question (Frankle et al., 2020; Entezari et al., 2021; Neyshabur et al., 2020).
Our results complicate the narrative around linear mode connectivity (Fig. 1).
While we find that models with high performance on OOD data were indeed linearly connected to each other, models with low performance were also linearly connected to each other.
It seems that the heuristic and generalizing models occupy two different linear basins, with barriers in the ID loss surface between models in each of these two basins.
HANS performance during interpolation: It is clear from Fig.
1 that, when interpolating between LO-heuristic models, HANS-LO loss significantly improves further from the end points.
This finding implies that the heuristic basin does contain more syntax-aware models.
In contrast, the syntax-aware basin shows only a very slight improvement in heuristic loss during interpolation, even though the improvement in broad coverage loss is more substantial than in the position-unaware basin. Connections over 2 dimensions: To understand the loss topography better, we present planar views of these models using code 2 from Benton et al. We see how, in the plane covering the heuristic and generalizing models, a central barrier intrudes on the linear connecting edge between heuristic and generalizing models (Fig. 2).
On the other hand, the heuristic and generalizing models each occupy separate planes that exhibit only a small central barrier.
Visibly, this barrier is smallest for the perimeter composed of generalizing models and largest for the mixed perimeter.
These topographies motivate the following notion of an ϵ -convex basin.
One possibility we argue against is that the increasing loss between models with different heuristics is actually an effect of sharper minima in the heuristic case.
There is a significant body of work on the controversial (Dinh et al., 2017) association between wider minima and generalization in models (Li et al., 2018; Keskar et al., 2017; Hochreiter and Schmidhuber, 1997; Huang et al., 2020).
Instead, we find that clusters of linearly connected models are far better predictors of generalization behavior than optimum width is.
To identify such clusters, we define a metric based on linear mode connectivity, the convexity gap ( CG ), and use it to perform spectral clustering.
Entezari et al.
(2021) define a barrier’s height on a linear path from θ 1 to θ 2 as (for α ∈ [0 , 1] ):
[Equation]
We define the convexity gap on a linear path from θ 1 to θas the maximum possible barrier height on any sub-segment of the linear path joining θ 1 and θ 2 .
With γ, β ∈ [0 , 1] ,
[Equation]
Under this definition, an ϵ -convex basin has a convexity gap of at most ϵ within the basin.
Our metric exposes stronger clustering patterns than either area under the curve (AUC) or BH (evidence in Appendix C).
4.1. Clustering
The basins that form from this CG distance metric are visible based on connected sets of models in the distance heatmap (Fig. 4a).
To quantify basin membership into a prediction of
HANS performance, we perform spectral clustering, with the distances between points defined as CG -distance on the
ID loss surface.
Using the difference between distances from each cluster centroid ∥ w − c 1 ∥ and ∥ w − c 2 ∥ , we see a significantly larger correlation with HANS performance (Fig. 3a), compared to a baseline of the model
’s ϵ -sharpness
(Fig. 3b).
Furthermore, a linear regression model offers significantly better performance based on spectral clustering membership than on sharpness.
In Fig.
4b, we see the heuristic that defines the larger cluster: constituent overlap.
Models that perform well on constituent overlap diagnostic sets tend to fall in the basin containing models biased towards lexical overlap.
This behavior characterizes the two basins: the larger basin is syntax-aware (tending to acquire heuristics that require awareness of constituent structure), while the smaller basin is syntax-unaware (acquiring heuristics that rely only on unordered sets of words).
4.1.1. QQP
On QQP, we similarly find strong differentiation between distinct clusters of linearly connected models (Fig. 4c). As B). [Figure]
[Figure]
[Figure] [Figure] HANS-LO performance vs differ- ence between distances from the cluster centroids c 1 , c 2 in the CG -based spectral clustering space. [Figure]
[Figure]
[Figure]
[Figure]
[Figure]
[Figure]
[Figure]
|| w c
||
|| w c
||
[Figure]
Movement in metric space with training
[Figure]
in our procedure on NLI, we study the distance from the centroids formed by spectral clustering with CG defining the distance metric, and find cluster membership to be a strong predictor of generalization on PAWS-QQP (Fig. 3c).
4.2. Generalization basins trap training trajectories
At this point we have aligned different basins with particular generalization behaviors, but a skeptic may propose that the smaller cluster contains models which have simply not trained long enough.
Under this conjecture, continuing to train them would eventually place them in the larger, syntaxaware cluster.
We find that this is not the case, as shown in Fig.
Marginal members of the smaller cluster, those which fall closer to the cluster boundary, may drift towards the larger cluster later in training.
However, models that are more central to the cluster actually become increasingly solidified in their cluster membership later in training.
These results have two important implications.
First, they confirm that these basins constitute distinct local minima which can trap optimization trajectories.
Additionally, our findings suggest that early on in training, we can detect whether a final model will follow a particular heuristic.
The latter conclusion is crucial for any future work towards practical methods of directing or detecting desirable generalization strategies during training (Jastrzebski et al., 2021).
5. Conclusions
In one view of transfer learning, a pretrained model may select a prior over generalization strategies by favoring a particular basin.
Neyshabur et al.
(2020) found that models initialized from the same pretrained weights are linearly connected, suggesting that basin selection is a key component of transfer learning.
We find that a pretrained model may not commit exclusively to a single basin, but instead favor a small set of them.
Furthermore, we find that linear connectivity can indicate shared generalization strategies under domain shift, as evidenced by results on NLI, paraphrase, and linguistic acceptability tasks.
The split between generalization strategies can potentially explain results from the bimodality of CoLA models (Mosbach et al., 2021) to wide variance on NLI diagnostic sets (McCoy et al., 2020).
Because weight averaging can find parameter settings that fall on a barrier, we may even explain why weight averaging, which tends to perform well on vision tasks, fails in text classifiers (Wortsman et al., 2022).
Future work that distinguishes generalization strategy basins could improve the performance of such weight ensembling methods.
A. Linguistic Acceptability
The Corpus of Linguistic Acceptability (CoLA; Warstadt et al., 2018) is a set of acceptable and unacceptable English sentences collected from the linguistics literature.
Linguistics has a longstanding practice of studying minimal changes that render sentences ungrammatical; one CoLA example is the pair of sentences “Betsy buttered the toast” (acceptable) and “Betsy buttered at the toast” (unacceptable).
CoLA includes an ID val/test set, where the examples are taken from the same linguistics papers that the training set uses.
However, it also includes an OOD diagnostic val/test set.
The diagnostic sets are taken from a different set of linguistics papers, so in order for a model to perform well on
CoLA-OOD, it must transfer a general ability to recognize unacceptable English sentences, rather than simply learning the set of acceptability rules described in the ID sources.
A.1. Experimental details
We found that default settings on the HuggingFace (Wolf et al., 2020) training script 4 resulted in more pronounced barriers between models, compared to the Google script we used for NLI and QQP.
Because our goal is to study the relationship between barriers and generalization, we therefore chose to use Huggingface for our CoLA analysis.
Like in our other experiments, we kept the default hyperparameters, which differ slightly from the Google script.
The CoLA models were trained for 6 epochs with a learning rate of 2 × 10 − 5 , a batch size of 32 samples, and 0 weight decay.
Both scripts use the AdamW(Loshchilov and Hutter, 2017) optimizer with a linear learning rate decay schedule and no warm-up.
A.2. Clustering
In CoLA, there are very few barriers between finetuned models.
A single model out of the 48 finetuned accounted for all substantial interpolation convexity gaps (Fig. 6a), thus forming its own one-point cluster when using CG as a distance metric for spectral clustering.
This outlier model outperformed all others on OOD generalization (Fig. 6b), suggesting that CoLA is another task where models with different generalization behavior are disconnected.
B. HANS performance on subsequence heuristics
Models that perform poorly on subsequence heuristics tend to fall in the bag-of-words basin.
However, the clusters are less pronounced than for either constituent or lexical overlap heuristics (Fig. 7).
C. Alternative barrier measurements
In Fig.
8 we show NLI model clustering using the original barrier height metric
(Equation 2) from Entezari et al.
We can see that the Pearson’s correlation coefficient is − 0 .
49 , which is far lower in magnitude than correlation in the CG -metric space.
We also show the results for another metric, viz.
area under the interpolation curve (AUC), in Fig.
Although this shows the same pearson’s correlation coefficient, the clusters are much less crisp in the heatmap.
In order to compute
AUC, we add together the area between each point on the curve and the lowest point in the entire curve.
[Figure]
[Figure]
[Figure]
ce v a l A cc
[Figure]
|| w c
||
|| w c 2 || 0.
A cc . on
HAN
S - L
O pearsonr = 0.
clustercluster-
[Figure]
[Figure]
[Figure]
[Figure]
[Figure]
HANS-LO val Acc.
HAN
S - L
O v a l
A cc .
[Figure]
[Figure]
|| w c
||
|| w c
||
[Figure]
A cc . on
H
AN SL O pearsonr = 0.
clustercluster-
[Figure]
HANS-LO val Acc.
[Figure]