A Comparative Analysis of Attention versus State-Space Models for In-Context Learning
Organizations: The Ohio State University · RWTH Aachen University
Abstract
Transformers and state-space models (SSMs) are two prominent sequential learning architectures, yet their comparison remains largely empirical and existing theoretical analyses are typically task-specific or architecturally restricted. In this paper, we develop belief geometry, a unified analytical framework for comparing the representational capabilities of broad classes of attention and SSMs. Starting from a generalized formulation of in-context linear regression and using cumulative Bayes regret as our measure, we abstract three capabilities required by many sequential learning problems in our belief geometry: evidence assembly, belief maintenance, and addressing. We then study three cases of our formulation that isolate these capabilities and yield sharp architectural lessons: For belief maintenance, SSMs attain the optimal regret over stationary aggregation kernels; for positional assembly, SSMs have a memory advantage; and for content addressing, softmax attention has an exponential width advantage over sigmoid-selective SSMs. Experiments with LLaMA-type Transformers and Mamba-2 show that these architectural insights extend beyond our analytically tractable classes and linear-regression testbed.
Figures & tables
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
| Bottleneck (Belief geometry tool) | Lower-bound classes | Construction classes | |
|---|---|---|---|
| Case 1 (§ 3 ) | Belief maintenance (Aggregation kernel) | Proposition 1 , or fixed , | Proposition 1 , , |
| Case 2.a (§ 4.1 ) | Evidence assembly (Belief alignment) | Corollary 1 , | Proposition 2 , , |
| Case 2.b (§ 4.2 ) | Addressing (Addressing capacity) | Theorem 3 , | Proposition 4 |
| Architecture | Reference |
|---|---|
| Transformer | Vaswani et al. (2017) |
| LLaMA | Touvron et al. (2023) |
| S4 | Gu et al. (2022) |
| H3 | Fu et al. (2023) |
| RetNet | Sun et al. (2023) |
| Mamba | Gu & Dao (2024) |
State Space Models
State space models represent sequences through evolving latent states, enabling efficient temporal modeling, system identification, and forecasting.
See all 287 papers