Recent advances in language models have shown remarkable capabilities in various domains, from natural language understanding to complex reasoning tasks. However, their ability to extrapolate beyond training data remains a significant challenge, particularly in structured problem-solving scenarios like path planning and navigation, even after fine-tuning[1].
The Human Edge in Problem-Solving
Humans demonstrate remarkable abilities in generalizing problem-solving strategies across different scales and complexities. This capability stems from our cognitive architecture, which cognitive scientists have long studied and categorized into two primary systems [2]:
- System 1: Quick, instinctive responses based on familiar patterns, operating automatically and with little effort
- System 2: Careful, methodical thinking that creates mental maps of problems, engaging in conscious reasoning and strategic planning
This dual-process theory has profound implications for AI development, particularly in how we approach the challenge of making language models truly cognitive.
Recent approaches, such as Chain of Thought (CoT) reasoning[3], show promise for mimicking System 2 reasoning via in-context learning. Theoretical findings suggest that complex problems outside the `TC^0 ` (polynomial-sized constant-depth circuits) complexity class can be solved with an ample amount of CoT tokens[4]. However, the precise form of CoT required remains unclear. Our research is to configure the CoT variant that can show emergent cognitive map-like behavior in language models.
Extrapolation in Gridworld as a Probe of Cognitive Map
How do we know if the language model exhibits cognitive map-like behavior? We investigate this through extrapolation, a key characteristic of System 2 reasoning. By training a language model with simple demonstrations and testing its extrapolation capabilities in complex environments, we can determine if it possesses cognitive maps. Specifically, we utilize a Gridworld environment for several compelling reasons:
- Cognitive science foundations: Probing mental representations through spatial tasks is foundational in cognitive science[5]
- Minimal knowledge requirements: Gridworld provides an ideal environment to probe the extrapolability of language models while minimizing the influence of world knowledge
- Scalability: Gridworld allows us to systematically increase the problem space by expanding the grid dimensions
- Complexity class and computational limitations: Gridworld has a complexity class outside `TC^0`, so a fixed-precision transformer can't solve it[6]
To measure true extrapolability of language models, we designed a rigorous experimental setup:
- Training Environment: Limited to 10x10 grids maximum
- Testing Environment: Extended to 20x20 grids maximum
- Key Challenge: Evaluating extrapolation beyond training distribution
Our test set features significantly longer input tokens and higher environmental complexity compared to the training set, allowing us to evaluate true extrapolation capabilities.
We observe clear differences between training and testing environments in both input length and complexity (measured by the negative log probability of successfully completing an optimal path using a random policy). Our hypothesis is that models equipped with cognitive map-like reasoning should be able to effectively handle test cases outside the training distribution (shown in red box) by leveraging their systematic planning capabilities.
We test two types of planning scenarios in Gridworld: optimal planning and reachable planning. Optimal planning involves finding the shortest path to the goal, while reachable planning allows for multiple steps to reach the goal. The key difference lies in the complexity of the planning task and the need for offline planning before actual interaction. Optimal planning requires a comprehensive mental model of the environment, akin to cognitive maps, to find the shortest path efficiently.
Cognitive Maps for Path Planning: Planning with World Model through CoT
The cognitive map framework operates through three integrated stages: sampling, propagation, and backtracking. This architecture enables language models to simultaneously 1) build robust world model of novel environments and 2) perform model-based planning through CoT reasoning. At the sampling stage, the model extracts key environmental features and relationships. During propagation, it extends these initial observations into a broader cognitive map. The backtracking stage then leverages this representation to identify optimal solutions by evaluating potential paths and their outcomes. Our experiments demonstrate that this approach significantly enhances the model's ability to extrapolate beyond its training data, generating effective solutions for previously unseen scenarios without requiring external feedback or interaction.
Key Components:
- Sampling: Systematic exploration of the state space to identify potential paths and obstacles
- Propagation: Building a comprehensive mental model of the environment through information sharing between states
- Backtracking: Efficient path planning by working backwards from the goal state
Experimental Results
We compared the performance of language models equipped with cognitive maps against baseline models with implicit (directly predicting the next action) and explicit (predicting the next action via conventional CoT) planning capabilities. Here are some key findings:
Our experiments demonstrate that models equipped with cognitive maps only shows significant improvements in extrapolation capabilities, achieving higher success rates in unseen environments and more optimal paths in reachable planning scenarios.
We further support our analysis by examining model performance across problem complexity and input length. While baseline methods fail sharply beyond training boundaries, cognitive maps maintain significant performance at twice the training thresholds.