arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.16653cs.LG
收藏

结合注意力与层归一化的计数:归一化缩放与表示几何

Counting with Attention and LayerNorm: Norm Scaling and Representation Geometry

New York University Abu Dhabi(纽约大学阿布扎比分校)

Ayyub Shaffy, Manoj Dhakal, Safal Shrestha, Keith W. Ross

AI总结:

该研究针对Transformer长序列计数失败问题,分析单注意力层计数的参数成本,推导不同归一化与读出方式的计数速率,通过实验验证后归一化模型的两种读出差异。

摘要:

计数是一项简单任务,但Transformer在长序列长度下仍会在此任务上失败。我们研究了单个注意力层中计数的成本,最大长度为$L$,重点关注softmax注意力和层归一化如何塑造用于恢复计数的表示。我们主要关注回归读出,也考虑分类读出。对于回归,我们证明未归一化的线性注意力可在参数范数与$L$无关时精确计数;对于softmax注意力,回归无法用有限参数精确计数,需在舍入后恢复计数,但仅当向量参数范数随$L$增长时才可实现。我们用$B_{\min}$衡量此成本,$B_{\min}$是确保舍入后精确计数的每个可训练向量的最小边界,并推导了其紧速率:在固定模型维度下,无归一化时$B_{\min}$随$L$增长,仅使用后归一化时随$L^{3/2}$增长,使用可学习后归一化时随$L^{3/4}$增长。最后一速率出乎意料:后归一化会丢弃承载计数的幅值,本应使计数更困难,但结合可学习增益后,其计数所需的范数比无归一化的softmax更小。仅使用前归一化则不同:它会约束注意力分数,因此超过有限长度后无参数范数足够。分类读出会在所有位置保持每个范数有界,但密集头会为每个计数存储一个输出向量,存储成本更高。对后归一化模型的实验重现了两种读出方式的这种差异。综上,我们的理论与实验发现阐明了自注意力、层归一化位置和读出选择如何塑造所研究的最小单头架构中计数的表示几何与参数成本。

英文摘要:

Counting is a simple task on which transformers can nevertheless fail at long sequence lengths. We study the cost of counting in a single attention layer, up to a maximum length $L$, focusing on how softmax attention and layer normalization shape the representation from which the count is recovered. We mainly focus on regression read-out but also consider classification read-out. For regression, we show unnormalized linear attention counts exactly at parameter norms independent of $L$. For softmax attention, regression cannot count exactly with finite parameters; it recovers the count after rounding, but only when the vector parameter norms grow with $L$. We measure this cost by $B_{\min}$, the smallest bound that can be placed on every trainable vector to ensure exact counting after rounding, and derive tight rates. At fixed model dimension, $B_{\min}$ grows as $L$ without normalization, as $L^{3/2}$ under bare post-normalization, and as $L^{3/4}$ with learned post-normalization. The last rate is unexpected: post-normalization discards the magnitude that carries the count and might be expected to make counting harder, yet with a learnable gain it counts at a smaller norm than softmax without normalization. Bare pre-normalization is different: it bounds the attention scores, so beyond a finite length no parameter norm suffices. A classification read-out keeps every norm bounded under every placement, but a dense head stores one output vector per count and costs more in storage. Experiments on the post-normalized model reproduce this split between the two read-outs. Together, our theoretical and empirical findings characterize how self-attention, layer-normalization placement, and read-out choice shape the representation geometry and parameter cost of counting in the minimal single-head architecture studied here.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑