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

Francesco Cagnetta, Casper L. Christensen
10/15/2026
cs.LGcs.AIstat.ML

No confident code implementation found for this paper.

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.

Show full abstract

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 \textit{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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{cagnetta2026incontext,
  title  = {In-Context Learning Before Specialisation: Theory of Learning in a Solvable Topic Model},
  author = {Francesco Cagnetta and Casper L. Christensen},
  year   = {2026},
  eprint = {2610.21901},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2610.21901v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2610.21901.svg)](https://codeofpaper.com/paper/2610.21901)

Discussion