Probing In-Context Learning: Impact of Task Complexity and Model Architecture on Generalization and Efficiency

Binwen Liu, Peiyu Xu, Quan Yuan, Yihong Chen · DOI

Abstract

We investigate in-context learning (ICL) through a meticulous experimental framework that systematically varies task complexity and model architecture. Extending beyond the linear regression baseline, we introduce Gaussian kernel regression and nonlinear dynamical system tasks, which emphasize temporal and recursive reasoning. We evaluate four distinct models: a GPT2-style Transformer, a Transformer with FlashAttention mechanism, a convolutional Hyena-based model, and the Mamba state-space model. Each model is trained from scratch on synthetic datasets and assessed for generalization during testing. Our findings highlight that model architecture significantly shapes ICL performance. The standard Transformer demonstrates robust performance across diverse tasks, while Mamba excels in temporally structured dynamics. Hyena effectively captures long-range dependencies but shows higher variance early in training, and FlashAttention offers computational efficiency but is more sensitive in low-data regimes. Further analysis uncovers locality-induced shortcuts in Gaussian kernel tasks, enhanced nonlinear separability through input range scaling, and the critical role of curriculum learning in mastering high-dimensional tasks.

Introduction

In-Context Learning (ICL) is the emergent capability that allows Large Language Models to solve novel problems via few-shot examples without explicit weight updates. While Transformers have demonstrated remarkable proficiency in ICL, existing research has predominantly focused on simple linear benchmarks. This study addresses a critical gap: understanding how ICL scales with nonlinear or recursive task complexity and how modern, efficient architectures—such as State Space Models (SSMs) and structured convolutions—compare to the standard Transformer in these challenging regimes.

Experimental Framework and Architectures

To systematically evaluate architectural inductive biases, we compared four encoder-only models with matched parameter budgets:

  1. Baseline Transformer: A standard GPT2-style decoder-only architecture.
  2. FlashAttention Transformer: An IO-optimized variant designed to maximize computational throughput.
  3. Hyena: An attention-free model utilizing long, structured convolutions to capture dependencies.
  4. Mamba: A selective State Space Model that leverages recurrence for sequence processing.
Evolution of the Mamba architecture from H3 and Gated MLP.

Training high-dimensional tasks required a robust Curriculum Learning strategy. Models were initially trained on low-dimensional subspaces with short prompts, gradually scaling to more complex configurations. Performance was quantified using Mean Squared Error (MSE) against optimal statistical estimators like Least Squares.

Task Complexity and Datasets

We utilized three synthetic function families to probe specific reasoning dimensions:

  • Linear Regression: The foundational benchmark for ICL.
  • Gaussian Kernel Regression: Designed to test locality and smoothness handling.
  • Nonlinear Dynamical Systems: A suite of systems (e.g., Lorenz, Van der Pol) requiring the tracking of latent states over time, testing recursive reasoning.

Inputs were sampled from high-dimensional spaces (up to $d=100$) to evaluate the limits of generalization.

Key Insights: Inductive Biases and Task Alignment

A primary finding is the critical role of Architectural Alignment. Mamba’s internal recurrence provides a superior inductive bias for dynamical systems. While Transformers struggle with the temporal entanglement of chaotic systems like the Lorenz oscillator, Mamba’s architecture naturally mirrors the recursive nature of these tasks.

Furthermore, we identified a Locality Shortcut in Gaussian kernel tasks: models often defaulted to local interpolation (nearest neighbor) rather than learning the global function. Forcing true compositional reasoning required architectural adjustments like linear readout layers. We also observed that Geometric Separability improves with input range scaling; expanding the range (e.g., to $[-2, 2]$) amplifies higher-order nonlinear features, making them more distinguishable in the representation space.

Performance Evaluation and Results

The standard Transformer remains a robust generalist, showing stable error reduction across all tasks. However, Mamba demonstrated a clear "temporal edge," significantly outperforming Transformers in nonlinear dynamical systems as sequence lengths increased.

Memory hierarchy and FlashAttention's computational efficiency compared to standard PyTorch implementations.

While FlashAttention and Hyena offered substantial efficiency gains, they exhibited higher sensitivity in low-data regimes. FlashAttention, in particular, showed larger performance fluctuations with short prompts compared to the baseline Transformer. Finally, curriculum learning proved indispensable; without it, models frequently suffered from "gradient starvation" in high-dimensional settings.

Conclusion

This research highlights that while Transformers are versatile, specialized architectures like Mamba offer significant advantages for specific classes of recursive tasks. Future work will explore hybrid architectures that combine the general reasoning of Transformers with the temporal efficiency of SSMs, as well as scaling these findings to billion-parameter regimes.

Summary updated

BibTeX
@misc{liu2025probing,
  author = {Binwen Liu and Peiyu Xu and Quan Yuan and Yihong Chen},
  title = {{Probing In-Context Learning: Impact of Task Complexity and Model Architecture on Generalization and Efficiency}},
  year = {2025},
  eprint = {2505.06475},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.06475},
}
Figure