Abstract
Recent research into Large Language Models (LLMs) reveals that In-Context Learning (ICL) operates through a distinct two-step internal pipeline. This process involves an initial inference function that computes an abstract task solution, followed by a verbalization function that maps this solution to specific output tokens. By employing interchange intervention techniques, this study demonstrates that internal task representations are often invariant to the specific label words used in the prompt.
Introduction
In-Context Learning (ICL) allows LLMs to perform new tasks based solely on a few examples provided in the prompt. A puzzling observation in prior work is that ICL remains effective even when labels are replaced with semantically unrelated words (e.g., using "cat" for "positive"). This suggests that models might not be merely matching surface patterns but performing abstract reasoning.
This paper investigates the causal mechanisms behind this behavior, proposing three primary hypotheses regarding the model's internal architecture:
- Causal Mechanism (H1): The model infers a task representation and then verbalizes it.
- Invariance (H2): The inference process is shared across different label sets for the same task.
- Localization (H3): These functions are consistently localized within specific model layers.
Methodology: Interchange Intervention
To test these hypotheses, the authors use Interchange Intervention (a form of activation patching). The method involves two parallel model instances: a "Source" model prompted with standard labels (e.g., "true/false") and an "Intervened" model prompted with remapped labels (e.g., "cat/dog").
By "transplanting" hidden state activations from a specific layer $l$ of the Source model into the Intervened model, researchers can observe if the output "flips" to the corresponding remapped label. A successful flip indicates that the representation at layer $l$ contains task-relevant information that is independent of the final verbalization.
Results and Key Insights
The experimental results across various benchmarks (NLI, Sentiment Analysis, Topic Classification) and models (Gemma, Mistral, Llama) strongly support the proposed two-stage pipeline.
Functional Localization and Label Invariance
The study found that the "verbalization" logic typically peaks in the middle-to-late layers. For instance, in Gemma-7B, interventions at layers 18–20 yielded flip rates exceeding 90%. This confirms that the model's internal "thought" regarding the task is fully formed before it is mapped to a specific output word. This "inference" stage is remarkably robust and invariant to changes in the label space.
Discussion and Limitations
While the findings provide a clear modular view of classification tasks, several questions remain. The study focuses on discrete label spaces; it is yet to be determined if this pipeline exists for open-ended generation. Additionally, because the method requires access to internal activations, it is currently limited to open-source models. Future work will explore how the "Inference" function itself is constructed in the earlier layers and whether these findings generalize to more complex, non-classification reasoning tasks.
Summary updated