Multi-layer Cross-attention is Provably Optimal for Multi-modal In-context Learning
Organizations: Department of Statistics, Harvard University
Abstract
Recent progress has rapidly advanced our understanding of the mechanisms underlying in-context learning in modern attention-based neural networks. However, existing results focus exclusively on unimodal data; in contrast, the theoretical underpinnings of in-context learning for multi-modal data remain poorly understood. We introduce a mathematically tractable framework for studying multi-modal learning and explore when transformer-like architectures can recover Bayes-optimal performance in-context. To model multi-modal problems, we assume the observed data arises from a latent factor model. Our first result comprises a negative take on expressibility: we prove that single-layer self-attention models fail to recover the Bayes-optimal predictor uniformly over the task distribution. To address this limitation, we introduce a novel, linearized cross-attention mechanism, which we study in the regime where both the number of cross-attention layers and the context length are large. We show that this cross-attention mechanism is provably Bayes optimal when optimized using gradient flow. Our results underscore the benefits of depth for in-context learning and establish the provable utility of cross-attention for multi-modal distributions.
Figures & tables
| Model | Params | Best test acc. (%) | Best epoch |
|---|---|---|---|
| Full paper-inspired model (Inj. & cross-attn) | 63.85 | 64 | |
| No injection | 62.72 | 65 | |
| No cross-attn | 62.10 | 79 | |
| No inj. & no cross-attn | 60.79 | 90 | |
| Standard bi-CA transformer | 62.72 | 62 |
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
| Symbol | Meaning |
|---|---|
| total covariate dimension | |
| context length (we use or when needed) | |
| stacked covariate for context token | |
| query covariate | |
| context response for token | |
| query response |
In-Context Learning
In-context learning studies how models adapt to new tasks from examples or instructions supplied at inference time, without changing their weights.
See all 426 papers