Manuscript Offprint

arXiv:2610.19966

Choosing the Number of Attention Heads from Intrinsic Dimension: A Small-Scale Study

Arjun Boya, Charan Sai Bandaru, Masthanaiah Pillimetla, Kavana Chidanandappa

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Arjun Boya

Institute of Cognitive Science

University of Osnabrück

aboya@uni-osnabrueck.de

Masthanaiah Pillimetla

Department of Social Sciences and Technology

Technical University of Munich

masthanaiahpillimetla7@gmail.com

Charan Sai Bandaru

Institute of Cognitive Science

University of Osnabrück

cbandaru@uni-osnabrueck.de

Kavana Chidanandappa

Department of Social Sciences and Technology

Technical University of Munich

ckavana003@gmail.com

Abstract

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.2k^* = 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\pm 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.008p = 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.

1 Introduction

Ask why a transformer has 8, 12 or 16 attention heads per layer and the honest answer is usually that a previous model did. Head count is rarely derived from the task. Meanwhile, pruning studies keep finding that many heads in trained models can be removed with little loss (Michel et al., 2019; Voita et al., 2019), which suggests the usual counts are often larger than needed. The standard response is to train a large model and prune it afterwards. We ask whether the count can instead be chosen before training, from a cheap property of the data.

The property we use is intrinsic dimension: roughly, the number of independent directions along which the representations actually vary. Section 3 explains why this might bear on head count and where the analogy breaks down. In short, we treat it as a hypothesis with a testable prediction: a model with about k∗k^{*} heads should do as well as one with many more.

We test that prediction at small scale. Our contributions are:

  • A label-free procedure for estimating a head count: a nested-dropout VAE on token embeddings, an elbow detector suited to the convex spectra such VAEs produce, and a rule for choosing the VAE's KL weight from its own rate–distortion curve. Applied to DistilBERT embeddings of WikiText-2, it gives k∗=9.2k^* = 9.2.

  • A paired-seed comparison showing that 10 heads match 32 heads on SST-2 and MRPC (TOST equivalence within ±1\pm1 accuracy point) in a 4-layer transformer trained from scratch, with 69% fewer attention parameters.

  • A comparison with reactive pruning: training 10 heads from the start slightly but consistently beats training 32 heads and pruning to 10.

The claims are modest. We do not derive head count from intrinsic dimension, and two small tasks with one architecture do not establish a general rule. Section 6 lists what would be needed to do so.

References (15)

  • Intrinsic dimensionality explains the effectiveness of language model fine-tuning
  • Intrinsic dimension of data representations in deep neural networks
  • Automatically constructing a corpus of sentential paraphrases
  • Estimating the intrinsic dimension of datasets by a minimal neighborhood information
  • $\beta$-VAE: Learning basic visual concepts with a constrained variational framework
  • Auto-encoding variational Bayes
  • Pointer sentinel mixture models
  • Are sixteen heads really better than one? In Advances in Neural Information Processing Systems, volume 32, 2019
  • Learning ordered representations with nested dropout
  • DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
  • Finding a “kneedle” in a haystack: Detecting knee points in system behavior
  • Recursive deep models for semantic compositionality over a sentiment treebank
  • Attention is all you need
  • Analyzing multi-head self-attention: Specialized heads do the heavy lifting, the rest can be pruned
  • GLUE: A multi-task benchmark and analysis platform for natural language understanding