April 02, 2024
Estimating the out-of-distribution performance in regimes where labels are scarce is critical to safely deploy foundation models. Recently, it was shown that ensembles of neural networks observe the phenomena “agreement-on-the-line”, which can be leveraged to reliably predict OOD performance without labels. However, in contrast to classical neural networks that are trained on in-distribution data from scratch for numerous epochs, foundation models undergo minimal finetuning from heavily pretrained weights, which may reduce the ensemble diversity needed to observe agreement-on-the-line. In our work, we demonstrate that when lightly finetuning multiple runs from a single foundation model, the choice of randomness during training (linear head initialization, data ordering, and data subsetting) can lead to drastically different levels of agreement-on-the-line in the resulting ensemble. Surprisingly, only random head initialization is able to reliably induce agreement-on-the-line in finetuned foundation models across vision and language benchmarks. Second, we demonstrate that ensembles of multiple foundation models pretrained on different datasets but finetuned on the same task can also show agreement-on-the-line. In total, by careful construction of a diverse ensemble, we can utilize agreement-on-the-line-based methods to predict the OOD performance of foundation models with high precision.
Random Head
Data Ordering
Data Subsetting
Figure 1: The ID versus OOD accuracy and agreement trends for CIFAR10 to CIFAR10C “Pixelate” in linear probed CLIP, MNLI to SNLI in full finetuned OPT, and SQuAD to SQuAD-Shifts “Amazon” in full finetuned GPT2 models. Models observe different agreement linear fits depending on the diversity source (columns) used to generate the model ensemble..
Foundation models (FM), or large models first pretrained on open world data then finetuned or prompted for a specific downstream task, have proven to be powerful solutions for many common machine learning problems. A notable trait about FMs is that they are far more robust to distribution shift than other deep learning approaches — across image and language benchmarks, they suffer a smaller performance degradation on out-of-distribution (OOD) data, that may vary substantially from the in-distribution (ID) finetuning data [1]–[6]. From clinical decision-making in different hospitals to navigating robots through unseen terrains, FMs are increasingly utilized for tasks prone to distribution shift. However, evaluating these models in OOD settings remains difficult: in many cases, acquiring labels for OOD data is costly and inefficient, while unlabled OOD data is much easier to collect. Although the field has explored other means for estimating OOD accuracy without labeled data, they are not ideal for FMs. A reliable FM performance estimator has the following desirable properties. First, the method must be computationally efficient to account for FMs’ large model size. Second, FMs are leveraged for many different tasks (e.g., classification, question-answering, regression), so the method should also be versatile across tasks. Third, as we will see, methods for finetuned FMs may require different model assumptions from neural networks trained from scratch.
Recently, [7] proposed a promising method for estimating the OOD accuracy of deep networks using the agreement between pairs of these classifiers (i.e., how often two classifiers make the same prediction). For distribution shifts where models observe a strong linear correlation in ID versus OOD accuracy – a common phenomenon in vision and language benchmarks [8], [9] – a strong linear correlation also holds for ID versus OOD agreement with extremely similar slopes and intercepts. These effects are referred to as accuracy-on-the-line (ACL) and agreement-on-the-line (AGL) respectively, and together they provide a simple method for estimating OOD accuracy via unlabeled data alone. Namely, without any OOD labels, we can instead measure the linear fit of ID versus OOD agreement as a proxy for the linear fit of ID versus OOD accuracy. We can then verify whether ACL holds using the correlation strength of agreement’s linear trend and estimate each model’s OOD accuracy by linearly transforming ID accuracy using this approximate slope and bias. This simple approach has shown reliably predict the OOD accuracy of models within a few percentage points across classification and question-answering tasks.
Unfortunately, while the method has several practical advantages, it is unclear whether finetuned FMs also observe the necessary AGL phenomena. Intuitively, a prerequisite to observing AGL is a diverse ensemble of classifiers. Since OOD accuracy falls below ID accuracy, if the linear trend in ID versus OOD agreement is to match that of accuracy, models must also agree much less OOD than ID. For this to happen, errors between any two models must be sufficiently decorrelated. [7] observes AGL in ensembles of neural networks trained for hundreds of epochs from scratch where it is conceivable that the stochasticity between training runs leads to large divergences in the weight space, and corresponding models have diverse OOD predictions. However, in the case of finetuned FMs, models are much closer in the weight space. FMs are often either linear probed over the same pretrained weights or full finetuned for a few epochs with a small learning rate and intuitively, such light finetuning may lead to models that “revert back” to their pretrained behavior to make highly correlated predictions OOD.
This raises the question: can we enforce AGL in this paradigm of lightly finetuning heavily pretrained models? In this work, we conduct an extensive study across several modalities, e.g., CLIP-based image classification and LLM-based question-answering, and training regiments, e.g., full finetuning and linear probing, to understand when AGL holds for finetuned FMs. We first investigate whether AGL appears in an ensemble of finetuned models from a single base FM. To collect a deep ensemble, the following sources of diversity can be injected into the finetuning process: 1) random initialization of the linear head; 2) random data ordering; and 3) random data subsetting. We find that not every source of diversity during fine-tuning on ID data manifests in sufficient diversity OOD, breaking the matching linear fits in ID versus OOD accuracy and agreement. Interestingly, finetuning models from different random initializations of the linear head consistently induces AGL in the resulting ensemble across benchmarks. In contrast, neural networks trained from scratch observe AGL irrespective to these diversity sources.
Second, we show that finetuned models from multiple different base FMs can be leveraged for AGL-based performance estimation. As base FMs can be pretrained with entirely different datasets, architectures, and training regiments, the linear trends in ID versus OOD accuracy and agreement may break altogether in such ensembles. Indeed previous works indicate that on vision tasks, FMs pretrained on different image corpora can have different levels of OOD robustness for the same ID performance [1], [10], [11]. On the contrary, we find that on language tasks, FMs pretrained on different text corpora observe both AGL and ACL across question-answering and text classification tasks.
In total, we develop simple techniques for applying AGL-based performance estimation methods to predict the OOD performance of foundation models. We demonstrate that the AGL phenomenon is not limited to ensembles of neural networks trained from scratch. By simply finetuning FMs from random initializations of the linear head, we can observe the phenomena in FMs across a wide variety of tasks (classification, question-answering) and modalities (vision, language) and training procedures (linear probing, full finetuning). We find that AGL is the only method to accurately estimate the performance of finetuned FMs across all tasks, surpassing other performance estimation baselines by a significant margin as large as \(20\%\) mean absolute percentage error.
We are interested in evaluating models that map an input \(x \in {\mathbb{X}}\) to a discrete output \(y \in {\mathbb{Y}}\). In particular, we finetune foundation models. For a base model \(\mathsf{B}\), let \(f(\mathsf{B})\) denote a finetuned version of \(\mathsf{B}\). In this work, we consider a variety of foundation models: GPT2 [2], OPT [12], Llama2 [13], BERT [6], and CLIP [1].
We have access to labeled data from some distribution \(\mathcal{D}_\text{ID}\) that we use for obtaining \(f(\mathsf{B})\) from \(\mathsf{B}\). In this work, we consider the following standard finetuning procedures.
Linear probing (LP): Given features from the base model \(\mathsf{B}_\theta\), we train a linear head \(v\) such that the final classifier maps the score \(v^\top \mathsf{B}_\theta(x)\) to a predicted class. We randomly initialize \(v\) and update \(v\) via gradient steps on a suitable loss function. The base model parameters remain frozen. We refer to \(v\) as either a linear probe (classification), or span prediction head (question-answering) depending on the task.
Full finetuning (FFT): We update all parameters of the backbone \(\mathsf{B}_\theta\) and the linear head \(v\) using a small learning rate. When infeasible to update all parameters, we perform low-rank adaptation (LoRA) [14] to reduce the number of trainable parameters while still effectively updating the feature extractor \(\mathsf{B}_\theta\). In this work, we do not distinguish between LoRA and FFT as they conceptually achieve the same effect, and seem to show similar empirical trends in our studies.
Given access to a labeled validation set from \(\mathcal{D}_\text{ID}\) and unlabeled samples from a related but different distribution \(\mathcal{D}_\text{OOD}\), our goal is to estimate performance on \(\mathcal{D}_\text{OOD}\). We consider the standard performance metrics for various tasks: Accuracy \(\ell_\text{0-1}:{\mathbb{Y}}\mapsto [0,1]\) for classification, and Exact Match \(\ell_\text{EM}:{\mathbb{Y}}\mapsto [0,1]\) and Macro-averaged F1 score \(\ell_\text{F1}: {\mathbb{Y}}\mapsto [0,1]\) for question-answering. We use \(\ell\) to denote the appropriate metric in the context.
There is rich literature on OOD performance estimation for deep networks, with a variety of proposed approaches. Initial works focused on upper bounding the degree of distribution shift through data and/or model dependent metrics, e.g., uniform convergence bounds using \(\mathcal{H}\)-divergence [15]–[18]. However, these bounds tend to be loose for deep networks [8]. The following works try to estimate the performance exactly.
For classification, a popular approach is to leverage the model’s confidence to predict the OOD performance [19]–[23]. Since deep models are typically overconfident, it is common practice to first calibrate these models in-distribution by temperature scaling. On a related note are uncertainty quantification works that directly try to calibrate models under distribution shift [24]–[26]. Confidence based methods are commonly utilized in practice, and favorable for foundation models as they are not computationally intensive and model-agnostic. However, they do have a couple downsides. Namely, they often fail in the presence of large shifts [21] and are often only well-defined for accuracy and ill-defined for other common metrics like F1 score. These can be limiting factors for foundation models which are applied to a broad array of tasks. Still, as they are the most common estimation methods, we utilize them as the baselines in our work.
Another approach involves measuring model behavior on known auxiliary tasks to understand how the model will behave under the distribution shift at hand [27]–[29]. These approaches however tend to be overfit to specific datasets or modalities. Similar to AGL, there are prediction methods that utilize information from ensembles. Oftentimes a separate “reference” ensemble is trained on some objective to predict the performance of a “target” model [30]–[32]. These methods generally have a much higher computational cost than AGL. Although AGL also requires at least 3 models to compute agreement between, these models only undergo generic finetuning. Thus, it is better suited approach for evaluating foundation models, especially if off-the-shelf finetuned models are readily available, e.g., from Huggingface (see Section 4).
Overall, there is growing attention towards understanding the safety and reliability of foundation models. To understand the effective robustness of FMs under distribution shift, recent works focus on studying the “accuracy-on-the-line” phenomena [8] which we cover in more detail in the next subsection and designing benchmarks that try to expose different failure modes of large models [33], [34]. On the other hand, unsupervised OOD performance estimation has been underexplored in this modern setting, in terms of new methods and the transferability of old methods to large pretrained models.
We are interested in adapting the method “agreement-on-the-line” (AGL) [7] for OOD estimation as it obtains state-of-the-art performance estimation across a wide variety of distribution shifts. AGL is based on an earlier observation called “accuracy-on-the-line” (ACL) — across common distribution shift benchmarks, there is a strong linear correlation between the ID and OOD performance of models [8], [11], [35]–[39]. ACL has been observed in foundation models for image classification, e.g., CIFAR10C [20], ImageNetV2 [36], FMoW-WILDS [40], and question-answering, e.g., SQuAD-Shifts [39]. However, ACL does not always hold, e.g., Camelyon-WILDS [8] and SearchQA [9].
While ACL is a striking phenomenon, it does not immediately provide a practical method to estimate OOD performance—computing the linear fit of ID versus OOD accuracy requires labeled samples from \(\mathcal{D}_\text{OOD}\). Alternatively, [7] suggests that we can estimate this linear trend exactly using only the agreement between neural networks. Formally, given a pair of models \(f_1\) and \(f_2\) that map inputs to labels, accuracy and agreement is defined as \[\begin{align} \mathsf{Acc}(f_i) = \mathbb{E}_{x,y \sim \mathcal{D}}[\ell(f_i(x), y)], ~~ \mathsf{Agr}(f_1, f_2) = \mathbb{E}_{x,y \sim \mathcal{D}}[\ell(f_1(x), f_2(x))], \end{align}\] where \(\ell\) is the appropriate performance metric of interest. While accuracy requires access to the ground truth labels \(y\), note that agreement only requires access to unlabeled data and a pair of models. [7] observes that when ID versus OOD accuracy is strongly linearly correlated between neural networks, i.e., ACL, then the ID versus OOD agreement of pairs of these models also observe a strong linear correlation with the same linear slope and bias. Furthermore, when accuracies do not show a linear correlation, agreements also do not. This coupled phenomenon is dubbed “agreement-on-the-line” (AGL).
[7] uses AGL for OOD performance estimation: one may obtain the slope and bias of the agreement line with unlabeled data, and then estimate the OOD performance by linearly transforming the ID validation performance. As in [7] and [8] we apply probit scaling to the accuracies and agreements, which induces a stronger linear fit. We refer the reader to [7] for formal AGL-based performance estimation algorithms (ALine-S and ALine-D), which we also provide in Appendix 7.1.1.
We first evaluate whether AGL appears in an ensemble of multiple finetuned runs of a single base foundation model. This would enable precise OOD performance estimates for each ensemble member. A practitioner may naively gather a finetuned ensemble by training a couple runs with different seeds or hyperparameters. However, an overriding concern is that even with some randomness in the finetuning process, linear probing or light full finetuning over the same base model may lead to solutions with very correlated predictions. We extensively evaluate the following methods of introducing diversity into the finetuning process to see what approach (if any) can lead to AGL.
Random linear heads We initialize the last layer of the network (i.e., the linear head) randomly, instead of via some zero-shot or pre-specified manner.
Data ordering We present the same training data to each model but shuffle the order of the data, i.e., model observes different minibatches.
Data subsetting We i.i.d. sample \(p\%\) subset of the data to train over. In the main body, we report models trained on independently sampled \(10\%\) of the training data, other proportions of \(30\%\) and \(50\%\) are reported in Appendix 7.4.
We perturb one source of diversity at a time and study whether AGL occurs in each resulting model ensemble. For each setting, we also vary the number of training epochs to collect models with different ID performances, which is necessary to obtain a meaningful linear correlation in accuracy. The additional randomness induced by varied training epochs does affect any conclusions we make in this section.
We first investigate the effect of diversity source on AGL behavior for vision benchmarks. For image classification, a common pipeline is to finetune over a CLIP [1] pretrained foundation model.
We finetune over OpenCLIP ViT-B/32 model trained on LAION-2B [41]. Given its well-established zero-shot capabilities, a popular method of finetuning CLIP is to simply employ linear probing on top of the CLIP representation. We take particular interest in evaluating the OOD performance of an ensemble of linear models trained on top of frozen base model representations.
We evaluate ensembles on synthetic corruptions (CIFAR10C, CIFAR100C, ImageNetC), dataset replication shifts (CIFAR10.1, ImageNetV2), style shifts (OfficeHome), geographical and temporal shifts (FMoW-WILDS, iWildCam-WILDS), and interlaboratory shifts in medicine (Camelyon17-WILDS). iWildCam-WILDS exhibits weak ACL and Camelyon17-WILDS doesn’t exhibit any ACL [8]. We test on iWildCam-WILDS and Camelyon17-WILDS to verify AGL’s negative condition, i.e., when the linear correlation does not exist in ID versus OOD accuracy, it also does not exist in agreement.
ID | OOD |
---|---|
CIFAR10 [42] | CIFAR10C [20], CIFAR10.1 [35] |
CIFAR100 [42] | CIFAR100C [20] |
ImageNet [43] | ImageNetC [20], CIFAR10.1 [35] |
FMoW ID [40] | FMoW OOD [40] |
iWildCam ID [40] | iWildCam OOD [40] |
Camelyon17 ID [40] | Camelyon17 OOD [40] |
OfficeHome [44] | All (ID, OOD) pairings of domains Art, ClipArt, Product, Real World |
MNLI [45] | MNLI-Mismatched [45], SNLI [46] |
SQuAD [47] | SQuAD-Shifts [39] |
Figure 2: In ensembles with diverse random initializations, ACL and AGL holds across benchmarks in linear probed CLIP models. Similar to [7], neither ACL nor AGL holds for the Camelyon17-WILDS.
Across vision benchmarks, linear probed CLIP models observe ACL meaning there is a strong linear correlation in the ID versus OOD performance. Similarly, on the same datasets, we can observe a corresponding strong linear correlation in agreement across ensembles injected with diversity in linear head initialization, data ordering, and data subsetting (Figures 1). However, we find that only ensembles with diverse initialization leads to AGL where the linear trend of agreement and accuracy matching slope and bias (Figure 2). See Appendix 7.3.2 for results on other datasets. In model ensembles obtained by data ordering and data subsetting, we observe a consistent trend where the agreement trend observe a much higher slope close to the diagonal \(y = x\) line. These results are not specific to linear probing alone. In full finetuned CLIP models, we also observe that random linear heads induce the most reliable AGL behavior (See Appendix 7.3). Note that this setting is still notably different from [7] where models are heavily trained for tens to hundreds of epochs often with a large learning rate, which causes AGL behavior to be more robust to the source of diversity used to induce the ensemble (See Appendix 7.3.4).
We conduct a similar systematic investigation of AGL in finetuned runs of a single base language model. Similar to CLIP linear probing, we find that AGL cannot be observed without random head initialization in language models evaluated on text classification and question-answering tasks.
We evaluate over a collection of \(450\) full finetuned runs of several base FMs: GPT2-Medium [2] and OPT-125M [12]. Models are full finetuned for up to \(20\) epochs with a small learning rate (\(\leq 1e^{-6}\)). Hyperparameters specifics can be found in Appendix 7.2. We do not conduct a linear probing study for question-answering as it leads to poorly performing models. For text classification, we also conduct a linear probing study in Appendix 7.5.
We test models on a text classification shift from MNLI [45] in the GLUE benchmark [48] to MNLI-Mismatched [45] and SNLI [46]. We also evaluate extractive question-answering models on the shift from SQuAD v1.1 [47] to SQuAD-Shifts [39].
We evaluate models on accuracy for text classification and F1 score for question-answering. Similar to our findings in CLIP, in both text classification and question-answering benchmarks, ensembles of full finetuned LLMs observe AGL when models are trained from different randomly initialized linear or span heads while data ordering and data subsetting observe an agreement trend closer to the diagonal \(y = x\) line (Figure 1 and Appendix 7.5). We note that with full finetuning, the differences in AGL behavior between diversity sources are not as stark as with linearly probed models. In some sense, how model diversity is achieved is becomes increasingly less important for observing AGL as the base model parameters also diverge, with ensembles of models heavily trained from scratch at the extreme [7].
max width=
Across image and language modalities, we demonstrate that ensembles of finetuned FMs can also observe agreement-on-the-line like to heavily trained CNN’s [7]. A natural hypothesis about finetuning a single base FM may be that heavy pretraining and light finetuning leads to downstream models with highly correlated behavior under distribution shift. However, simply randomizing the initialization of the linear head alone induces sufficiently decorrelated models for observing AGL. The diversity in the ensemble becomes important when predicting the OOD performance of models using downstream AGL-based methods. In Table [tab:diversity95table], we show that AGL-based methods can only accurately predict the OOD performance of models in ensembles with diverse initialization, while methods fail for ensembles with diverse data subsetting or ordering.
Furthermore, our findings contrast to previous works that suggest AGL is a neural-network specific phenomenon [7], [49], unlike ACL which is model agnostic [8]. Specifically, [7] reports that linear models trained on top of the flattened CIFAR10 images do not observe AGL. However, we find that, on top of CLIP features, linear models can exhibit AGL with random initialization. Previous works on the Generalization Disagreement Equality [50] also contend that data subsetting leads to the most diversity in model predictions. Specifically, in-distribution, the agreement rate between pairs of models was shown to equal their expected accuracy in ensembles with diverse data subsetting, while diverse random initialization leads to slightly higher agreement [50], [51]. On the other hand, out-of-distribution, we find that randomizing the linear head is important for diverse predictions and AGL behavior.
Alternatively, we consider a scenario where the ensemble consists of multiple base foundation models. First, it is unclear whether ACL itself holds amongst such models. The base models are heavily pretrained on different data corpuses which may cause respective downstream models to have different ID versus OOD accuracy trends or “effective robustness” [10]. On vision tasks, for example, linear probing over CLIP, EfficientNet [52], ViT [53], and BYOL [54] observe varying robustness trends [1]. Second, even when ACL does indeed hold, it is unclear whether these model ensembles will also observe AGL. Here the problem is seemingly different from the single base model setting: any pair of foundation models finetuned from different base models may agree too little, or OOD agreement rate may vary across model pairs depending on the similarity of the pretraining corpus, breaking the linear correlation of agreement entirely. Yet, we observe that for language models and tasks, ensembles of finetuned FMs from a wide range of base models observe both ACL and AGL.
We finetune models from OPT-125M, OPT-350M, OPT-1.3B [12], GPT2, GPT2-Medium, GPT2-Large, GPT2-XL [2], GPT-Neo-135M [55], Llama2-7B [13], Alpaca-7B [56], and Vicuna-7B [57]. We full finetune OPT and GPT models and LoRA finetune Llama, Alpaca, and Vicuna. These models are pretrained on different mixtures of BookCorpus [58], Stories [59], PILE [60], CCNews v2 corpus, and PushShift.io Reddit [61]. Alpaca and Vicuna are additionally instruction-finetuned over Llama2.
Figure 3: AGL can be observed between models finetuned from different base models (Llama, GPT, OPT) for the F1 score for question-answering shift (SQuAD to SQuAD-Shifts) and accuracy for text classification (MNLI-Matched to MNLI-Mismatched and SNLI).
We investigate the AGL behavior of an ensemble of foundation models finetuned from diverse base models in Figure 3 for question-answering. First note that base LLM models pretrained on different text corpora lead to finetuned models that lie on the same linear trend in accuracy. Unlike the different accuracy trends observed by different vision foundation models [2], we suspect that the pretraining datasets for the language models in our study observe much more homogeneity. Second, the ID versus OOD agreement between pairs of models in this ensemble, including those between different base foundation models, is also strongly correlated and the slope and intercept closely matches that of accuracy. In other words, ensembles of different base models also observe AGL without any special regularization for ensemble diversity.
By constructing a diverse ensemble of foundation models, we can leverage AGL to extract precise estimates of model performances under distribution shift. We construct diverse ensembles by collecting models trained from randomly-initialized heads (Section 3) and different base models (Section 4). For image classification, our model collection consists of just the former, i.e., linear models over CLIP representations. For text classification and question-answering, we include GPT, OPT, Llama models individually full finetuned from differently initialized heads. Table [tab:ALine95comparison], we compare the Mean Absolute Percentage Error (MAPE) of AGL-based prediction algorithms, ALine-S and ALine-D [7], to other baselines.
We compare against confidence based methods ATC [21], AC [62] and DOC-Feat [23] and Naive Agreement which directly uses agreement between model pairs as a proxy for their average accuracy [50], [63]. For confidence based methods, we first temperature scale the models using ID validation data, and pick the lower error rate from the estimations obtained with and without temperature scaling. Since confidence baselines are designed to estimate the accuracy metric on classification tasks, there are several limitations when attempting to naively apply the baselines to estimate performance on question-answering. First, there is no easy analogous formulation of confidence baselines for the F1 score, so we estimate the exact-match score instead for fair comparison. On the other hand, note that AGL can predict the performance of models across metrics accuracy, F1, and exact-match. Second, extractive question-answering is a joint classification task where models predict both the start and end token index of the answer span in the context. More details for how we calibrate baselines for this setting is provided in Appendix 7.1.2.
Note that ALine-S and ALine-D only provide estimation guarantees in circumstances where the linear correlation in agreement is strong. Consistent with [7], we filter out datasets with low correlation strength \(R^2 \leq 0.95\). These shifts include iWildCam-WILDS, Camelyon-WILDS, and a few corruptions in CIFAR10C, CIFAR100C, and ImageNetC. We evaluate ALine-S/D for these specific failure cases in Appendix 7.1.3. Across datasets that observe a strong linear correlation in agreement, ALine-S and ALine-D provide precise estimates of OOD performance in finetuned foundation models, surpassing other baselines by a large margin. In particular, they perform notably better on question-answering task SQuAD, with the next best confidence method achieving as large as \(20\%\) higher error.
max width=
We develop methods for extending AGL to foundation models to enable OOD performance prediction in this emerging paradigm. We find that utilizing AGL for performance estimation requires a careful tuning of ensemble diversity. Unlike the original paradigm of AGL, where models observed tens or hundreds of epochs of training on the ID dataset, we find that randomness in specific optimization choices, especially linear head initialization, is crucial for foundation models. In fact, in contrast to [7], we find that linear models can also observe AGL, specifically in the CLIP representation space, suggesting that AGL may not be a neural network specific phenomena.
Our conclusion on AGL also sheds light on the robustness of foundation models. First, our experiments show that light finetuning alone can corrupt models to have diverse behaviors. Next, in contrast to vision models, where previous works show different forms of pretraining lead to different slopes in the linear correlations [1], a term that is often called “effective robustness”, we find that all the language models we evaluate, e.g., OPT, GPT2, GPT2-Neo, Alpaca, Llama, lie on the same accuracy line. This is particularly intriguing because it goes against the common wisdom that the pretraining data influences the models’ effective robustness. We leave these questions for future analysis.
ALine algorithms are the AGL-based performance estimation methods proposed in [7]. When the AGL phenomenon occurs, i.e., models observe a strong linear correlation in both ID versus OOD agreement and accuracy with matching slopes and biases, algorithms ALine-S and ALine-D effectively apply the linear transformation calculated using agreements to map the ID performances to OOD performance estimates. We describe the algorithms in more detail below.
Provided a collection of models \(\mathcal{F} = \{f_1, f_2, ..., f_n\}\), AGL suggests that ID versus OOD accuracy observe a strong linear correlation if and only if ID versus OOD agreement observes a strong linear correlation and when they do, the slopes and biases match: \(\forall f_i, f_j \in \mathcal{F}\) where \(i \neq j\)
\[\begin{gather} \Phi^{-1}(\text{Acc}_{\text{OOD}}(f_i)) = a \cdot \Phi^{-1}(\text{Acc}_{\text{ID}}(f_i)) + b \\ \Updownarrow \quad \\ \Phi^{-1}(\text{Agr}_{\text{OOD}}(f_i, f_j)) = a \cdot \Phi^{-1}(\text{Agr}_{\text{ID}}(f_i, f_j)) + b \end{gather} \label{eq:AGL}\tag{1}\]
\(\Phi^{-1}\) is the probit transform used to induce a better linear fit as used in [7] and [8]. Provided access to \(\text{Acc}_{\text{ID}}(f_i), \text{Agr}_{\text{ID}}(f_i, f_j), \text{Agr}_{\text{OOD}}(f_i, f_j) \;\forall i, j\), we’d like to estimate \(\text{Acc}_{\text{OOD}}(f_i)\) for all \(f_i \in \mathcal{F}\).
The algorithm ALine-S simply estimates the the slope \(a\) and bias \(b\) of accuracy by computing the linear fit of agreement.
\[\label{eq:your95label} \hat{a}, \hat{b} = \arg \min_{a, b \in \mathbb{R}} \sum_{i \neq j} \left( \Phi^{-1}(\hat{\text{Agr}}_{\text{OOD}}(f_i, f_j)) - a \cdot \Phi^{-1}(\hat{\text{Agr}}_{\text{ID}}(f_i, f_j)) - b \right)^2\tag{2}\]
With \(\hat{a}\) and \(\hat{b}\), we estimate \({\text{Acc}_{\text{OOD}}}(f_i) \approx \hat{a} \cdot {\text{Acc}_{\text{ID}}}(f_i) + \hat{b}\). This method is called Aline-S.
This method instead constructs the following system of linear equations. Provided the relation in Equation 1 , one can derive that for any \(f_i, f_j \in \mathcal{F}\),
\[\begin{align} &\frac{1}{2}\left(\Phi^{-1}(\text{Acc}_{\text{OOD}}(f_i)) + \Phi^{-1}(\text{Acc}_{\text{OOD}}(f_j))\right) \\ &\approx \Phi^{-1}(\text{Agr}_{\text{OOD}}(f_i, f_j)) + \hat{a} \cdot \left(\frac{\Phi^{-1}(\text{Acc}_{\text{ID}}(f_i)) + \Phi^{-1}(\text{Acc}_{\text{ID}}(f_j))}{2} - \Phi^{-1}(\text{Agr}_{\text{ID}}(f_i, f_j))\right) \end{align}\]
Treating \(\text{Acc}_{\text{OOD}}(f_i) \;\forall i\) as unknown variables, note that the right hand side is known and we can construct a linear system of equations using all \(n \choose 2\) pairs of models. The algorithm employs least squares to solve this approximate system of linear equations.
We compare ALine against confidence-based methods ATC [21], AC [62], and Doc-Feat [23]. These methods notably perform better after calibrating the models ID by temperature scaling.
For classification tasks, we optimize a temperature \(T\) for each model \(f\) on the cross-entropy loss over the in-distribution validation data. \[\begin{align} \min_T \sum_{x, y} \mathsf{CE}(\sigma(f(x) \exp(T)), y) \end{align}\] where \(\sigma(\cdot)\) is the softmax.
For extractive question-answering tasks, the model has to predict two labels – the start and end token index \(y = [y_s, y_e]\) of the context span that answers the question. For each model, we attach a span prediction head \(v = [v_s, v_e] \in \mathbb{R}^{d \times 2}\) on top of the base \(\mathsf{B}_\theta(x) \in \mathbb{R}^{d \times N}\) where \(N\) is the token length of \(x\). \(s(x) = v_s^\top \mathsf{B}_\theta(x)\) and \(e(x) = v_e^\top \mathsf{B}_\theta(x)\) predict the start and end token index, respectively.
We’re interested in evaluating question-answering models on the exact match (EM) objective, \[\begin{align} \mathsf{EM}(\hat{y}, y) = \mathbb{1}\left[{\hat{y}_s = y_s}\right] \cdot \mathbb{1}\left[{\hat{y}_e = y_e}\right] \end{align}\]
EM treats question-answering as a classification problem over \(N \times N\) choices of start and end index pairs. This allows us to utilize confidence-based methods that are designed for classification tasks. We can calculate the model confidence for index pair \([i, j]\) as \(\sigma(s(x))_i \cdot \sigma(e(x))_j\).
We jointly optimize a separate temperature for the start and end logits \(T_s\) and \(T_e\) and we minimize the cross-entropy loss over the in-distribution validation data. \[\begin{align} \min_T \sum_{x, y} \mathsf{CE}(\sigma(s(x) \exp(T_s)) \sigma(e(x) \exp(T_e))^\top , y) \end{align}\]
In this section, we present a comparison with ProjNorm [31], a method that yields a score which is shown to be correlated with the OOD performance of the model. We study the same setting as presented in Section 4 where we estimate OOD performance of foundation models pretrained on different text corpora. Unlike AGL, ProjNorm doesn’t provide an estimate of the OOD performance hence we compare the linear correlation between the predicted value and OOD performance. From Table [tab:projnorm] it can be seen that estimates from ALine-D are more strongly correlated with OOD performance than ProjNorm.
max width=
In our comparison with baselines in Section 5, we filter out datasets with a low correlation coefficient \(\leq 0.95\) in ID vs OOD agreement. When the linear correlation of agreement is weak, AGL tells us that the correlation is also low for accuracy, and AGL-based methods are not guaranteed to be reliable in such circumstances. We provide ID vs OOD accuracy and agreement scatter plots for all datasets in Appendix 7.3.2.
Below, we separately provide the comparison with baselines for the excluded datasets. We generally find that the baseline ATC [21] is significantly better in circumstances where AGL-based methods are unreliable.
max width=
We state here the hyperparameters used to finetune the models for diversity experiments reported in Section 3.
We train all linear probes using SGD. Models are trained for different timesteps to achieve an even distribution of ID accuracies.
max width=
We use AdamW [64] to full finetune language models. We keep the learning rate small. Models are trained for different timesteps to achieve an even distribution of ID accuracies.
max width=
max width=
max width=
max width=
max width=
In Section 3.1, we examine how diversity source impacts whether AGL is observed in linear probed CLIP models from CIFAR10 to CIFAR10C. Here, we perform the same experiment on Office-Home [44], which consists of 4 domains or image styles (“Art”, “Clip Art”, “Product”, and “Real World”) for 65 common objects. We train models on one domain and treat the remaining three domains as OOD. Similarly, only Random Initialization yields AGL or matching slopes in accuracy and agreement, and as a result, the corresponding MAPE of estimating the OOD performance of this diverse ensemble is the smallest.
Random Head
Data Ordering
Data Subsetting
Figure 4: ID vs OOD accuracy and agreement of linear probed CLIP models on OfficeHome Art (top row), Product (middle row), and Real World (bottom row). The figure title is the OOD domain..
The ALine-S MAPE(%) for ensembles trained on each domain of OfficeHome.
We report the strength of AGL in linear probed CLIP models with randomly initialized linear heads across all datasets discussed in Section 3.2.
Figure 5: AGL and ACL for all C10C shifts with random head initialization finetuning..
Figure 6: AGL and ACL for the C10.1 shifts with random head initialization finetuning..
Figure 7: AGL and ACL for the C100C shifts with random head initialization finetuning..
Figure 8: AGL and ACL for the ImageNetC shifts with random head initialization finetuning..
Figure 9: AGL and ACL for the ImageNet V2 shifts with random head initialization finetuning..
Figure 10: AGL and ACL for 3 benchmarks from the WILDS dataset with random head initialization finetuning..
Figure 11: AGL and ACL for the OfficeHome ClipArt, Product, Real shifts with random head initialization finetuning over OfficeHome Art..
Figure 12: AGL and ACL for the OfficeHome Art, Product, Real shifts with random head initialization finetuning over OfficeHome ClipArt..
Figure 13: AGL and ACL for the OfficeHome ClipArt, Art, Real shifts with random head initialization finetuning over OfficeHome Product..
Figure 14: AGL and ACL for the OfficeHome Art, ClipArt, Product shifts with random head initialization finetuning over OfficeHome Real..
We show that light full finetuning over CLIP also observes similar effects of diversity source on the strength of AGL. We verify this on shifts from CIFAR10 to CIFAR10C.
Random Head
Data Ordering
Data Subsetting
Figure 15: ID vs OOD accuracy and agreement of full finetuned CLIP models on shift from CIFAR10 to CIFAR10C “JPEG Compression” (top row) and “Pixelate” (bottom row) shifts. Only Random Initialization (Column a) yields AGL or matching slopes in accuracy and agreement..
max width=
On the other hand, we demonstrate that in models heavily trained from scratch, AGL can be observed irrespective of the diversity source. Consistent with the models in [7], we train ResNet18 on CIFAR10 from scratch, varying the different sources of randomness. These models are trained heavily with SGD with learning rate of \(1\times10^{-2}\), batch size 128, and weight decay of \(1 \times 10^{-5}\) for up to 200 epochs. We do not use any data augmentation.
Figure 16: Effect of Diversity Source on ResNet18 from CIFAR10 to CIFAR10C-Snow
To rid of any confounding factors from data subsetting observing a smaller amount of data, we evaluate all randomness sources on different training dataset sizes. We track the effect of diversity in random initialization, data ordering, and data subsetting for different portions of the training data (100\(\%\), 50\(\%\), 30\(\%\), \(10\%\)). For each percentage \(x\%\), Random Initialization and Data Ordering ensembles are trained on the same randomly sampled \(x\%\) proportion of the data while each model in the Data Subsetting ensemble observe different randomly sampled \(x\%\) portions
Random Head
Data ordering
Figure 17: ID vs OOD accuracy and agreement of linear probe CLIP models finetuned on 100% of CIFAR10 training data evaluated on the CIFAR10C “JPEG Compression” (top row) and “Pixelate” (bottom row) shifts.
Random Head
Data ordering
Data Subsetting
Figure 18: ID vs OOD accuracy and agreement of linear probe CLIP models finetuned on 50% of CIFAR10 training data evaluated on the CIFAR10C “JPEG Compression” (top) and “Pixelate” (bottom) shifts.
Random Head
Data ordering
Data Subsetting
Figure 19: ID vs OOD accuracy and agreement of linear probe CLIP models finetuned on 30% of the CIFAR10 training data evaluated on the CIFAR10C “JPEG Compression” (top) and “Pixelate” (bottom) shifts.
Random Head
Data Ordering
Data Subsetting
Figure 20: ID vs OOD accuracy and agreement of linear probe CLIP models finetuned on 10% of the CIFAR10 training data and evaluated on the CIFAR10C “JPEG Compression” (top) and “Pixelate” (bottom) shifts.
In Section 3.2, we report the effect of diversity source in full finetuned GPT2-Medium models for the extractive QA task SQuAD to SQuAD-Shifts. In this section, we also provide the same experiments on OPT-125M and BERT. As observed in GPT, using Random Heads yields the strongest AGL behavior and achieves the smallest ALine-D MAPE.
In Table [tab:mape95opt9550] and [tab:mape95bert9550], we report the MAPE of OOD performance estimation of models trained with Random Initialization and Data Ordering using \(100\%\) of training data and Data Subsetting with \(10\%\) of training data.
max width=
max width=
We track the effect of diversity in random initialization, data ordering, and data subsetting for different portions of the training data (100\(\%\), 50\(\%\), 30\(\%\), \(10\%\)). For each percentage \(x\%\), Random Initialization and Data Ordering ensembles are trained on the same randomly sampled \(x\%\) proportion of the data while each model in the Data Subsetting ensemble observe different randomly sampled \(x\%\) portions.
Random Head
Data Ordering
Figure 21: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained GPT2 model with 100% of the training data.
Random Head
Data Ordering
Data Subsetting
Figure 22: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained GPT2 model with 50% of the training data.
Random Head
Data Ordering
Data Subsetting
Figure 23: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained GPT2 model with 10% of the training data.
We track the effect of diversity in random initialization, data ordering, and data subsetting for different portions of the training data (100\(\%\), 50\(\%\), 30\(\%\), \(10\%\)). For each percentage \(x\%\), Random Initialization and Data Ordering ensembles are trained on the same randomly sampled \(x\%\) proportion of the data while each model in the Data Subsetting ensemble observe different randomly sampled \(x\%\) portions.
Random Head
Data Ordering
Figure 24: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained OPT-125m with 100% of the training data.
Random Head
Data Ordering
Data Subsetting
Figure 25: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained OPT-125m with 50% of the training data.
Random Head
Data Ordering
Data Subsetting
Figure 26: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained OPT-125m with 30% of the training data.
Random Head
Data Ordering
Data Subsetting
Figure 27: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained OPT-125m with 10% of the training data.
We track the effect of diversity in random initialization, data ordering, and data subsetting for different portions of the training data (100\(\%\), 50\(\%\), 30\(\%\), \(10\%\)). For each percentage \(x\%\), Random Initialization and Data Ordering ensembles are trained on the same randomly sampled \(x\%\) proportion of the data while each model in the Data Subsetting ensemble observe different randomly sampled \(x\%\) portions.
Random Head
Data Ordering
Figure 28: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained BERT with 100% of the training data.
Random Head
Data Ordering
Data Subsetting
Figure 29: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained BERT with 50% of the training data.
Random Head
Data Ordering
Random Head
Figure 30: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained BERT with 30% of the training data.
Random Head
Data Ordering
Random Head
Figure 31: ID vs OOD accuracy and agreement of models finetuned on SQuAD from a single pretrained BERT with 10% of the training data.
In Section 3.2, we reported the effect of diversity source for full finetuned OPT. Here, we demonstrate similar results on text classification shift from MNLI-matched to SNLI with linear probed GPT2-Medium (Figure 32) and OPT-125M (Figure 33). Similarly, random initialization observes the strongest AGL behavior. In Table [tab:mape95tc], we report the average MAPE of OOD performance estimation using ALine across models.
Random Head
Data Ordering
Data Subsetting
Figure 32: ID vs OOD accuracy and agreement of models finetuned on MNLI from GPT2-Medium. Random Head and Data Ordering ensembles are trained on \(100\%\) of the training data while Data Subsetting ensemble is on \(10\%\)..
Random Head
Data Ordering
Data Subsetting
Figure 33: ID vs OOD accuracy and agreement of models finetuned on MNLI from OPT-125M. Random Head and Data Ordering ensembles are trained on \(100\%\) of the training data while Data Subsetting ensemble is on \(10\%\)..
max width=