Abstract
Large Language Models (LLMs) exhibit a surprising degree of structural robustness, maintaining 72–95% of their original accuracy even when middle layers are deleted or reordered during inference. This paper investigates this phenomenon across several model families, proposing a "Four-Stage Inference Hypothesis" to explain the depth-dependent roles of transformer layers. By analyzing layer sensitivity, representational similarity, and neuron dynamics, the study identifies four distinct phases: Detokenization, Feature Engineering, Prediction Ensembling, and Residual Sharpening. These findings suggest that while the initial and final layers are critical for grounding and refinement, the middle layers operate with significant redundancy and effectively commutative logic.
Introduction
In the field of mechanistic interpretability, researchers have long debated how Large Language Models (LLMs) process information. Two primary frameworks have emerged: the iterative inference hypothesis, which posits that layers gradually refine predictions through similar, repeated operations, and the circuit hypothesis, which suggests that specific components, such as induction heads, perform highly specialized and modular tasks.
This research seeks to reconcile these views by examining the structural resilience of LLMs. If a model were a series of strictly specialized circuits, one might expect the removal of any single layer to be catastrophic. However, empirical evidence shows that LLMs are remarkably robust to "layer surgery." This paper explores why this robustness exists and whether the computation within a transformer is uniform or divided into distinct functional stages.
Methodology
The researchers conducted a series of "layer-wise interventions" on several decoder-only transformer families, including Pythia, GPT-2, Qwen 2.5, LLaMA 3.2, and Microsoft Phi (ranging from 124M to 6.9B parameters). The study employed five key analytical techniques:
- Layer Deletion (Ablation): Removing a layer entirely and allowing the residual stream to bypass it.
- Layer Swapping: Reversing the execution order of adjacent layers to test for commutativity.
- Logit Lens: Projecting internal activations into the output vocabulary to observe the model's "evolving" prediction at different depths.
- Centered Kernel Analysis (CKA): Measuring the similarity of representations between different layers.
- Probing: Using linear classifiers to detect specific semantic or grammatical features within internal activations.
Performance was benchmarked using one million tokens from the Pile dataset and validated on tasks such as HellaSwag, ARC-Easy, and LAMBADA.
The Four-Stage Inference Hypothesis
The study's most significant finding is a "U-shaped" sensitivity curve. While the first and last layers are indispensable, the middle layers exhibit high redundancy. Based on this, the authors propose that LLMs operate through four depth-dependent stages:
1. Detokenization (Early Layers)
In the initial layers, the model integrates local context to transform raw sub-word embeddings into coherent semantic entities. This stage "stitches" fragments together into concepts. Deleting these layers is typically catastrophic, as the model loses its ability to ground the input tokens in their immediate context.
2. Feature Engineering (Middle Layers)
The middle layers focus on building and refining abstract semantic features. Probing tasks using the Word-in-Context (WiC) dataset show that "meaning" peaks in this region. This stage is the most robust to intervention; swapping or deleting layers here has minimal impact, suggesting that the computation is either parallelized or highly overlapping.
3. Prediction Ensembling (Later Layers)
As the token moves toward the end of the model, it transitions from abstract features to concrete next-token predictions. This phase is characterized by "prediction neurons" that promote specific tokens in the vocabulary.
4. Residual Sharpening (Final Layers)
In the final ~10% of the network, the model performs "cleanup." "Suppression neurons" become dominant, narrowing the probability distribution by suppressing improbable tokens. This reduces entropy and increases the model's confidence in its primary prediction.
Key Results and Observations
The experimental results provide strong evidence for this staged architecture:
- Structural Robustness: Most models retained 72–95% top-1 accuracy despite middle-layer interventions without any additional fine-tuning.
- Commutativity: Swapping adjacent middle layers proved less harmful than deleting them. This suggests that the operations in the "Feature Engineering" stage are effectively commutative, behaving more like an ensemble than a strict sequence.
- Neuron Dynamics: A clear transition was observed in neuron roles, with prediction neurons peaking at approximately 85% depth, followed by a surge in suppression neurons at the very end.
- The Sharpening Effect: In a unique experiment, the authors found that repeating layers from the latter half of the model actually decreased output entropy. This "sharpening" effect confirms that the final layers serve to refine and focus the model's output.
Conclusion and Future Work
The Four-Stage Inference Hypothesis provides a bridge between the iterative and circuit views of LLMs. It suggests that while the model's "thought process" is structured, the middle stages are characterized by a high degree of redundancy that grants the model its remarkable robustness.
However, the authors note that these stage boundaries are approximate and likely overlap. Different data types, such as source code versus natural language, may progress through these stages at different rates. Future research is needed to understand why certain architectures, like the Microsoft Phi series, exhibit higher densities of specific neuron types and how training data mixtures influence the development of these functional stages.
Summary updated