A Theoretical Analysis of Fine-tuning with Linear Teachers

Gal Shachaf, Alon Brutzkus, Amir Globerson

Abstract

Fine-tuning pre-trained models is a cornerstone of modern machine learning, yet its success in overparameterized regimes remains theoretically elusive. This paper introduces a rigorous mathematical framework using linear teachers to analyze fine-tuning dynamics. We demonstrate that generalization performance is critically dependent on the alignment between task differences and the data's covariance structure. Furthermore, we identify a "depth advantage" where deeper networks exhibit an implicit bias that regularizes task scale differences, and we prove that common practices like layer freezing can lead to model degeneration in specific deep linear settings.

Introduction

Modern AI relies heavily on pre-training on massive source datasets followed by fine-tuning on smaller target tasks. Despite the massive overparameterization of these models, they often generalize remarkably well on tiny datasets where standard theory would predict overfitting. The central challenge lies in formalizing the "similarity" between source and target tasks and understanding how network architecture influences this transfer. This work seeks to bridge this gap by analyzing the evolution of model weights under gradient flow.

Methodology

The study employs three primary architectural lenses:

  1. Standard Linear Regression: Examining single-layer networks as a baseline.
  2. Deep Linear Networks: Analyzing multi-layer networks that, while functionally linear, possess complex training dynamics.
  3. Shallow ReLU Networks: Investigating non-linear architectures within the Neural Tangent Kernel (NTK) regime.

Researchers utilized synthetic Gaussian data to isolate variables like task alignment and covariance, and validated findings on MNIST by modeling digit classification as a regression task.

Theoretical Insights

The Covariance Connection

A key finding is that generalization error is not merely a function of the Euclidean distance between the source task ($\theta_S$) and target task ($\theta_T$). Instead, it depends on the alignment of the task difference ($\theta_T - \theta_S$) with the eigenvectors of the data covariance matrix. When task differences align with high-variance directions (top eigenvectors), the model requires significantly fewer samples to achieve low test loss.

Test loss decreases more rapidly when task differences align with the top eigenvectors of the data covariance matrix.

The Depth Advantage and Implicit Bias

In deep linear networks, depth serves as a natural regularizer. As network depth increases, the fine-tuning process becomes less sensitive to the absolute magnitude (scale) of task vectors and more focused on their directional alignment. This allows deeper networks to effectively "auto-scale" the source task to match the target. Conversely, the "Freeze Trap" theorem shows that freezing early layers in deep linear settings can cause the model to degenerate, preventing it from ever learning the target task regardless of sample size.

Increasing network depth (a) reduces test loss across different task alignments, while scaling factors (b) illustrate the sensitivity of source and target tasks to magnitude changes.

Key Results

  • Superior Generalization Bounds: The proposed bounds for linear regression achieved a correlation of $R^2 \approx 0.86$ with actual test error on MNIST, significantly outperforming previous state-of-the-art bounds ($R^2 \approx 0.73$).
  • Zero Risk with Minimal Samples: Theorem 5.3 proves that an infinitely deep linear network can achieve zero prediction error with just a single target sample, provided the source and target tasks are perfectly aligned in direction.
  • ReLU Sample Complexity: Analysis of ReLU networks in the NTK regime confirms that population risk is bounded by the distance between source and target outputs, justifying the intuition that "closer" tasks require less data.

Limitations and Future Work

The current analysis is primarily restricted to linear teachers and the NTK regime for non-linear models. Real-world tasks often involve high non-linearity and significant feature learning that moves beyond the NTK regime. Future research will focus on extending these insights to classification tasks with exponential losses and more complex architectures like Transformers.

Summary updated

BibTeX
@inproceedings{shachaf2021theoretical,
  author = {Gal Shachaf and Alon Brutzkus and Amir Globerson},
  title = {{A Theoretical Analysis of Fine-tuning with Linear Teachers}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=DyE8hmj2dse},
}
Figure