The number of attention heads in a transformer is usually set by convention or grid search. We test a simple heuristic for setting it in advance: estimate the intrinsic dimension of token representations without labels, and use roughly that many heads. We estimate intrinsic dimension with a nested-dropout VAE trained on DistilBERT embeddings of WikiText-2, choosing the KL weight at the knee of the VAE's rate-distortion curve rather than by hand. This gives k∗=9.2 (95% CI [8.6, 9.8]). In a small 4-layer transformer trained from scratch, 10 heads and 32 heads are statistically equivalent on SST-2 and on MRPC (paired TOST over 10 seeds, ±1 point margin), with 69% fewer attention parameters for the 10-head model. Training 10 heads from the start also slightly outperforms training 32 heads and pruning to 10 (0.6 points, p=0.008). The evidence is narrow: two classification tasks, one small architecture, no pretrained models, and no formal link between intrinsic dimension and head count. We present the result as a practical heuristic worth testing at larger scale, not as a general principle.
Figures & tables
Figure 1: The β sweep (mean over 5 seeds). Left: held-out reconstruction loss; β∗ is the point furthest from the dashed chord. Right: elbow of the latent variance spectrum, with 95% confidence intervals. At β∗=4 the elbow is k∗=9.2 ; the dotted line marks the head count tested downstream.
β
Reconstruction loss
Elbow k
0.10
0.354
34.0±0.9
0.25
0.382
26.4±1.1
0.50
0.422
21.6±1.4
1.00
0.485
17.0±1.5
2.00
0.602
13.0±0.9
3.00
0.707
10.4±0.7
Table 1: Values behind Figure 1 : held-out reconstruction loss and elbow k (mean ± 95% CI half-width over 5 seeds). Italic rows were added after the first seven-point sweep.
Task
k=10
k=32
Paired t -test
TOST
SST-2
82.13%±0.42
81.95%±0.33
p=0.31
equivalent, p=0.0005
MRPC
70.47%±0.90
70.37%±1.03
p=0.74
equivalent, p=0.006
Table 2: Validation accuracy of 10 versus 32 heads (mean ± std over 10 paired seeds). TOST tests equivalence within ±1 accuracy point.
Configuration
Validation accuracy
32 heads, unpruned
81.95%±0.33
32 pruned to 10, before fine-tuning
71.69%±7.04
32 pruned to 10, after fine-tuning
81.50%±0.37
10 heads from the start
82.13%±0.42
Table 3: Pruning baseline on SST-2 (mean ± std over the same 10 seeds).
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
SST-2
MRPC
Pruned fine-tune
VAE
Learning rate
10−4
2×10−4
2×10−5
10−3
Weight decay
0.05
0.03
0.05
10−4
Dropout
0.30
0.25
0.30
–
Batch size
64
32
64
256
Max epochs
10
20
5
40
Early-stopping patience
3
6
2
–
Appendix
Table 4: Training settings. All classifier runs use AdamW, a cosine learning-rate schedule with linear warmup, gradient clipping at 1.0, and early stopping on validation accuracy.
Multi-head attention uses parallel attention heads to route and combine information in Transformers, shaping their capacity, interpretability, and efficiency.
Center for Data Science, Peking University · Institute for Functional Intelligent Materials, National University of Singapore · Department of Mathematics, National University of Singapore +1