Sign inGet started
Paper · arXiv

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

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...

AuthorsKhashayar Gatmiry, Nathan W. Henry, Chloe H. Su et al.
Primary categorycs.LG
Published18 October 2026
Last updated at source18 October 2026
cs.LGcs.CL
Embed this entry
<iframe src="https://silytics.si/embed/item/35a822e8-06e9-4c35-bd49-a464ac8cc4fa" width="420" height="190" style="border:0" loading="lazy" title="Silytics entry"></iframe>

Free, no tracking. More about feeds and embeds.

Popularity, last 3 days

0 now. Counts as reported by the source, snapshotted daily by Silytics.

Silytics shows public metadata from arXiv and links to the original. Information may be incomplete or out of date. Last refreshed 23 October 2026. Licenses and terms of the original apply to the work itself. Not financial, legal or professional advice.