Abstract
In-Context Learning (ICL) is a cornerstone of modern Large Language Models (LLMs), enabling them to perform new tasks without weight updates. However, traditional synthetic studies of ICL often focus solely on few-shot examples, ignoring the critical role of task instructions. This paper introduces In-Context Learning with Hypothesis-Class Guidance (ICL-HCG), a framework that models instructions as a "hypothesis prefix." Our experiments demonstrate that while Transformers and Mamba can generalize to unseen tasks using these prefixes, traditional recurrent architectures like LSTMs fail. We further analyze the trade-offs between Transformers and Mamba regarding sample efficiency and context length generalization.
Introduction
The ability of LLMs to solve tasks via prompting—In-Context Learning—is often studied through synthetic tasks like linear regression or parity checking. In these setups, a model receives a sequence of input-output pairs $(x^{(1)}, y^{(1)}, \dots, x^{(k)})$ and must predict $y^{(k)}$ for a new $x^{(k)}$. While useful, this setup misses a vital component of real-world usage: instructions. In practice, users provide a natural language description of the task (e.g., "Translate to French") before the examples.
As shown in Figure 2, there is a gap between standard synthetic ICL and real-world applications. The ICL-HCG framework bridges this by prepending a "hypothesis prefix" to the example sequence, representing a set of possible functions (a hypothesis class $\mathcal{H}$) the model might encounter.
The ICL-HCG Framework
The core of ICL-HCG is the hypothesis prefix. Instead of the model having to infer the entire task structure from examples alone, it is given a "menu" of potential functions.
- Hypothesis Prefix: A representation of a hypothesis class $\mathcal{H} = \{h_1, h_2, h_3, \dots\}$.
- Task Execution: The model uses subsequent $(x, y)$ pairs to identify which specific $h \in \mathcal{H}$ is active and predicts the output for the query $x^{(k)}$.
This setup allows researchers to mathematically define "instructions" and test how different architectures utilize this prior information to narrow down the task space.
Experimental Setup: Generalization and Diversity
To evaluate true meta-learning, the researchers defined a "Hypothesis Universe" ($\mathcal{H}^{uni}$) consisting of binary classification functions. They split this universe into In-Distribution (ID) and Out-of-Distribution (OOD) sets.
As illustrated in Figure 6, the model is trained on a specific pool of hypothesis classes and tested on its ability to generalize. This includes:
- ID Generalization: Testing on new functions within a known class.
- OOD Generalization: Testing on entirely new hypothesis classes (new "menus") that were never seen during training.
Key Insights and Results
Instructions as Force Multipliers
The inclusion of the hypothesis prefix significantly improves performance. For instance, Transformers achieve approximately 95% accuracy with only three examples when guided by a prefix, compared to roughly 80% without it. This confirms that instructions act as a powerful prior that simplifies the learning problem.
Architectural Comparisons: Transformer vs. Mamba
The study compared Transformers with Mamba (a selective state-space model). A notable trade-off emerged:
- Mamba exhibited superior sample efficiency, reaching high generalization performance after being exposed to far fewer task types during training.
- Transformers demonstrated better length generalization, maintaining performance more effectively as the size of the hypothesis class (the "menu" length) increased.
The Failure of Recurrence
Surprisingly, LSTMs and GRUs failed to perform above random chance in the ICL-HCG setting. This suggests that the specific architectural features of modern models—such as the attention mechanism in Transformers or the selective gating in Mamba—are essential for the high-level reasoning required to map instructions to examples.
Conclusion and Future Work
ICL-HCG provides a rigorous mathematical framework for studying the interplay between instructions and examples in ICL. While it highlights the strengths of Transformers and Mamba, it also points to future challenges. Current instructions are represented as explicit tables; future work must bridge the gap to natural language. Additionally, understanding why Mamba excels in sample efficiency while Transformers lead in context handling remains a key area for architectural research.
Summary updated