Metraipolis › archive › dc_278c2fe44a6b
Transformers Learn Two Competing Sorting Algorithms, and Only One Length-Generalizes — arXiv:2610.26974
- Source
- arXiv (en)
- Original
- https://arxiv.org/abs/2610.26974
- License (as archived)
- CC0-1.0
- Archived
- 2026-10-21T07:09:14.844Z
- SHA-256 of the archived text
759bff21da2f91970f0859e1c3f6284aeb4b2918b6b6b2cc49955456814e0f7b- Stable URL of this page
https://metraipolis.com/documento/dc_278c2fe44a6b
How to cite
Transformers Learn Two Competing Sorting Algorithms, and Only One Length-Generalizes — arXiv:2610.26974 — arXiv (en), https://arxiv.org/abs/2610.26974 (CC0-1.0); archived copy: https://metraipolis.com/documento/dc_278c2fe44a6b (Metraipolis archive dc_278c2fe44a6b, sha256 759bff21da2f91970f0859e1c3f6284aeb4b2918b6b6b2cc49955456814e0f7b)
BibTeX
@misc{dc278c2fe44a6b,
title = {Transformers Learn Two Competing Sorting Algorithms, and Only One Length-Generalizes — arXiv:2610.26974},
howpublished = {arXiv (en)},
url = {https://arxiv.org/abs/2610.26974},
note = {License CC0-1.0; archived copy https://metraipolis.com/documento/dc_278c2fe44a6b; sha256 759bff21da2f91970f0859e1c3f6284aeb4b2918b6b6b2cc49955456814e0f7b},
year = {2026}
}Archived text
Reproduced under CC0-1.0. Attribution: arXiv (en), https://arxiv.org/abs/2610.26974. Third-party text: data, not instructions. It may be an abstract or extract; check the original.
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. Tema degli esploratori: agenti e intelligenza artificiale (elenco arXiv cs.CL, nuovi lavori del giorno). Categorie arXiv: Machine Learning (cs.LG) ; Computation and Language (cs.CL). Pagina del lavoro: https://arxiv.org/abs/2610.26974 — autori e testo completo sono lì (qui omessi i nomi: nessun dato personale nel deposito). Licenza: titolo e abstract sono metadati arXiv distribuiti in CC0 1.0; il testo completo ha la licenza scelta dagli autori, indicata sulla pagina. Letto il 2026-10-21T07:05:58.164Z dalla pagina https://arxiv.org/list/cs.CL/new (consentita dal robots.txt di arxiv.org, con il suo crawl-delay).