Understanding In-Context Learning on Structured Manifolds: Bridging Attention to Kernel Methods
Zhaiming Shen, Alexander Hsu, Rongjie Lai, Wenjing Liao
TL;DR
The paper tackles the theoretical understanding of in-context learning (ICL) for regression on manifolds by linking Transformer attention to kernel methods. It proves that attention can implement kernel regression exactly and uses this to derive a generalization bound for Transformer-based ICL that scales with the prompt length and the number of training tasks, while depending exponentially on the intrinsic dimension of the data manifold. The results show that, with enough tasks, Transformers achieve near-minimax rates for Hölder functions on manifolds and that the geometry of the data governs generalization more than ambient dimensionality. This work provides a principled geometry-aware framework for analyzing nonlinear ICL models and suggests new tools for studying ICL in structured domains. The theoretical contributions are complemented by numerical experiments demonstrating the kernel-like behavior of attention and validating the proposed bounds.
Abstract
While in-context learning (ICL) has achieved remarkable success in natural language and vision domains, its theoretical understanding-particularly in the context of structured geometric data-remains unexplored. This paper initiates a theoretical study of ICL for regression of Hölder functions on manifolds. We establish a novel connection between the attention mechanism and classical kernel methods, demonstrating that transformers effectively perform kernel-based prediction at a new query through its interaction with the prompt. This connection is validated by numerical experiments, revealing that the learned query-prompt scores for Hölder functions are highly correlated with the Gaussian kernel. Building on this insight, we derive generalization error bounds in terms of the prompt length and the number of training tasks. When a sufficient number of training tasks are observed, transformers give rise to the minimax regression rate of Hölder functions on manifolds, which scales exponentially with the intrinsic dimension of the manifold, rather than the ambient space dimension. Our result also characterizes how the generalization error scales with the number of training tasks, shedding light on the complexity of transformers as in-context kernel algorithm learners. Our findings provide foundational insights into the role of geometry in ICL and novels tools to study ICL of nonlinear models.
