From Text to Space: Mapping Abstract Spatial Models in LLMs during a Grid-World Navigation Task
Nicolas Martorell
TL;DR
The paper examines how text-based spatial representations shape LLM navigation in a grid-world task, comparing Cartesian, Topographic, and Textual encodings across LLaMA-3 models from $1\mathrm{B}$ to $90\mathrm{B}$ parameters on a $5\times 5$ grid. It finds Cartesian representations yield higher success and path efficiency, with performance scaling with model size and JSON formatting often performing best. Probing reveals mid-layer units that encode agent position and action correctness across representations, including a subset active in unrelated spatial reasoning, indicating an abstract internal spatial model, though ablations show space encoding is distributed and not strictly necessary for task success. These findings advance interpretability of spatial processing in LLMs and offer guidance for designing robust, agentic AI systems that rely on spatial reasoning, while outlining limitations and directions for extending to larger, more complex, and multimodal scenarios.
Abstract
Understanding how large language models (LLMs) represent and reason about spatial information is crucial for building robust agentic systems that can navigate real and simulated environments. In this work, we investigate the influence of different text-based spatial representations on LLM performance and internal activations in a grid-world navigation task. By evaluating models of various sizes on a task that requires navigating toward a goal, we examine how the format used to encode spatial information impacts decision-making. Our experiments reveal that cartesian representations of space consistently yield higher success rates and path efficiency, with performance scaling markedly with model size. Moreover, probing LLaMA-3.1-8B revealed subsets of internal units, primarily located in intermediate layers, that robustly correlate with spatial features, such as the position of the agent in the grid or action correctness, regardless of how that information is represented, and are also activated by unrelated spatial reasoning tasks. This work advances our understanding of how LLMs process spatial information and provides valuable insights for developing more interpretable and robust agentic AI systems.
