Spectral Journey: How Transformers Predict the Shortest Path
Not on the map. Why?
Abstract (arXiv)
Decoder-only transformers lead to a step-change in capability of large language models. However, opinions are mixed as to whether they are really planning or reasoning. A path to making progress in this direction is to study the model's behavior in a setting with carefully controlled data. Then interpret the learned representations and reverse-engineer the computation performed internally. We study decoder-only transformer language models trained from scratch to predict shortest paths on simple, connected and undirected graphs. In this setting, the representations and the dynamics learned by the model are interpretable. We present three major results: (1) Two-layer decoder-only language models can learn to predict shortest paths on simple, connected graphs containing up to 10 nodes. (2) Models learn a graph embedding that is correlated with the spectral decomposition of the line graph. (3) Following the insights, we discover a novel approximate path-finding algorithm Spectral Line Navigator (SLN) that finds shortest path by greedily selecting nodes in the space of spectral embedding of the line graph.
Key facts. Cited by 8 papers in the map (data through 14 Oct 2026). First posted on arXiv 12 Feb 2025.
Builds on
0 of 0 references.
No references here yet.
Built on by
Citing papers per year: 2025: 5; 2026: 3.
8 papers.
- 2025Reasoning by Superposition: A Theoretical Perspective on Chain of Continuous Thoughtcited by 77
- 2025GaLore 2: Large-Scale LLM Pre-Training by Gradient Low-Rank Projectioncited by 14
- 2025Is the Reversal Curse a Binding Problem? Uncovering Limitations of Transformers from a Basic Generalization Failurecited by 13
- 2025Benefits and Pitfalls of Reinforcement Learning for Language Model Planning: A Theoretical Perspectivecited by 4
- 2025From Sequence to Structure: Uncovering Substructure Reasoning in Transformerscited by 3
- 2026Provable Benefits of RLVR over SFT for Reasoning Models: Learning to Backtrack Efficientlycited by 2
- 2026When Do Hallucinations Arise? A Graph Perspective on the Evolution of Path Reuse and Path Compressioncited by 0
- 2026Generalization in LLM Problem Solving: The Case of the Shortest Pathcited by 0
- 2026Provable Benefits of RLVR over SFT for Reasoning Models: Learning to Backtrack Efficiently22 Jun 2026
- 2026Generalization in LLM Problem Solving: The Case of the Shortest Path16 Apr 2026
- 2026When Do Hallucinations Arise? A Graph Perspective on the Evolution of Path Reuse and Path Compression4 Apr 2026
- 2025Benefits and Pitfalls of Reinforcement Learning for Language Model Planning: A Theoretical Perspective26 Sep 2025
- 2025From Sequence to Structure: Uncovering Substructure Reasoning in Transformers11 Jul 2025
- 2025Reasoning by Superposition: A Theoretical Perspective on Chain of Continuous Thought18 May 2025
- 2025GaLore 2: Large-Scale LLM Pre-Training by Gradient Low-Rank Projection29 Apr 2025
- 2025Is the Reversal Curse a Binding Problem? Uncovering Limitations of Transformers from a Basic Generalization Failure2 Apr 2025