Counting Hypothesis: Potential Mechanism of In-Context Learning
Jung H. Lee, Sujith Vijayan
TL;DR
This work proposes the Counting Hypothesis to explain In-Context Learning in pretrained LLMs, suggesting that fixed transformer computations encode context-dependent subspaces in residual streams that allow competing potential answers to be inferred from prompt examples. It argues FFNs function as associative memories storing keys and values, enabling parallel encoding of multiple candidate answers, and that last-separator predictions leverage common subspace components shared with answer tokens. The authors support this with dictionary learning and ICA analyses across six models, showing shared components between separators and answers and increasing alignment as depth grows; they also demonstrate a diagnostic embedding signal (ratio R) that distinguishes correct from incorrect predictions. If validated, this framework offers a mechanistic lens on ICL, enabling reliability diagnostics and guiding future architectural and training strategies to enhance in-context adaptability without fine-tuning.
Abstract
In-Context Learning (ICL) indicates that large language models (LLMs) pretrained on a massive amount of data can learn specific tasks from input prompts' examples. ICL is notable for two reasons. First, it does not need modification of LLMs' internal structure. Second, it enables LLMs to perform a wide range of tasks/functions with a few examples demonstrating a desirable task. ICL opens up new ways to utilize LLMs in more domains, but its underlying mechanisms still remain poorly understood, making error correction and diagnosis extremely challenging. Thus, it is imperative that we better understand the limitations of ICL and how exactly LLMs support ICL. Inspired by ICL properties and LLMs' functional modules, we propose 1the counting hypothesis' of ICL, which suggests that LLMs' encoding strategy may underlie ICL, and provide supporting evidence.
