In-context learning (ICL) is widely considered the "secret sauce" of modern Large Language Models (LLMs). Since the rise of GPT-3, the ability of models to learn new tasks on the fly from a few prompt examples has revolutionized AI. However, because almost all successful LLMs rely on the Transformer architecture, a fundamental question has lingered: Is the attention mechanism strictly necessary for ICL to emerge?
As the AI community searches for more efficient alternatives to Transformers—which suffer from quadratic computational costs as sequences lengthen—it is critical to understand if new architectures (like State Space Models or modern RNNs) can truly "learn" in-context, or if they are merely sophisticated pattern matchers. This paper systematically investigates whether ICL is an architectural quirk exclusive to attention, or a more universal property of causal language modeling.
Benchmarking 13 Architectures
To isolate ICL ability from pre-existing world knowledge, the researchers conducted a large-scale empirical study. They trained 13 different architectures from scratch (~33M parameters each) on a suite of synthetic tasks where the model must use the prompt to succeed.
The models spanned four major paradigms:
- Recurrent: Classic RNN, LSTM, and GRU.
- Convolutional: LightConv and DynamicConv.
- SSM-inspired: S4, H3, Hyena, Mamba, RetNet, and RWKV.
- Transformers: GPT-2 (absolute positional embeddings) and Llama-2 (rotary embeddings).
The evaluation focused on two primary metrics: statistical efficiency (how quickly a model improves as more examples are added to the prompt) and consistency (whether performance continues to improve or plateaus when the prompt exceeds the length seen during training).
Key Findings: ICL is a Universal Phenomenon
The most striking takeaway from the study is that every architecture tested demonstrated the ability to perform ICL to some degree. This suggests that the simple objective of "predict the next token" naturally incentivizes models to leverage previous tokens as a learning signal, regardless of their internal mathematical structure.
Attention Alternatives Are Ready to Compete
Modern State Space Models (SSMs) like Mamba and Hyena proved to be highly competitive with—and sometimes superior to—Transformers in statistical efficiency. This proves that quadratic attention is not a strict prerequisite for building capable in-context learners.
- Linear Regression: Llama-2, Mamba, and RetNet achieved near-perfect Mean Squared Error (MSE), matching the performance of a theoretical Ridge Regression baseline.
- Multiclass Classification: Mamba dominated this task, achieving the highest accuracy when given a large number of examples (up to 255), outperforming both GPT-2 and Llama-2.
- Overriding Priors: In a flipped-label NLP task (where "happy" might be mapped to "sad"), Hyena was the standout performer. It showed a unique ability to ignore its pre-trained semantic knowledge and strictly follow the provided context.
The "Memorization vs. ICL" Tug-of-War
Models face a choice during training: memorize global statistics or learn to infer patterns from the immediate context. By varying the "burstiness" of the training data (how often specific labels appear in a single prompt), the authors uncovered distinct architectural predispositions.
Some models, like Llama-2 and Hyena, are naturally predisposed to ICL. Others, including classic RNNs, CNNs, and RetNet, prefer to memorize global statistics unless the training data explicitly forces them to rely on context.
The Extrapolation Ceiling
Despite these successes, almost all models—Transformers included—struggle when the number of in-context examples exceeds what they encountered during training. Performance often plateaus or even crashes. This "extrapolation ceiling" suggests that simply having an "infinite context window" doesn't automatically translate to "infinite learning capacity."
For Transformers specifically, the choice of positional embedding was the single biggest factor in determining whether the model could handle longer, out-of-distribution prompts.
Looking Ahead
While this study is comprehensive, it relies on synthetic tasks and relatively small-scale models. Whether these findings hold true at the scale of tens of billions of parameters remains an open question.
Furthermore, the "how" remains a mystery. If Transformers use specific internal structures like "induction heads" to perform ICL, what is the equivalent mechanical process inside a Mamba or Hyena model? Answering this will be the next great frontier in understanding the mechanics of modern AI.
Summary updated