跳到正文
arXiv cs.CL· Khashayar Gatmiry, Nathan W. Henry, Chloe H. Su, Emmanuel Abbe, Samy Bengio, Melanie Weber, Jonathan A. Kelner, Peter L. Bartlett·· 12 小时前AI 评分32

两层 Transformer 学排序会收敛到两类算法,仅一类能长度泛化

Transformers Learn Two Competing Sorting Algorithms, and Only One Length-Generalizes

AI 导读

在排序任务上训练至近零损失的两层 Transformer 会依初始化收敛到两类机制不同的解法:一类不使用第二层注意力,无法长度泛化;另一类同时使用两层注意力,仅在固定长度序列上训练却能完美长度泛化。研究者通过选择权重初始化可将模型导向任一解法,并将训练长度下罕见、长序列下渐多的输入类型识别为泛化差异来源。在求序列最小值任务上出现类似的两类解法现象,但泛化模式相反。

正文 · 原文

View PDF HTML (experimental)

Abstract:We show that two-layer transformers trained to near-zero loss on a sorting task converge to one of two mechanistically distinct solution classes depending on their initialization. One solution class consists of solutions that do not use the second attention layer to sort, but also fail to length-generalize. The other, which uses both attention layers, length-generalizes perfectly, despite only being trained to sort sequences of a fixed length. By carefully choosing the weight initialization, we demonstrate that we can steer the model toward learning one solution or the other. We identify input types that are rare at the training length but increasingly common at longer sequence lengths as a source of this disparity in length-generalization, and find that layer-wise specialization of the second class of solutions allows them to handle these rare sequences more accurately. In the second class, we discover a mechanism by which the second layer attention can use the contextual information gathered by the first layer attention to reduce its search space. On the related task of finding the minimum of a sequence, we find a similar two solution-type phenomenon, but with the opposite generalization pattern, where a different form of layer-wise specialization causes the two-layer solution to length-generalize worse than the single-attention solution.
Subjects: Machine Learning (cs.LG); Computation and Language (cs.CL)
Cite as: arXiv:2610.26974 [cs.LG]
  (or arXiv:2610.26974v1 [cs.LG] for this version)
  https://doi.org/10.48550/arXiv.2610.26974

arXiv-issued DOI via DataCite

Submission history

From: Huangyuan Su [view email]
[v1] Sun, 18 Oct 2026 20:21:16 UTC (21,550 KB)

来源:arXiv cs.CL · arxiv.org