Abstract
As Large Language Models (LLMs) are increasingly deployed as autonomous agents, understanding their internal reasoning processes is paramount. A central question in AI safety and architecture is whether LLMs plan "greedily"—predicting only the most likely next token—or if they engage in "look-ahead" planning by internally representing future states. This paper presents mechanistic evidence that LLMs indeed perform look-ahead planning. By analyzing Llama-2-7b-chat and Vicuna-7B within the Blocksworld domain, we demonstrate that internal representations encode future decisions several steps in advance, primarily driven by Multi-Head Self-Attention (MHSA) mechanisms that synthesize information from goal states and recent history.
Introduction
While LLMs demonstrate remarkable capabilities in web navigation, robotics, and coding, their decision-making process remains largely opaque. In planning tasks—where a sequence of discrete actions must be mapped to reach a specific goal—it is unclear if the model is simply following local statistical patterns or building an internal roadmap of the solution. Distinguishing between greedy next-token prediction and genuine look-ahead planning is crucial for developing more reliable agents and moving toward principled architectural improvements rather than relying solely on trial-and-error prompting.
Methodology
To investigate the internal mechanics of planning, we employed a suite of mechanistic interpretability techniques on Llama-2-7b-chat and Vicuna-7B:
- Extraction Rate Analysis: We measured the relative contributions of Multi-Head Self-Attention (MHSA) and Multi-Layer Perceptron (MLP) components in decoding the final answer at the terminal token.
- Information Flow Tracing: Using gradient-based methods, we mapped the model's attention to specific input segments (e.g., initial state, goal, or previous steps) during different planning stages.
- Linear and Non-linear Probing: We trained auxiliary probes on the hidden states of the LLM to determine if they contained latent information about the current world state and, more importantly, future actions not yet generated.
- Causal Intervention: We performed activation patching by masking or isolating specific information in attention layers to establish a causal link between internal representations and the resulting planning decisions.
Experimental Setup
The study utilized Blocksworld, a classic AI benchmark requiring an agent to move colored blocks into a target configuration. We generated a synthetic dataset featuring 4 to 6 block colors and 4 piles, categorized into three complexity levels: LEVEL1 (2 steps), LEVEL2 (4 steps), and LEVEL3 (6 steps). Models were fine-tuned on a 1:3 training/test split to ensure task proficiency prior to mechanistic analysis.
Key Insights
The Look-Ahead Hypothesis
Our most significant finding confirms that LLMs encode future decisions within their internal hidden states. Probing revealed that the model often contains information about Step 6 while it is still generating Step 1. This suggests the model is not merely reacting to the previous token but is maintaining a representation of the intended trajectory.
MHSA as the Planning Engine
While MLP layers contribute to processing, the MHSA layers are the primary drivers for extracting the correct plan from the context. This extraction is most concentrated in the middle-to-upper layers (specifically layers 15–20), suggesting that planning is an associative task that links goals to specific action sequences.
Goal-Oriented Attention and State Linearity
Information flow analysis indicates that the model "anchors" its attention on the goal state and the most recent history, effectively filtering out older, irrelevant steps. Furthermore, the world state (the physical arrangement of blocks) appears to be stored linearly, as linear probes performed nearly as well as complex non-linear ones in decoding the state from hidden layers.
Quantitative Results
- Future Prediction Accuracy: In Llama-2-7b, probes predicted the 6th future step with 0.51 accuracy at the very first step of the plan. This accuracy improved as the plan progressed, reaching 0.85 when predicting Step 6 from the Step 5 representation.
- Component Dominance: MHSA layers exhibited a significantly higher extraction rate than MLP layers in the network's mid-section, reinforcing the theory that attention is the core mechanism for plan synthesis.
- Causal Impact: Through intervention, making a single past step "visible" to the model increased the probability of selecting the correct future action by up to 0.24, proving that the model actively utilizes historical tokens to refine its future look-ahead.
Discussion and Limitations
While this research provides a breakthrough in understanding LLM reasoning, several limitations remain. The methods require access to internal weights, making them inapplicable to closed-source models like GPT-4. Additionally, the study is limited to the logically rigid Blocksworld environment; it remains to be seen how these mechanisms translate to "commonsense" planning where multiple optimal paths may exist. Finally, the look-ahead horizon is currently limited; the model's certainty drops as the planning depth increases, suggesting that long-term strategic planning remains a significant challenge for current architectures.
Summary updated