mlsanityData to 14 Oct 2026

Transformers Provably Learn Algorithmic Solutions for Graph Connectivity, But Only with the Right Data

arXiv 2510.19753 ↗First posted 22 Oct 2025cs.LGcited by 2

Not on the map. Why?

Abstract (arXiv)

Transformers often fail to learn generalizable algorithms, instead relying on brittle heuristics. Using graph connectivity as a testbed, we explain this phenomenon both theoretically and empirically. We consider a simplified Transformer architecture, the Disentangled Transformer, and prove that an L-layer model can compute connectivity in graphs with diameters up to 3L, implementing an algorithm equivalent to computing powers of the adjacency matrix. By analyzing training dynamics, we prove that whether the model learns this strategy hinges on whether most training instances are within this model capacity. Within-capacity graphs (diameter ≤ 3L) drive the learning of the algorithmic solution while beyond-capacity graphs drive the learning of a simple heuristic based on node degrees. Finally, we empirically show that restricting training data to stay within a model's capacity makes both standard and Disentangled Transformers learn the exact algorithm.

Key facts. Cited by 2 papers in the map (data through 14 Oct 2026). First posted on arXiv 22 Oct 2025.

Builds on

0 of 0 references.

No references here yet.

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 2.

2 papers.