Spectral Journey: How Transformers Predict the Shortest Path

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Cohen, Andrew, Gromov, Andrey, Yang, Kaiyu, Tian, Yuandong
Natura: Preprint
Pubblicazione: 2025
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866909490495881216
author Cohen, Andrew
Gromov, Andrey
Yang, Kaiyu
Tian, Yuandong
author_facet Cohen, Andrew
Gromov, Andrey
Yang, Kaiyu
Tian, Yuandong
contents 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.
format Preprint
id arxiv_https___arxiv_org_abs_2502_08794
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle Spectral Journey: How Transformers Predict the Shortest Path
Cohen, Andrew
Gromov, Andrey
Yang, Kaiyu
Tian, Yuandong
Machine Learning
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.
title Spectral Journey: How Transformers Predict the Shortest Path
topic Machine Learning
url https://arxiv.org/abs/2502.08794