Theoretical Insights into Fine-Tuning Attention Mechanism: Generalization and Optimization
Xinhao Yao, Hongjin Qian, Xiaolin Hu, Gengze Xu, Wei Liu, Jian Luan, Bin Wang, Yong Liu
TL;DR
This work reveals two attention-centered phenomena that govern fine-tuning efficiency in Transformer-based LLMs: (i) Unequal Importance of Attention Matrices, where tuning $W_v$ dominates and focusing on $W_q$ and $W_v$ can match or outperform full $W_q,W_k,W_v$ tuning while reducing parameter counts; and (ii) Attention Matrices with Customized Learning Rate, which shows that allocating a larger learning rate to $W_v$ accelerates convergence. The authors formalize a unified PEFT perspective, derive information-theoretic generalization bounds favoring the $W_q$+$W_v$ subset at fixed rank, and analyze learning-rate dynamics to justify a larger $ ext{LR}_V$ relative to $ ext{LR}_{QK}$. An actionable example demonstrates a storage- and time-efficient fine-tuning strategy—freeze $W_k$ and train $W_q$ and $W_v$ with distinct learning rates—validated on GLUE benchmarks with RoBERTa-base and Llama3.1-8b, achieving competitive performance with significantly fewer trainable parameters. Collectively, the results provide a theoretical foundation and practical guidance for designing lightweight, PEFT-based fine-tuning methods for Transformer architectures.
Abstract
Large Language Models (LLMs), built on Transformer architectures, exhibit remarkable generalization across a wide range of tasks. However, fine-tuning these models for specific tasks remains resource-intensive due to their extensive parameterization. In this paper, we explore two remarkable phenomena related to the attention mechanism during the fine-tuning of LLMs (where $\mathbf{W}_q$, $\mathbf{W}_k$, and $\mathbf{W}_v$ denote the weights of the query, key, and value layers, respectively). The first phenomenon, termed "Unequal Importance of Attention Matrices", highlights the impact of fine-tuning different weight matrices. It shows that optimizing the $\mathbf{W}_v$ matrix yields significantly better performance than optimizing the $\mathbf{W}_k$ matrix. Fine-tuning only the $\mathbf{W}_q$ and $\mathbf{W}_v$ matrices is computationally efficient while delivering results comparable to, or even better than fine-tuning all three matrices ($\mathbf{W}_q$, $\mathbf{W}_k$, and $\mathbf{W}_v$). The second phenomenon,"Attention Matrices with Customized Learning Rate Lead to Better Convergence", emphasizes the importance of assigning distinct learning rates to these matrices. Specifically, a higher learning rate for the $\mathbf{W}_v$ matrix compared to $\mathbf{W}_q$ and $\mathbf{W}_k$ accelerates convergence and improves performance. Building on these insights, we propose a new strategy that improves fine-tuning efficiency in terms of both storage and time. Experimental results on benchmark datasets validate the effectiveness of this approach, supporting our theoretical findings. Our analysis lays the theoretical groundwork for configuring and improving algorithms in LLMs fine-tuning.
