TL;DR
- In-context learning gets better with more demonstrations even though no gradient ever touches the weights. That should be more puzzling than it usually is.
- Xie et al. pretrain on a mixture of HMMs, one per latent document concept, and prove that next-token prediction then amounts to implicit Bayesian inference over the concept.
- A few-shot prompt reads like a partial document. Each demonstration sharpens the posterior over concepts, and from the outside that looks like learning.
The puzzle: learning with frozen weights
In-context learning should bother us more than it does. Between reading the demonstrations and producing an answer, nothing in the model is updated. By the usual definition, nothing is being learned.
Yet accuracy keeps climbing as you add examples, which is exactly what learning looks like. Xie et al. set out to find a pretraining story in which this stops being a mystery and becomes something you would expect.
0
gradient updates between seeing the demonstrations and answering
1
forward pass: all of the "learning" happens inside it
More shots
still means better accuracy, just as if the model were being trained
A pretraining world built for a proof
To prove anything, they need a pretraining distribution simple enough to analyze. They pick a mixture of Hidden Markov Models, with one HMM for each latent “document concept.”
- Sample a concept. It stays fixed for the whole document.
- Sample a long token sequence from that concept’s HMM.
- Train a transformer to predict the next token on many such documents.
Keeping the concept fixed is a crude stand-in for something real: actual documents tend to hold one topic or style from beginning to end. It is enough structure to prove a result.
The result: with enough pretraining data, a next-token predictor trained on this distribution ends up doing Bayesian inference over which concept generated the document it is reading, using only the tokens it has seen so far. Nobody built that behavior in. It falls out of next-token prediction once the data has this concept structure.
Why a prompt looks like a document
An ICL prompt is just demonstrations stuck together. To a model pretrained this way, that looks like the start of a document whose concept it has to infer.
Every step happens in one forward pass, over a belief about the concept. The weights never change.
Each demonstration is evidence about which concept is active. More demonstrations narrow the posterior, and predicting under a narrower posterior is what we see from outside as “the model learned the task.”
The model isn’t updating its weights. It is updating a belief about which concept it is in.
What the evidence shows
The theory comes with a synthetic testbed built to match it: GINC, generated from an HMM mixture that satisfies the paper’s own assumptions. Real pretrained models give a second, looser check.
Synthetic
GINC
- Built directly from the paper’s HMM-mixture assumptions
- Accuracy rises with more demonstrations
- Holds up reasonably well when the examples are reordered
- Both results are what the Bayesian account predicts
Real models
GPT-2 and GPT-3
- Show similar trends with demonstration count on natural tasks
- The authors call this suggestive, not proof
- Nothing shows that real LMs satisfy the formal setup
The careful framing matters. The proof holds in a world the authors built. Whether real pretraining corpora look enough like an HMM mixture is still an open question.
What “uncertain” means now
This is the part I keep coming back to. If the model is inferring a concept, then its uncertainty is simply a posterior that hasn’t concentrated yet, and that raises a sharper question than “how confident is the model?”
Why is the posterior still spread out? Maybe the demonstrations really are ambiguous about which concept applies, which is a fact about the prompt. Or maybe the evidence is clear and the model reads it badly, which is a fact about the model.
The paper never measures this split. What it gives me is the vocabulary to ask for it, and pulling those two sources apart is where my own work on uncertainty in in-context learning starts.
Key takeaways
- In-context learning improves with more demonstrations with no weight updates. Xie et al. explain why.
- Pretraining on a mixture of concept-specific HMMs turns next-token prediction into implicit Bayesian inference over the latent concept.
- A prompt acts as a partial document: each demonstration sharpens the posterior over concepts inside a single forward pass.
- GINC matches the theory (more shots help, and reordering is tolerated). GPT-2 and GPT-3 trends are suggestive, not proof.
- Seen this way, uncertainty is an unconcentrated posterior. The open question is whether the prompt or the model is to blame.