What a Reader Head Learns From Twelve Labeled Examples
A fit predicted attention to matching labels in twelve-example prompts. At eighteen examples it overestimated that attention for 92–94% of the heads tested.
Correction, November 25, 2026. Equation 1 fits three constants for each attention head, of which two quantities can be identified separately. It predicts how much of that head’s attention falls on matching label positions. Our earlier account incorrectly extended the result to the model’s output probabilities. Section 4, Equation 1
Imagine a prompt that labels requests about deliveries with oak and requests about refunds with ash. When a new delivery question arrives, the model can use the earlier examples to infer what oak means in this prompt. Andrew Gao and William Gao study a version of that problem in A Circuit for In-Context Learning. They trace sentence classification in three base models, Qwen3-4B, SmolLM3-3B and Llama-3.2-3B. Paper and experimental setup
A label position carries two pieces of information. The label itself provides a value. Middle-layer heads write information about the preceding sentence’s class at that position, supplying a key. Later heads can match the new sentence to those keys. The authors also identify an early signal for repeated labels and a separate group of heads that counteracts the pull of the most recent label. Their repository includes the paired prompts and scripts used to trace those steps. Authors’ code and walkthrough
Reading Equation 1
Choose one head at the query and add up its attention weights on all the example labels whose class matches the query. That sum is the quantity m in the equation. For example, weights of 0.11, 0.08 and 0.06 on three matching positions give a matching mass of 0.25. This illustrative sum says nothing by itself about the probability assigned to oak at the output.
The fit groups positions into matching labels, other labels, the first token (the attention sink), and the rest of the prompt. The fitted quantities are the matching logit L, the sink logit Lsink and the remaining unnormalized mass nrest. The last two appear only as the sum exp(L_sink) + n_rest. Matching-mass measurements can distinguish the matching logit and that combined contribution. They cannot recover the two contributions to the sum individually. Equation 1 and identifiability
What happened when the prompt grew
| Authors’ test | Qwen result | Llama result |
|---|---|---|
| Fit on 12 demonstrations spread across 2, 3, 4 or 6 classes | 127 of 140 eligible heads fit within 0.10 attention mass | 124 of 125 fit within 0.10 |
| Keep those constants and predict 18 demonstrations, with 3–9 matching slots | Median error 0.15 | Median error 0.13 |
The twelve-example comparison includes heads that assigned at least 0.03 of their attention to label slots. For the eighteen-example test the authors set a median-error target below 0.07. Both models missed it, and the fit overestimated matching mass for 92–94% of heads. Figure 9 shows the direction of the error. Extra matching examples can share a head’s existing attention budget. Figure 9 and results
If you are deciding how many labeled examples to send to a classifier, measure its answers on the same held-out queries at each candidate prompt length. Count the predicted labels that match your answer key. That gives you a task accuracy you can use to compare prompt lengths. Figure 9 answers a narrower question about attention inside the models, and the twelve-example fit did not extrapolate reliably to eighteen.