A Kernel-Based View of Language Model Fine-Tuning

Sadhika Malladi, Alexander Wettig, Dingli Yu, Danqi Chen, Sanjeev Arora

Introduction

In modern NLP, it is routine to take a pre-trained language model with hundreds of millions of parameters and "fine-tune" it on just a few dozen examples. By standard statistical rules, this massive overparameterization should lead to severe overfitting, yet it works remarkably well in practice.

The theoretical tool best suited for understanding deep learning dynamics—the Neural Tangent Kernel (NTK)—was originally designed for infinitely wide networks starting from random initialization and trained with Stochastic Gradient Descent (SGD). Real-world fine-tuning violates these assumptions: models start from highly structured pre-trained weights, use the Adam optimizer, and often rely on "prompts" to frame the task. This paper bridges the gap between the empirical success of language model fine-tuning and the mathematical framework of NTKs, explaining why fine-tuning is so sample-efficient.

Methodology

The authors introduce several novel theoretical extensions to make the "kernel lens" applicable to modern language models:

  • Deriving an "Adam Kernel": Adam is notoriously difficult to analyze because its updates depend on the entire history of gradients. The authors show that in the early stages of training, Adam behaves like SignGD (taking the sign of the gradient). They derive a new "SignGD Kernel" to model this behavior.
  • Handling Pre-trained Weights: Using the Tensor Programs framework, they extend infinite-width analysis to non-random initializations. They define a "natural task" as one where the pre-trained model already has a small output derivative, meaning it only needs a "small change" to solve the task.
  • Formalizing Prompting: They demonstrate that formulating a task as masked word prediction (prompting) effectively moves the task into this "natural" regime, inducing kernel-based dynamics.
  • Kernel View of LoRA: Applying the Johnson-Lindenstrauss lemma, they show that parameter-efficient methods like LoRA (Low-Rank Adaptation) act as random projections that preserve underlying kernel properties.

The study evaluates these theories across 14 diverse NLP tasks in few-shot settings (16 or 64 examples per label) using the RoBERTa-base architecture.

Key Insights and Results

The "Lazy" Regime and Linearization

Fine-tuning isn't necessarily about learning entirely new features. If a task is well-prompted, the model only needs to slightly adjust its existing pre-trained features. This "lazy" movement is what prevents overfitting. For many tasks, a fine-tuned model can be surprisingly well-approximated by a first-order Taylor expansion around its pre-trained starting point.

Summary of kernel behavior across tasks and settings

As shown in the summary matrix above, for tasks where the empirical NTK (eNTK) performs well, the model's features remain nearly "fixed" (green dots), confirming the lazy training theory. On 10 out of 14 tasks, the eNTK achieved accuracy within 10% of full fine-tuning. On some tasks, the kernel actually outperformed standard fine-tuning.

The Prompting Gap

Prompting isn't just a trick to help the model "understand" the task; it mathematically aligns the downstream task with the pre-training objective. This alignment allows the model to stay in the kernel regime.

Performance gap between SGD and the kernel regime with and without prompting

Without prompting (using a standard [CLS] classification head), there is a massive performance gap—up to 16%—between the kernel approximation and the actual model. Adding a prompt closes this gap to just 3%, proving that prompts actively induce kernel behavior during fine-tuning.

LoRA's Secret Sauce

The success of LoRA can be explained by the fact that it preserves the kernel matrix. Updating a low-rank subspace is theoretically sufficient because the "important" directions for the kernel are captured even in reduced dimensions.

Limitations and Future Work

While the kernel view provides a powerful explanatory framework, it has limitations:

  • Task Complexity: The kernel view struggled with complex entailment tasks (like MNLI and SNLI). These tasks may require active "feature learning" rather than just "lazy" adjustment.
  • Early-Stage Focus: The reduction of Adam to SignGD only holds for the early stages of training. It remains unclear how well this theory describes long-term fine-tuning on large datasets.
  • Computational Cost: Computing the eNTK for a model like RoBERTa is extremely memory-intensive, making it difficult to scale this analysis to massive models like GPT-4 without further approximations.

Future work could extend this few-shot classification analysis to generative tasks or sequence labeling, further broadening our theoretical understanding of large language models.

Summary updated

BibTeX
@inproceedings{malladi2023kernel,
  author = {Sadhika Malladi and Alexander Wettig and Dingli Yu and Danqi Chen and Sanjeev Arora},
  title = {{A Kernel-Based View of Language Model Fine-Tuning}},
  booktitle = {International Conference on Machine Learning},
  year = {2023},
  url = {https://openreview.net/forum?id=49dTFIGdx8},
}
Figure