Language models form cognitive maps to understand relationships

Cognitive Map in Large Language Models

Computation and LanguageMachine Learning

Summary

Some animals create mental maps to navigate new places, and this paper explores if large language models do something similar. The authors found that big language models can figure out hidden connections between things and remember relationships as pairs of linked facts. These mental maps don’t position everything in one big space but connect items like building blocks, which helps the model reason with limited clues. By changing certain internal patterns, the models can be made to 'remember' incorrect facts, showing how their mental map is organized.

What this means in practice

  • For natural language processing engineers: Improve language model designs by targeting pairwise relational memory structures to enhance reasoning about entity relationships.
  • For ai safety teams: Develop techniques to detect and prevent false memories implanted via key-value pair perturbations in language models, improving reliability.

Authors

Albert Qin, Jonathan Cohen, Gautam Reddy

Abstract

It has long been proposed that animals construct cognitive maps to support flexible behavior in novel environments. We tested whether large language models form similar representations using relational reasoning tasks and causal "mosaic experiments" that manipulate internal activations in open-weight language models. Models beyond the ten-billion-parameter scale successfully inferred unstated relationships between entities and generalized to synthetic entity names. Across model and task families, models generated abstract representations of relational structure and combined them additively with representations of entity identity, binding entities to roles within that structure. Models stored observed relationships as pairwise links that they composed retrospectively when queried, rather than prospectively positioning each entity in a global coordinate system. Binding was mediated by a sparse, distributed set of key--value pairs; by perturbing these pairs, we implanted "false memories" that altered model behavior in predictable ways. Overall, our findings reveal an internal organization analogous to a cognitive map that explains how language models reason with limited information.