π€ AI Summary
This work addresses the limited understanding of in-context learning (ICL) mechanisms in large language models, which hinders error diagnosis and controllability. We propose the βcounting hypothesis,β positing that models implement ICL by encoding the frequency of examples within the context, and present the first systematic validation of this mechanism. Through functional module analysis, prompt engineering, and behavioral experiments, we provide empirical evidence supporting the counting hypothesis and uncover how models leverage example frequencies to perform inference in few-shot settings. Our findings offer a novel perspective on the internal workings of ICL and lay a foundation for enhancing the interpretability and controllability of large language models.
π 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.