Allocation of Parameters in Transformers

Ruoxi Yu, Haotian Jiang, Jingpu Cheng, Penghao Yu, Qianxiao Li, Zhong Li · DOI

Abstract

Transformers have become the standard architecture for modern AI, yet the theoretical principles governing their parameter efficiency remain under-explored. This paper investigates how to optimally allocate a fixed parameter budget—specifically the number of attention heads versus head dimension—across Transformer layers. By mathematically proving a trade-off in early layers and identifying a "softmax saturation" effect in later layers, we provide a principled strategy for designing more efficient, compressed Transformers without sacrificing performance.

Introduction

In standard Transformer designs, engineers typically employ a uniform parameter allocation: a fixed model dimension ($D$) is divided evenly into a set number of heads ($H$) and head dimensions ($d$) across all layers. However, research into the "division of labor" within these models suggests that early layers focus on surface-level feature extraction while later layers handle abstract semantic reasoning. This disparity raises a critical question: is uniform allocation truly efficient? We explore how to balance expressivity and computational efficiency under a strict parameter budget.

Theoretical Framework: The Early-Layer Trade-off

In the early stages of a Transformer, layers function primarily as information extractors. We model these dynamics using approximation error bounds to determine how error changes relative to head count and head dimension. Our analysis reveals a strict mathematical trade-off: while larger head dimensions are superior for preserving token information (reducing compression loss), a higher number of heads is more effective for approximating complex extraction functions.

Theoretical error bound as a function of the number of heads (H) for a fixed parameter budget.

As shown in the theoretical error curve above, there is a clear local minimum where the number of heads optimally balances these competing requirements. Beyond this point, increasing the number of heads at the expense of head dimension leads to higher approximation errors.

Softmax Saturation and Diminishing Returns

To understand later layers, we analyze the Jacobian matrix of the softmax attention mechanism. We prove that as sequence length ($L$) grows, the "slope" of the softmax activation flattens, with the Jacobian spectral norm scaling as $\mathcal{O}(1/L)$. This "softmax saturation" implies that continuously increasing head dimensions in later layers yields diminishing returns. Consequently, later layers can operate with significantly reduced head dimensions, presenting a major opportunity for model compression.

Empirical Validation

We tested our theoretical findings using both synthetic tasks (e.g., 4-gram and Induction Head tasks) and standard language modeling benchmarks like WikiText-103. For a synthetic 4-gram task with a fixed budget, our theoretical optimization formula predicted an optimal allocation of 8 heads.

Empirical validation showing Mean Squared Error (MSE) reaching a minimum at 8 heads, matching theoretical predictions.

As illustrated in the empirical results, the validation loss perfectly aligns with the theoretical prediction, confirming that a calculated balance of heads and dimensions outperforms arbitrary uniform allocation. Furthermore, experiments on pre-trained models like TinyLlama-1.1B confirmed that the spectral norm of the attention softmax Jacobian drops predictably as sequence length increases, validating our saturation theory.

Practical Implications for Compression

Our findings suggest a new strategy for model compression. By using Singular Value Decomposition (SVD) to initialize "student" heads from pre-trained "teacher" heads, we successfully compressed head dimensions in models like LiteLlama from 64 down to 16-32 with almost zero performance degradation. When training from scratch, reducing head dimension while maintaining head count proved more effective at reducing total parameters than cutting the number of heads.

Conclusion

This work moves beyond heuristic-based Transformer design toward a principled approach to parameter allocation. By recognizing the layer-specific needs for feature extraction and the inherent saturation of attention mechanisms, researchers can design models that are both smaller and more capable. Future work will extend this analysis to alternative attention mechanisms and explore the interaction between these strategies and feed-forward networks.

Summary updated

BibTeX
@misc{yu2025allocation,
  author = {Ruoxi Yu and Haotian Jiang and Jingpu Cheng and Penghao Yu and Qianxiao Li and Zhong Li},
  title = {{Allocation of Parameters in Transformers}},
  year = {2025},
  eprint = {2510.03784},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.03784},
}
Figure