The Effect of Attention Head Count on Transformer Approximation

Fuente: arXiv
Enregistré dans:
Détails bibliographiques
Auteurs principaux: Yu, Penghao, Jiang, Haotian, Bao, Zeyu, Yu, Ruoxi, Li, Qianxiao
Format: Preprint
Publié: 2025
Sujets:
Accès en ligne:
Tags: Ajouter un tag
Pas de tags, Soyez le premier à ajouter un tag!
_version_ 1866912989530030080
author Yu, Penghao
Jiang, Haotian
Bao, Zeyu
Yu, Ruoxi
Li, Qianxiao
author_facet Yu, Penghao
Jiang, Haotian
Bao, Zeyu
Yu, Ruoxi
Li, Qianxiao
contents Transformer has become the dominant architecture for sequence modeling, yet a detailed understanding of how its structural parameters influence expressive power remains limited. In this work, we study the approximation properties of transformers, with particular emphasis on the role of the number of attention heads. Our analysis begins with the introduction of a generalized $D$-retrieval task, which we prove to be dense in the space of continuous functions, thereby providing the basis for our theoretical framework. We then establish both upper and lower bounds on the parameter complexity required for $ε$-approximation. Specifically, we show that transformers with sufficiently many heads admit efficient approximation, whereas with too few heads, the number of parameters must scale at least as $O(1/ε^{cT})$, for some constant $c$ and sequence length $T$. To the best of our knowledge, this constitutes the first rigorous lower bound of this type in a nonlinear and practically relevant setting. We further examine the single-head case and demonstrate that an embedding dimension of order $O(T)$ allows complete memorization of the input, where approximation is entirely achieved by the feed-forward block. Finally, we validate our theoretical findings with experiments on both synthetic data and real-world tasks, illustrating the practical relevance of our results.
format Preprint
id arxiv_https___arxiv_org_abs_2510_06662
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle The Effect of Attention Head Count on Transformer Approximation
Yu, Penghao
Jiang, Haotian
Bao, Zeyu
Yu, Ruoxi
Li, Qianxiao
Machine Learning
Transformer has become the dominant architecture for sequence modeling, yet a detailed understanding of how its structural parameters influence expressive power remains limited. In this work, we study the approximation properties of transformers, with particular emphasis on the role of the number of attention heads. Our analysis begins with the introduction of a generalized $D$-retrieval task, which we prove to be dense in the space of continuous functions, thereby providing the basis for our theoretical framework. We then establish both upper and lower bounds on the parameter complexity required for $ε$-approximation. Specifically, we show that transformers with sufficiently many heads admit efficient approximation, whereas with too few heads, the number of parameters must scale at least as $O(1/ε^{cT})$, for some constant $c$ and sequence length $T$. To the best of our knowledge, this constitutes the first rigorous lower bound of this type in a nonlinear and practically relevant setting. We further examine the single-head case and demonstrate that an embedding dimension of order $O(T)$ allows complete memorization of the input, where approximation is entirely achieved by the feed-forward block. Finally, we validate our theoretical findings with experiments on both synthetic data and real-world tasks, illustrating the practical relevance of our results.
title The Effect of Attention Head Count on Transformer Approximation
topic Machine Learning
url https://arxiv.org/abs/2510.06662