A Comparative Analysis of Attention versus State-Space Models for In-Context Learning

Enes Arda, Semih Cayci, Atilla EryilmazarXiv 2026

Researchers and engineers have long debated the merits of Transformers versus State-Space Models (SSMs) like Mamba. While Transformers dominate the field, SSMs promise better scaling for long sequences. However, most comparisons remain empirical.

This paper introduces belief geometry, a unified theoretical framework that moves beyond "which is better" to "why and at what cost." By analyzing In-Context Learning (ICL) through the lens of Bayesian regret, the authors identify fundamental architectural trade-offs that explain the strengths and weaknesses of each family.

TL;DR

The authors develop "belief geometry" to show that SSMs are naturally superior at maintaining historical beliefs and handling positional tasks with minimal memory, whereas Softmax Attention provides an exponential efficiency advantage for complex content-based retrieval (associative recall).

What Problem Does This Paper Address?

Despite the success of both Transformers and SSMs, we lack a principled understanding of their representational differences. Existing theory is often too narrow—focusing on a single task or a restricted version of an architecture.

The authors argue that sequential learning requires three distinct capabilities:

  1. Evidence Assembly: Combining information across different time steps (e.g., pairing a reward with a past action).
  2. Belief Maintenance: Aggregating that evidence into a coherent internal model.
  3. Addressing: Finding the specific part of history relevant to the current prediction.

The paper aims to quantify how different architectural choices (like softmax vs. linear attention, or fixed vs. selective transitions in SSMs) supply these capabilities and at what resource cost (width, depth, and memory).

Methods

The researchers generalize In-Context Linear Regression (ICLR) by introducing "routing." In standard ICLR, the label $y_t$ is paired with the regressor $x_t$ in the same token. In this paper's routed setup, $y_t$ might be generated by a regressor $x_{t-K}$ from $K$ steps ago (positional routing) or by a regressor associated with a specific "key" (content routing).

They evaluate models using cumulative Bayes regret—the total excess loss incurred over an entire sequence compared to an optimal Bayesian predictor. This is a more rigorous metric than evaluating loss only at the end of a context window.

To analyze this, they project model predictions into a "belief subspace" (see Figure 1), allowing them to decompose errors into specific failures of assembly, maintenance, or addressing.

Figure 1: Belief geometry in Ht.

Datasets

The paper relies on sophisticated synthetic benchmarks designed to isolate specific learning challenges:

  • Gaussian Filtering: Used to test belief maintenance.
  • Delayed-Feedback Contextual Logistic Bandits: A 30-arm bandit task used to test positional assembly.
  • Continuous-Valued Associative Recall: A task where models must retrieve a specific regressor based on a codebook of keys, testing content addressing.

These are validated using practical implementations of LLaMA-type Transformers and Mamba-2.

Key Insights and Ideas

  • The Inductive Bias of Kernels: One-layer models can only realize "stationary" kernels (weights that depend only on the time lag). SSMs naturally implement exponential decay, which is optimal for these tasks. Linear attention uses a uniform window, which suffers from a "cold-start" bias. Figure 2 shows how practical models inherit these biases even after training.
  • Positional Reach vs. Memory: For tasks requiring models to look back a fixed number of steps ($K$), SSMs have a massive memory advantage. They use convolution for "reach" and recurrence for "maintenance," whereas Transformers must use their context window for both.
  • The Softmax "Superpower": The most striking finding is the exponential width advantage of softmax attention for content addressing. To select one relevant item out of $R$ candidates, a Transformer needs a width of only $O(\log R)$. In contrast, a selective SSM (like Mamba) must keep candidates separate in its recurrent state, requiring a width of $O(R)$.
Figure 2: Kernel alignment in practical models under finite optimization. Shading shows 95% bootstrap CIs over 20 seeds.

Key Results

  • Belief Maintenance: SSMs attain the optimal stationary regret floor, while linear attention pays a "shape factor" penalty of $2/\sqrt{3}$ (approx. 15% higher regret).
  • Memory Efficiency: In positional routing tasks, the lowest-memory Transformer required 5.2x more storage than a comparable Mamba-2 model to achieve the same performance level.
  • Scaling for Retrieval: As the number of keys ($R$) in associative recall grows, the required width for Mamba-2 grows quadratically/linearly, while the Transformer's required width stays nearly constant (logarithmic growth). This is validated in Figure 6 (page 9 of the paper), showing the "smallest width to succeed" scaling.

Limitations and Future Work

  • Linear/Logistic Focus: While the framework is general, the specific analytical results are derived for linear and logistic regression. Extending this to more complex, non-linear manifolds is a natural next step.
  • Single-Layer Selectivity: The lower bounds for selective SSMs currently assume selectivity only in the first layer. The authors note that extending this to fully selective deep stacks is a significant theoretical challenge.
  • Optimization: The analysis is representational (what can a model do?). The authors suggest that future work should bridge this with optimization theory to explain why certain architectures are easier to train for specific tasks.

Summary updated

BibTeX
@misc{arda2026comparative,
  author = {Enes Arda and Semih Cayci and Atilla Eryilmaz},
  title = {{A Comparative Analysis of Attention versus State-Space Models for In-Context Learning}},
  year = {2026},
  eprint = {2609.32341},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.32341},
}
Figure