TL;DR
This paper provides compelling evidence that Large Language Models (LLMs) internally decompose complex tasks into sequential subtasks, executing them layer by layer. By introducing novel methods like "layer-from context-masking" and "cross-task patching," the authors demonstrate that LLMs learn and process these subtasks in a structured, hierarchical manner, akin to an "internal chain-of-thought." This finding significantly enhances our understanding of LLM interpretability and opens new avenues for fine-grained control over their behavior.
What Problem Does This Paper Address?
While LLMs have shown remarkable capabilities in complex tasks like instruction following and multi-step problem-solving, much of their internal reasoning process remains a black box. Existing "chain-of-thought" prompting techniques externalize this reasoning by guiding the model to generate intermediate steps. However, a crucial question remained: do LLMs perform such multi-step reasoning internally, without explicit prompting? This paper tackles this gap by investigating whether LLMs possess an "internal chain-of-thought" (ICoT), where they sequentially break down and execute composite tasks across their network layers. Understanding this internal process is key to improving LLM transparency, reliability, and controllability.
Methods
The authors introduce two primary methods to probe for ICoT:
- Layer-from Context-Masking: This technique selectively masks attention to the in-context examples (demonstrations) from specific layers onwards. By observing how performance degrades as masking progresses, the authors can infer at which layers specific subtasks are learned. A distinct "X-shape" pattern in these results indicates sequential learning.
- Cross-Task Patching: This novel method investigates whether LLMs learn reusable, abstract "subtask vectors." Activations from a composite task prompt are "patched" into zero-shot prompts for individual subtasks. If performance on the subtask improves, it suggests the composite prompt's activation encodes a transferable subtask representation.
Additionally, they employ LogitLens to decode hidden states and track the Mean Reciprocal Rank (MRR) of intermediate and final outputs across layers, providing evidence for sequential execution.
Datasets
The primary dataset used is a newly constructed benchmark of 15 two-step composite tasks, spanning four categories: Knowledge-Algorithmic, Extractive-Knowledge, Extractive-Algorithmic, and Knowledge-Translation. These tasks are designed to require sequential application of two distinct subtasks (s1 ∘ s2).
The authors also evaluate their methods on the TRACE benchmark, a real-world complex instruction-following dataset, to demonstrate the applicability of their findings in practical scenarios.
Key Insights and Ideas
- LLMs Have an "Internal Chain-of-Thought": The most significant insight is that LLMs don't just follow explicit chain-of-thought prompts; they possess an inherent capability to decompose and execute tasks sequentially across their layers.
- Layered Learning of Subtasks: Different subtasks within a composite task are learned at distinct network depths. The "X-shape" pattern observed in context-masking experiments clearly shows that the model first learns the initial subtask (s1) at earlier layers and then learns the subsequent subtask (s2) at deeper layers.
- Sequential Execution of Subtasks: The LogitLens analysis reveals a clear "handoff" pattern. Intermediate subtask outputs peak in middle layers and are then superseded by the final output in later layers, indicating a sequential execution flow (s2(s1(x))).
- Transferable Subtask Vectors: Cross-task patching demonstrates that LLMs learn reusable representations for subtasks, which can be transferred across different tasks. This suggests that LLMs develop abstract modules for specific operations.
- Real-World Applicability: The findings on the TRACE benchmark confirm that these internal reasoning dynamics are not limited to synthetic tasks but are present in complex, real-world instruction-following scenarios.
Key Results
- Context-Masking: Consistently revealed an "X-shape" pattern across four different LLMs (Llama-3.1-8B, Mistral-7B, Qwen2.5-7B, Llama-3.2-3B) and 15 composite tasks, indicating sequential learning of subtasks.
- Cross-Task Patching: Showed that composite task activations could transfer to individual subtasks with a significant average strength of 0.66, demonstrating reusable subtask vectors.
- LogitLens Decoding: Provided visual evidence of intermediate subtask MRR peaking in middle layers and being overtaken by the final subtask MRR in later layers, supporting sequential execution.
- TRACE Benchmark: Layer-from context-masking on TRACE showed that different constraint types (e.g., Output Format vs. Inclusion/Tone/Style) were learned at different depths, further supporting the layered learning hypothesis.
Limitations and Future Work
- Task Construction Bias: The authors acknowledge that the "X-shape" pattern might be facilitated by the deliberate design of their benchmark tasks, which feature clearly distinguishable subtask types. More complex, real-world tasks with similar subtasks might exhibit more intertwined learning dynamics. Future work could explore these more entangled scenarios.
- TRACE Evaluation: The evaluation on TRACE relied on LLM-based scoring, which has inherent limitations like calibration issues and lack of human ground truth. Exploratory alternatives like logit-based measures or human validation are suggested.
- Model and Scale Scope: Experiments were conducted on mid-sized models (3B-8B parameters). It remains an open question whether these phenomena generalize to larger frontier models. Differences in architecture, training, and alignment could lead to distinct patterns.
- Future Directions: The discovery of ICoT opens avenues for fine-grained, instruction-level behavior control. For instance, by identifying layers responsible for specific (potentially harmful) instructions, interventions could be made to steer LLM behavior for safer outputs.
Summary updated