Skip to content
DraconiticResearch
Search Sources API
197,768 studies31 sourcesUpdated 54 min ago
PreprintarXiv licencearXiv

Transformers as Cross-Task Learners: Shared Structure Drives Sample Efficiency in In-Context Learning

Abstract

Transformers achieve remarkable performance by jointly learning broad families of tasks during pretraining and adapting to unseen tasks from only a short prompt. Yet a rigorous mathematical and statistical understanding of this phenomenon remains limited. This paper aims to study how Transformers exploit shared cross-task structure and how this structure affects the sample complexity of in-context learning (ICL). Specifically, we characterize task-space complexity through covering numbers under a prescribed metric, thereby quantifying the low-dimensional cross-task structure without requiring an explicit parametric representation. The resulting cover provides a set of anchor functions, which we use to introduce a task-identification-and-evaluation procedure: context observations localize an unseen task among the anchor functions, and the response at a query is predicted by aggregating the corresponding anchor function query evaluations. For approximation, we explicitly construct a Transformer with Softmax attention to approximate this procedure. For generalization, we derive an error bound that separates the effects of the number of pretraining tasks and the prompt length. The scaling with respect to the number of pretraining tasks is governed by the intrinsic dimensions of the task space and input domain; once sufficiently many tasks are available, the dependence on the prompt context length becomes dimension-free. To the best of our knowledge, this is the first work to quantify cross-task complexity for general nonlinear task families and explicitly construct a Transformer that exploits their low-dimensional structure to perform ICL. Our theory provides a quantitative explanation of how joint pretraining across related tasks improves in-context generalization.

Related

  1. Transformers as Adaptive Kernel Learners across Tasks for In-Context Learning
    Zhaiming Shen, Alexander Cloninger, Rongjie Lai +1
    arXivPreprintarXiv licenceFull textNumerical analysis & scientific computingStatisticsarXiv
  2. Adversarially Trained Linear Transformers Are Optimal Robust In-Context Learners for Gaussian Mixtures
    Soichiro Kumano
    arXivPreprintarXiv licenceFull textStatisticsarXiv
  3. In-context Learning of Single-index Targets: Comparing Kernel and Feature Learners
    Haotian Gu, Yizhou Xu, Lenka Zdeborová
    arXivPreprintarXiv licenceFull textStatisticsCondensed matterarXiv
  4. Nonparametric In-Context Learning under Growing Geometric Complexity: Minimax Optimality and Local Geometry-Adaptivity of Transformers
    Jaehee Seo, Jisu Kim
    arXivPreprintCC BY 4.0Full textStatisticsarXiv
  5. Predictive-Context LOO: Bayesian Model Comparison with Pretrained Predictive Learners
    Hans Montcho, Maurizio Filippone
    arXivPreprintCC BY 4.0Full textStatisticsarXiv
BibTeX
@misc{shi2026transformers,
  title = {{Transformers as Cross-Task Learners: Shared Structure Drives Sample Efficiency in In-Context Learning}},
  author = {Zhongjie Shi and Rongjie Lai and Alexander Cloninger and Wenjing Liao},
  howpublished = {arXiv},
  year = {2026},
  month = sep,
  doi = {10.48550/arxiv.2609.29060},
  eprint = {2609.29060},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.29060},
}
RIS
TY  - UNPB
TI  - Transformers as Cross-Task Learners: Shared Structure Drives Sample Efficiency in In-Context Learning
AU  - Zhongjie Shi
AU  - Rongjie Lai
AU  - Alexander Cloninger
AU  - Wenjing Liao
PY  - 2026
DA  - 2026/09/24
PB  - arXiv
DO  - 10.48550/arxiv.2609.29060
UR  - https://arxiv.org/abs/2609.29060
AB  - Transformers achieve remarkable performance by jointly learning broad families of tasks during pretraining and adapting to unseen tasks from only a short prompt. Yet a rigorous mathematical and statistical understanding of this phenomenon remains limited. This paper aims to study how Transformers exploit shared cross-task structure and how this structure affects the sample complexity of in-context learning (ICL). Specifically, we characterize task-space complexity through covering numbers under a prescribed metric, thereby quantifying the low-dimensional cross-task structure without requiring an explicit parametric representation. The resulting cover provides a set of anchor functions, which we use to introduce a task-identification-and-evaluation procedure: context observations localize an unseen task among the anchor functions, and the response at a query is predicted by aggregating the corresponding anchor function query evaluations. For approximation, we explicitly construct a Transformer with Softmax attention to approximate this procedure. For generalization, we derive an error bound that separates the effects of the number of pretraining tasks and the prompt length. The scaling with respect to the number of pretraining tasks is governed by the intrinsic dimensions of the task space and input domain; once sufficiently many tasks are available, the dependence on the prompt context length becomes dimension-free. To the best of our knowledge, this is the first work to quantify cross-task complexity for general nonlinear task families and explicitly construct a Transformer that exploits their low-dimensional structure to perform ICL. Our theory provides a quantitative explanation of how joint pretraining across related tasks improves in-context generalization.
ER  -