基于内在维度选择注意力头数量:一项小规模研究
Choosing the Number of Attention Heads from Intrinsic Dimension: A Small-Scale Study
AI总结:
该研究提出一种基于内在维度的Transformer注意力头数量选择启发式方法,经小规模实验验证,10头模型与32头模型性能相当且参数更少,该方法值得大规模测试。
摘要:
Transformer中的注意力头数量通常根据惯例或网格搜索设定。我们测试了一种预先设定该数量的简单启发式方法:在无标签情况下估计词元表示的内在维度,并使用大致对应该维度的头数量。我们通过在WikiText-2的DistilBERT嵌入上训练的嵌套Dropout VAE来估计内在维度,选择VAE率失真曲线拐点处的KL权重而非手动选择,得到k*=9.2(95%置信区间[8.6, 9.8])。在一个从头训练的小型4层Transformer中,10头模型与32头模型在SST-2和MRPC上的性能统计等价(配对TOST检验,10个随机种子,±1个点的边际),且10头模型的注意力参数减少69%。从头训练10头模型也略优于训练32头后剪枝至10头(0.6个点,p=0.008)。证据范围较窄:仅两个分类任务、一个小型架构、无预训练模型,且内在维度与头数量之间无正式关联。我们将该结果呈现为值得在更大规模上测试的实用启发式方法,而非通用原则。
英文摘要:
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, $\pm1$ 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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。