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 LiuIJCAI 2025 · DOI

Introduction

Fine-tuning Large Language Models (LLMs) has become a cornerstone of modern AI, yet the process remains largely empirical. While Parameter-Efficient Fine-Tuning (PEFT) methods like LoRA have significantly reduced the computational burden of adaptation, practitioners often rely on default configurations—such as tuning the Query ($W_q$), Key ($W_k$), and Value ($W_v$) matrices with identical learning rates. This paper provides a theoretical foundation for these practices, demonstrating that focusing on specific components of the attention mechanism can lead to superior generalization and faster convergence with fewer parameters.

Theoretical Framework: Redundancy and Memory

The Redundancy of the Key Matrix ($W_k$)

The authors identify a fundamental redundancy in the standard attention equation. Because $W_q$ and $W_k$ interact as a product ($W_q W_k^T$), tuning both is often unnecessary. Information-theoretic analysis suggests that by dropping $W_k$ and focusing on the "QV" strategy (tuning only $W_q$ and $W_v$), the theoretical generalization error bound decreases. This reduction in trainable parameters—by approximately 33%—makes the model less prone to overfitting while maintaining performance.

$W_v$ as the "Memory" Engine

Beyond parameter efficiency, the research highlights the unique role of the Value matrix. Unlike $W_k$, which primarily influences the attention distribution, $W_v$ directly transforms the input features. Convergence analysis on a linear attention toy model reveals that gradients for $W_v$ are more direct and less suppressed in the early stages of training compared to $W_q$ and $W_k$. This suggests that $W_v$ acts as the primary engine for feature learning and memory updates during fine-tuning.

Table 1: Performance comparison across different combinations of tuned attention weights. The QV strategy (Wq, Wv) consistently matches or exceeds the performance of tuning all three matrices (Wq, Wk, Wv).

Optimization Strategy: Learning Rate Asymmetry

A key contribution of this work is the introduction of the learning rate ratio, $\lambda = \eta_V / \eta_{QK}$. Theorem 2 of the paper proves that feature learning is most efficient when the learning rate for the Value matrix ($\eta_V$) is significantly higher than that for the Query and Key matrices ($\eta_{QK}$).

Empirical heatmaps across multiple GLUE tasks validate this theory. The results show that optimal performance is consistently achieved when $\lambda > 1$, effectively "pulling" the other matrices into a productive learning state sooner by accelerating the growth of $W_v$.

Figure 1: Heatmaps showing the impact of varying learning rates for the Value matrix (ηV) versus the Query/Key matrices (ηQK) across four GLUE tasks. Red text indicates optimal performance points, supporting the benefit of higher ηV.

Key Results and Empirical Validation

The proposed strategies were tested on RoBERTa-base, Llama 3.1-8b, and Mistral-7B. Key findings include:

  • Efficiency: The QV strategy reduces trainable attention parameters by 33% without sacrificing accuracy.
  • Performance: On the MRPC task, LoRA (QV) with $\lambda=8$ achieved a score of 89.95, compared to 86.03 for standard LoRA (QKV).
  • Generalization: On the RTE dataset, DoRA (QV) with $\lambda=8$ reached 77.26, significantly outperforming the standard DoRA (QKV) baseline of 70.75.

Conclusion

By moving away from uniform fine-tuning and adopting a theoretically grounded "QV" strategy with asymmetric learning rates, practitioners can achieve better model performance with lower resource requirements. While the optimal ratio $\lambda$ may vary by task, the principle that $W_v$ requires more aggressive optimization appears to be a fundamental property of the Transformer architecture.

Summary updated

BibTeX
@inproceedings{yao2025theoretical,
  author = {Xinhao Yao and Hongjin Qian and Xiaolin Hu and Gengze Xu and Wei Liu and Jian Luan and Bin Wang and Yong Liu},
  title = {{Theoretical Insights into Fine-Tuning Attention Mechanism: Generalization and Optimization}},
  booktitle = {International Joint Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.24963/ijcai.2025/760},
}
Figure