cs.LGOct 15, 2026

In-Context Learning Before Specialisation: Theory of Learning in a Solvable Topic Model

Authors: Francesco Cagnetta, Casper L. Christensen

Organizations: Simplex · Simplex, Astera Institute

Abstract

Sequence models can generalise in fundamentally distinct ways: extrapolating structures seen in training, or using their prompt to adapt to novel tasks. The prevailing strategy determines how the model behaves beyond its training distribution, controlling potential capabilities and risks. Recent work has characterised many different strategies theoretically, and empirically described the transition between them as the quality and quantity of pretraining data vary. However, there is no learning theory for this competition, hence no fundamental understanding of why one solution might be favoured over another. Here we provide such a theory in a solvable topic model---documents drawn from a finite mixture of latent topics, mirroring the heterogeneity of modern pretraining data. The dataset comes with two distinct solutions: a specialised predictor, that stores the finite topic mixture, and an in-context one, optimal for topics never seen during training. Our theory predicts their emergence at distinct sample complexities: the in-context predictor is available early, while the specialised one emerges only after the training tokens outnumber the parameters of the data-generating process. Trained transformers reproduce both scales and the separating crossover in remarkable agreement with the theory, with no fitted parameters.

Figures & tables

Appendix figures & tables6 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

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

    Sep 24, 2026Zhongjie Shi, Rongjie Lai, Alexander Cloninger +1TransformerMulti-Task Learning

  2. Test time training enhances in-context learning of nonlinear functions

    Sep 30, 2025Kento Kuwataka, Taiji SuzukiSingle-Index ModelsTest-Time Training

  3. When Context Sticks: Studying Interference in In-Context Learning

    Apr 25, 2026Hanna Rød, Dagny Streit, Nils Valseth Selte +1In-Context Learning