Manuscript Offprint

arXiv:2610.19113

From Copying to Composition: How Language Models Develop In-Context Learning

Minglai Yang, Xinyu Guo, Renxiong Wang, Sunjie Hou, Daniel Yue Zhang, Yunzhong He

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

In-context learning (ICL) allows language models to adapt their behavior from instructions and demonstrations in a prompt, but accuracy alone does not reveal how contextual information controls their predictions. We study the acquisition and trainability of ICL with a controlled diagnostic that separates copying a nearby demonstration from integrating information across the prompt. Across 17 models, about a third prefer the copied answer, a few are undecided, and the rest prefer the rule-consistent answer, which goes with higher accuracy and with control by the requested value rather than the closest conflicting example. Checkpoint analyses show that models begin prioritizing task-relevant prompt tokens over conflicting examples long before their accuracy improves beyond chance level. In matched training experiments, synthetic documents that define endings and then query them shift models toward compositional responses on the controlled diagnostic, whereas fine-tuning on definition exercises built from rewritten real documents improves accuracy when prompts reassign label meanings. The results suggest that ICL is not acquired as a single, uniform capability. Instead, prompt control, answer preference, construction without candidates, and transfer can develop along distinct trajectories.

1 Introduction

Language models are increasingly expected to adapt at inference time, from instructions, demonstrations, and temporary conventions in the prompt rather than from parameter updates. This ability is commonly described as in-context learning (ICL). We know much less about how this capacity is acquired during training than about how well trained models display it. Understanding ICL acquisition requires tracking how models shift their reliance on contextual information throughout training. Knowing when accuracy improves is not enough.

The same answer can result from different uses of the context: a model may reuse the output pattern of a demonstration similar to the query, or integrate mappings distributed across the prompt and apply them to a new combination. In ordinary ICL evaluations these behaviors predict the same output, so correctness shows that the context was useful but not how it was used. Studying the acquisition of ICL therefore needs a diagnostic in which different ways of using the prompt make different predictions.

These observations motivate a developmental question that final-answer accuracy alone cannot resolve: how does a model’s use of different sources of contextual information change during training? We track four aspects of ICL that, as we show, develop on different schedules: which prompt source controls the answer, which answer the model prefers, whether it can construct that answer without candidates, and whether a trained change transfers to other evaluations.

To make these aspects distinguishable, we construct a controlled task inspired by work on compositional generalization and made-up-word tests (Hupkes et al., 2020; Berko, 1958). Each prompt defines endings for two binary attributes, demonstrates three of the four possible combinations on made-up words, and asks for the missing combination on a new word (Figure 1). Combining the two prompt-defined mappings yields the rule-consistent (correct) answer, whereas reusing the conflicting ending from the demonstrated combination that shares the first requested attribute yields a distinct copied answer. Because the assignments change in every prompt, the task cannot be solved using a fixed word-ending mapping. We measure the copied answer's probability normalized over these two candidates, denoting it by P(copy)P(\text{copy}). Interventions on the conflicting ending in the closest ex-

∗^{*}Corresponding author.

(a) Copy or apply definitions?

(b) Change during training

small dap = dap-il big trum = trum-or one fen = fen-um many pab = pab-nak small one gib = gib-il-um small many vok = vok-il-nak big one zud = zud-or-um big many wug = ?

copy closest → wug-or-um apply definitions → wug-or-nak

Figure

(c) Train on definitions

real documents→ define + use label

Figure 1: Study overview. (a) The task makes copying and applying prompt definitions predict different answers. (b) Across pretraining checkpoints (OLMo-2-7B shown), the requested value overtakes the closest ending as the source of the answer (star) long before accuracy crosses chance (dashed line). (c) Fine-tuning SmoILM2-1.7B on definition exercises rewritten from real documents raises accuracy on three unseen datasets with made-up or exchanged labels (pale bars: a matched fine-tune on the original documents, solid extensions: the gain from the exercises).

ample or on the requested value in the question measure which source controls the candidate-score difference, and activation patching (Heimersheim and Nanda, 2024) and the disabling of selected attention heads (Wang et al., 2023) trace that control to internal states and heads.

Across 17 models, the diagnostic sorts answer preferences from copying the nearest demonstration to producing the correct form, and the composing models score higher and generate the form without candidates. Across pretraining checkpoints, sensitivity to the requested value overtakes sensitivity to the conflicting example hundreds of billions of tokens before accuracy rises above chance. Most other checkpoint series that reach composition show the same ordering, OLMo-3 and Comma on every criterion (Section 5).

Matched continued-training experiments then show which training signals change these behaviors and where the improvements transfer. Training on synthetic documents that define endings and then query them reverses the preferred answer on the controlled task and lets models generate the missing form. Fine-tuning on definition exercises built from rewritten real documents improves performance on evaluations that assign new meanings to labels. Each signal transfers the use of the prompt it rewards, so the exercises leave the controlled task unchanged.

Our work makes three contributions. First, we introduce a controlled diagnostic in which two ways of using the context predict different answers. Second, we measure answer preference and prompt dependence across 17 models and multiple checkpoint series showing that prompt control shifts long before accuracy crosses chance. Third, matched continued-training experiments show that the compositional answer must be built rather than unblocked: suppressing copy-favoring heads shifts the balance between candidates, training on synthetic documents that define endings and then query them creates the missing answer, and each signal transfers the use of the prompt it rehearses (Section 6).

References (26)