The Power and Limitation of Pretraining-Finetuning for Linear Regression under Covariate Shift

Jingfeng Wu, Difan Zou, Vladimir Braverman, Quanquan Gu, Sham M. Kakade · DOI

Abstract

In modern machine learning, the "pretrain-then-finetune" paradigm is the standard approach for leveraging large-scale datasets to improve performance on specific downstream tasks. However, the theoretical mechanisms governing this process—particularly under distribution shift—remain poorly understood. This paper provides a sharp theoretical analysis of the pretraining-finetuning pipeline for linear regression under covariate shift. We establish instance-dependent bounds that characterize the excess risk in terms of the spectral properties of source and target covariance matrices. Our analysis reveals that while pretraining alone may require $O(N^2)$ source samples to match the performance of $N$ target samples, finetuning acts as a critical catalyst, drastically reducing the source data requirement by relaxing the need for perfect alignment between domains.

Introduction

The success of large-scale pretraining is often attributed to the model's ability to learn general representations that transfer across tasks. In the context of covariate shift, the relationship between inputs ($x$) and outputs ($y$) remains constant, but the marginal distribution of inputs changes between the source (pretraining) and target (finetuning) domains.

Previous theoretical attempts to bound the error in this setting often relied on coarse measures of divergence between distributions. These "pessimistic" bounds frequently failed to capture how the specific geometry of the data—namely the eigenvalues and eigenvectors of the covariance matrices—influences the transfer of knowledge. This work addresses this gap by deriving tight, instance-dependent bounds for linear regression trained via online Stochastic Gradient Descent (SGD).

Methodology

We analyze a two-phase learning process using a linear regression model. The model is trained using online SGD with geometrically decaying stepsizes, a common optimization strategy in practice.

  1. Pretraining Phase: The model is trained on $M$ samples drawn from a source distribution with covariance matrix $G$.
  2. Finetuning Phase: Starting from the weights obtained in the pretraining phase, the model is further trained on $N$ samples from a target distribution with covariance matrix $H$.

The primary goal is to minimize the target domain excess risk. Our analysis provides both upper and lower bounds for this risk, expressed as functions of the eigenvalues of $G$ and $H$, the number of samples ($M, N$), and the optimization parameters. This approach allows us to close the logarithmic gap found in previous literature regarding last-iterate SGD performance.

Theoretical Insights: The $O(N^2)$ Rule and Alignment

Our analysis yields several key insights into the efficiency of transfer learning:

The Efficiency Gap

We identify a fundamental "efficiency gap" in out-of-distribution learning. For a broad class of problem instances, pretraining requires $O(N^2)$ source samples to achieve the same excess risk that supervised learning (training only on the target domain) achieves with $N$ samples. This quantification highlights the inherent difficulty of learning from shifted distributions without direct target-domain supervision.

The Importance of Spectral Alignment

The efficacy of pretraining is heavily dependent on the alignment between the "top" eigenvalues of the target covariance matrix ($H$) and the source covariance matrix ($G$). If the source distribution lacks sufficient signal in the directions (eigenvectors) that are most relevant to the target distribution, the pretraining phase fails to provide a useful initialization for the target task.

Finetuning as a Catalyst

One of the most significant findings is the transformative role of finetuning. Finetuning is not merely a refinement step; it serves to "save" the pretraining process when alignment is imperfect. By introducing even a small amount of target data, the model can resolve the "middle" eigenvalues that the source data might have missed. This synergy allows the pretraining-finetuning pipeline to require polynomially less total data than either pretraining alone or supervised learning from scratch.

Empirical Validation

To validate our theoretical bounds, we conducted simulations on synthetic datasets with a problem dimension of 200. We utilized a specific problem structure, $P(k)$, where the alignment between source and target domains is controlled by reversing the top-$k$ eigenvalues of the source covariance matrix.

  • Well-Aligned ($P(k=5)$): Pretraining alone is highly effective and matches the performance of supervised learning.
  • Moderately Aligned ($P(k=10)$): A significant performance gap appears for pretraining alone. However, the addition of scarce target data during finetuning rapidly closes this gap, demonstrating the synergy between the two phases.
  • Poorly Aligned ($P(k=20)$): Pretraining provides negligible benefit. The model's performance is dominated by the finetuning phase, requiring nearly as much target data as a model trained from scratch.

Conclusion and Future Work

This work provides a rigorous mathematical foundation for understanding the power and limitations of the pretrain-then-finetune pipeline in linear regression. By moving beyond coarse divergence measures to instance-dependent spectral analysis, we clarify why finetuning is so effective at mitigating the limitations of source-target misalignment.

Future research directions include extending this framework to account for model shift (where the underlying $w^*$ changes between domains) and incorporating unlabeled data through semi-supervised learning techniques. Finally, while linear regression provides a vital theoretical baseline, extending these sharp bounds to non-linear architectures like neural networks remains a primary objective for the field.

Summary updated

BibTeX
@inproceedings{wu2022power,
  author = {Jingfeng Wu and Difan Zou and Vladimir Braverman and Quanquan Gu and Sham M. Kakade},
  title = {{The Power and Limitation of Pretraining-Finetuning for Linear Regression under Covariate Shift}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2022},
}
Figure