mlsanityData to 14 Oct 2026

Cognitive Maps in Language Models: A Mechanistic Analysis of Spatial Planning

arXiv 2511.13371 ↗First posted 17 Nov 2025cs.AIcited by 1

Not on the map. Why?

Abstract (arXiv)

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 also adopts an adaptive, hierarchical reasoning system, switching between a low-level heuristic for short contexts and map-based inference for longer ones. In contrast, the goal-directed models learn a path-dependent algorithm, remaining reliant on explicit directional inputs throughout all layers. The hybrid model, despite demonstrating improved generalisation over its parent, retains the same path-dependent strategy. These findings suggest that the nature of spatial intelligence in transformers may lie on a spectrum, ranging from generalisable world models shaped by exploratory data to heuristics optimised for goal-directed tasks. We provide a mechanistic account of this generalisation-optimisation trade-off and highlight how the choice of training regime influences the strategies that emerge.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 9 of its 15 references that are in the map. First posted on arXiv 17 Nov 2025.

Builds on

9 of 15 references.

References · 9

  1. 2023Progress measures for grokking via mechanistic interpretabilitycited by 839
  2. 2023Towards Automated Circuit Discovery for Mechanistic Interpretabilitycited by 724
  3. 2023Faith and Fate: Limits of Transformers on Compositionalitycited by 503
  4. 2024How to use and interpret activation patchingcited by 214
  5. 2024The pitfalls of next-token predictioncited by 160
  6. 2025Language Models Use Trigonometry to Do Additioncited by 70
  7. 2024The Cognitive Revolution in Interpretability: From Explaining Behavior to Interpreting Representations and Algorithmscited by 13
  8. 2024Transformers Can Navigate Mazes With Multi-Step Predictioncited by 11
  9. 2024Learning Cognitive Maps from Transformer Representations for Efficient Planning in Partially Observed Environmentscited by 6

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 1.

1 paper.

Similar, not cited

Close in wording, no citation either way

  1. 2025From Text to Space: Mapping Abstract Spatial Models in LLMs during a Grid-World Navigation Task
  2. 2026From Human Cognition to Neural Activations: Probing the Computational Primitives of Spatial Reasoning in LLMs
  3. 2026Do LLMs Build Spatial World Models? Evidence from Grid-World Maze Tasks
  4. 2025From reactive to cognitive: brain-inspired spatial intelligence for embodied agents
  5. 2025MazeEval: A Benchmark for Testing Sequential Decision-Making in Language Models
  6. 2026The Sword, Shield, and Achilles' Heel: Characterizing the Linguistic Inductive Bias of Large Language Models for Spatial Reasoning in Navigation Planning
  7. 2024How language models extrapolate outside the training data: A case study in Textualized Gridworld
  8. 2025Thinking on Maps: How Foundation Model Agents Explore, Remember, and Reason Map Environments