Bayesian Optimality of In-Context Learning with Selective State Spaces
Di Zhang, Jiaqi Xing
TL;DR
This work reframes in-context learning as Bayesian sequential inference over latent state-space tasks, formalizing ICL as meta-learning across Linear Gaussian State Space Models (LG-SSMs). It proves that meta-trained selective SSMs asymptotically implement the Bayes-optimal predictor, converging to the posterior predictive mean, and establishes a computational-statistical separation from gradient-descent ERM-based transformers under temporally structured noise. The authors provide a Filter Representation Lemma showing selective SSMs can realize Kalman-filter updates, and Theorem 1 with consistency and efficiency results, along with Theorem 2 demonstrating strictly lower asymptotic risk than ERM in a correlated-noise task family. Empirical results on synthetic LG-SSMs and a character-level Markov benchmark confirm faster convergence to Bayes risk, improved sample efficiency in structured-noise settings, and more faithful latent-state tracking than linear Transformers, offering a principled basis for architecture design in sequential inference tasks.
Abstract
We propose Bayesian optimal sequential prediction as a new principle for understanding in-context learning (ICL). Unlike interpretations framing Transformers as performing implicit gradient descent, we formalize ICL as meta-learning over latent sequence tasks. For tasks governed by Linear Gaussian State Space Models (LG-SSMs), we prove a meta-trained selective SSM asymptotically implements the Bayes-optimal predictor, converging to the posterior predictive mean. We further establish a statistical separation from gradient descent, constructing tasks with temporally correlated noise where the optimal Bayesian predictor strictly outperforms any empirical risk minimization (ERM) estimator. Since Transformers can be seen as performing implicit ERM, this demonstrates selective SSMs achieve lower asymptotic risk due to superior statistical efficiency. Experiments on synthetic LG-SSM tasks and a character-level Markov benchmark confirm selective SSMs converge faster to Bayes-optimal risk, show superior sample efficiency with longer contexts in structured-noise settings, and track latent states more robustly than linear Transformers. This reframes ICL from "implicit optimization" to "optimal inference," explaining the efficiency of selective SSMs and offering a principled basis for architecture design.
