Cognitive Maps in Language Models: A Mechanistic Analysis of Spatial Planning
Caroline Baumgartner, Eleanor Spens, Neil Burgess, Petru Manescu

TL;DR
This paper investigates how GPT-2 models develop spatial understanding, revealing two distinct algorithms: a map-like cognitive model from passive exploration and a path-dependent strategy from goal-directed training, influenced by training regimes.
Contribution
It provides a mechanistic analysis of spatial learning in language models, identifying how different training paradigms lead to different spatial reasoning strategies.
Findings
The foraging model develops a map-like spatial representation.
Causal interventions show reliance on a coordinate system in the foraging model.
Goal-directed models rely on explicit directional inputs throughout.
Abstract
How do large language models solve spatial navigation tasks? We investigate this by training GPT-2 models on three spatial learning paradigms in grid environments: passive exploration (Foraging Model- predicting steps in random walks), goal-directed planning (generating optimal shortest paths) on structured Hamiltonian paths (SP-Hamiltonian), and a hybrid model fine-tuned with exploratory data (SP-Random Walk). Using behavioural, representational and mechanistic analyses, we uncover two fundamentally different learned algorithms. The Foraging model develops a robust, map-like representation of space, akin to a 'cognitive map'. Causal interventions reveal that it learns to consolidate spatial information into a self-sufficient coordinate system, evidenced by a sharp phase transition where its reliance on historical direction tokens vanishes by the middle layers of the network. The model…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsSpatial Cognition and Navigation · Constraint Satisfaction and Optimization · Categorization, perception, and language
