Inference and Verbalization Functions During In-Context Learning
Junyi Tao, Xiaoyin Chen, Nelson F. Liu
TL;DR
This work probes how in-context learning in large language models operates when demonstrations use irrelevant or misleading label words. It proposes a two-function causal decomposition: an inference function that derives an answer representation and a verbalization function that maps that representation to the demonstrated label space, with the inference function invariant to label remappings. Using interchange interventions, the authors demonstrate that these functions can be localized in separate, consistent layers across multiple models and tasks, supporting a mechanistic account of ICL. The findings show middle-layer interventions reliably induce counterfactual outputs, suggesting robust transfer of information between the two functions, and generalize across datasets like MultiNLI, RTE, ANLI, IMDb, and AGNews. Overall, the paper advances a causal, mechanistic understanding of ICL and offers a methodology for probing internal representations with potential implications for robust prompt design and model interpretability ($H_1$,$H_2$,$H_3$).
Abstract
Large language models (LMs) are capable of in-context learning from a few demonstrations (example-label pairs) to solve new tasks during inference. Despite the intuitive importance of high-quality demonstrations, previous work has observed that, in some settings, ICL performance is minimally affected by irrelevant labels (Min et al., 2022). We hypothesize that LMs perform ICL with irrelevant labels via two sequential processes: an inference function that solves the task, followed by a verbalization function that maps the inferred answer to the label space. Importantly, we hypothesize that the inference function is invariant to remappings of the label space (e.g., "true"/"false" to "cat"/"dog"), enabling LMs to share the same inference function across settings with different label words. We empirically validate this hypothesis with controlled layer-wise interchange intervention experiments. Our findings confirm the hypotheses on multiple datasets and tasks (natural language inference, sentiment analysis, and topic classification) and further suggest that the two functions can be localized in specific layers across various open-sourced models, including GEMMA-7B, MISTRAL-7B-V0.3, GEMMA-2-27B, and LLAMA-3.1-70B.
