Abstract
Language models' ability to extrapolate learned behaviors to novel, more complex environments beyond their training scope is highly unknown. This study introduces a path planning task in a textualized Gridworld to probe language models' extrapolation capabilities. We show that conventional approaches, including next token prediction and Chain of Thought (CoT) finetuning, fail to extrapolate in larger, unseen environments. Inspired by human cognition and dual process theory, we propose cognitive maps for path planning, a novel CoT framework that simulates humanlike mental representations. Our experiments show that cognitive maps not only enhance extrapolation to unseen environments but also exhibit humanlike characteristics through structured mental simulation and rapid adaptation. Our finding that these cognitive maps require specialized training schemes and cannot be induced through simple prompting opens up important questions about developing general-purpose cognitive maps in language models. Our comparison with exploration-based methods further illuminates the complementary strengths of offline planning and online exploration.
Introduction: The Extrapolation Problem
Current large language models (LLMs) like GPT-4 are masters of pattern matching within their training data, yet they often fail when asked to solve slightly more complex versions of the same problems. This "interpolation gap" is a fundamental limitation in current AI development, particularly for tasks requiring "System 2" (slow, deliberative) reasoning, such as long-horizon planning.
In a spatial navigation task using a textualized Gridworld, models trained on 10x10 grids frequently fail when navigating 20x20 grids. This failure is linked to the task's complexity class ($TC^0$), which implies that a fixed-depth transformer cannot solve it without an extended "thinking" process. To bridge this gap, researchers propose Cognitive Maps, a solution inspired by human mental representations of spatial relationships.
Methods: Cognitive Maps for Path Planning
The core innovation is the Cognitive Map framework, a specialized form of Chain-of-Thought (CoT) reasoning. Instead of listing a final path immediately, the model is trained to verbalize a tree-structured mental representation of the environment through three stages:
- Sampling: Identifying potential actions from the current state.
- Propagation: Simulating movements to predict resulting states, effectively building a global "mental map" of obstacles and boundaries.
- Backtracking: Once the goal is mentally reached, the model retraces its steps to the start to identify the optimal path.
The study compared Forward (FWD) construction (start to goal) against Backward (BWD) construction (goal to start) and tested variants that explicitly marked "dead-end" states.
Experimental Results
Models were trained on 50,000 samples with grid sizes up to 10x10 and tested on 3,000 samples with grid sizes up to 20x20 to measure extrapolation capabilities. Key findings include:
- Massive Performance Boost: In optimal planning on extrapolated grids, the Cognitive Map approach achieved a 76.5% success rate, compared to just 19% for the implicit baseline and 26.5% for standard CoT.
- Thinking Backward is Better: Backward construction (BWD) consistently outperformed forward construction, appearing to be a more robust strategy for LLM planning.
- Unpromptable Nature: These cognitive maps are "unpromptable." Even massive models like GPT-4o or Llama-3-70B cannot produce these structured maps through few-shot prompting alone; they require specialized supervised fine-tuning.
- Efficiency and Adaptation: Cognitive maps achieve near-optimal efficiency ($O(n)$ steps) by simulating the environment internally. Models trained with these maps converged significantly faster, suggesting the structured representation is easier for the model to learn and generalize.
Conclusion and Future Work
This research demonstrates that injecting human-like mental representations into LLMs can significantly enhance their ability to extrapolate to novel, complex environments. While currently focused on 2D spatial navigation, future work aims to generalize these "mental maps" to abstract domains like mathematical problem-solving or code generation. Additionally, hybrid approaches combining offline planning (cognitive maps) with online exploration (active sensing) may bring AI closer to human-level navigation in dynamic environments.
Summary updated