Learning on Transformers is Provable Low-Rank and Sparse: A One-layer Analysis

Hongkang Li, Meng Wang, Shuai Zhang, Sijia Liu, Pin-Yu Chen

Abstract

This paper investigates the theoretical underpinnings of Low-Rank Adaptation (LoRA) and model pruning in Transformer architectures. By analyzing a one-layer, single-head Transformer model under a label-relevant data distribution, the authors provide the first rigorous proof that gradient updates are inherently low-rank and that trained models exhibit natural sparsity. The findings demonstrate that the effective rank of weight updates is determined by the number of task-relevant features, justifying the success of empirical compression techniques. Our analysis shows that the rank of updates is bounded by the number of relevant features and that a significant portion of the network can be pruned without compromising performance, providing a formal justification for common model compression practices.

Introduction

Efficiency is the cornerstone of modern AI deployment. Techniques like Low-Rank Adaptation (LoRA) and model pruning have become industry standards for fine-tuning and deploying massive Transformer models. While these methods work remarkably well in practice, the theoretical reasons for their success have remained elusive. Most existing deep learning theory focuses on simpler architectures like feed-forward networks or CNNs, leaving the complex self-attention mechanisms of Transformers largely unexamined.

This study bridges that gap by answering a fundamental question: Why do low-rank updates and pruning work specifically for the Transformer architecture? The authors provide a theoretical foundation showing that the "effective" dimensionality of the learning process is much lower than the total parameter count, driven by the underlying structure of the data.

Theoretical Framework and Methodology

The researchers analyze a one-layer, single-head Transformer trained using Stochastic Gradient Descent (SGD). To ensure mathematical tractability while maintaining practical relevance, they utilize a specific Label-Relevant Data Model:

  • Patterns: Input data consists of $M$ distinct unit vector patterns.
  • Label-Relevance: Only a small subset of these patterns (e.g., $\mu_1, \mu_2$) determines the binary label, while the remaining $M-2$ patterns serve as label-irrelevant background noise.
  • Tokens: Each input token is modeled as a noisy version of one of these patterns.

The study characterizes the trained model after convergence, specifically examining the directions and magnitudes of the weight updates ($\Delta W$) for the Query ($W_Q$), Key ($W_K$), Value ($W_V$), and Output ($W_O$) matrices.

Key Insights

1. Task-Driven Low-Rank Bias

The authors prove that gradient updates primarily map input patterns toward the directions of the label-relevant patterns. Because only a few patterns are critical for the classification task, the update matrix is naturally low-rank. Specifically, if two patterns determine the label, the update matrix can be effectively approximated by a rank-2 matrix. This suggests that Transformers have an inherent bias toward low-rank solutions when the task depends on a low-dimensional subspace of the input.

2. Emergent Sparsity and Pruning

In the output matrix ($W_O$), the analysis reveals that a constant fraction of neurons end up with negligible magnitudes after training. These neurons do not contribute to the final decision-making process. This mathematically justifies magnitude-based pruning: removing neurons with small weights in $W_O$ has a negligible effect on generalization error, whereas removing high-magnitude neurons (those that captured label-relevant patterns) causes performance to collapse.

Experimental Results

Numerical experiments on synthetic datasets ($d=20, M=20, m=200$) confirm the theoretical predictions.

Testing hinge loss across different rank approximations.

As shown in the figure above, when the rank of the update approximation is at least 2 (matching the number of label-relevant patterns), the testing performance is nearly identical to a full-rank model. However, reducing the rank to 1 leads to a significant drop in performance, confirming that the task complexity dictates the necessary rank.

Testing hinge loss as a function of the pruning rate.

Furthermore, the researchers observed a clear pruning threshold. As illustrated in the plot above, approximately 40% of the neurons in the output layer could be pruned before any increase in testing hinge loss was observed. This aligns with the theoretical prediction that a significant fraction of the model remains sparse and redundant.

Conclusion and Future Work

This work provides a rigorous explanation for why LoRA and pruning are effective: the learning process in Transformers naturally focuses on a low-dimensional, task-relevant subspace. While this analysis is limited to one-layer, single-head models, it serves as a vital starting point for understanding deeper architectures. Future research will focus on extending these proofs to multi-layer and multi-head Transformers and using these insights to design more principled, data-aware compression algorithms.

Summary updated

BibTeX
@inproceedings{li2024learning,
  author = {Hongkang Li and Meng Wang and Shuai Zhang and Sijia Liu and Pin-Yu Chen},
  title = {{Learning on Transformers is Provable Low-Rank and Sparse: A One-layer Analysis}},
  booktitle = {SAM},
  year = {2024},
  doi = {10.1109/sam60225.2024.10636559},
}
Figure