If “abcd” goes to “abce”, what should “ijkl” go to?
A natural answer is “ijkm”: replace the final letter with its successor in the alphabet. When coming up with that answer, you need to infer a relationship from one example and apply it to another string.
These puzzles, called letter-string analogies, offer a way to investigate a more general question: how do transformers learn to reason by analogy, and when does that learning transfer to unfamiliar situations?
In our paper, Transformer See, Transformer Do: Copying as an Intermediate Step in Learning Analogical Reasoning, accepted to COLM 2026, we investigate this question using small-scale transformers. Our findings show how training choices can support analogical reasoning, while also revealing limits to generalization.
We trained Transformers on letter-string analogies using Meta-Learning for Compositionality, an approach designed to help models learn how to solve tasks from examples.
Our experiments use letter-string analogies with different alphabet orders. Imagine being given an alphabet in which the letters appear in an unfamiliar sequence. “The next letter” now depends on this new sequence, rather than the familiar A-to-Z order. To solve the puzzle, you now need to use the local context.
We tested whether models could transfer what they learned to 1) unseen alphabet orders, 2) new combinations of familiar transformations, and 3) entirely new transformations.
One of our main findings is that including copy tasks in training substantially improves learning. In these tasks, the query repeats the example input, so the model can copy the corresponding example output.
Our interpretability analysis links this improvement to the development of matching attention heads. These heads connect matching letters across different parts of the problem, helping the model use the relationship between the example input and output.
We also found that greater diversity in training alphabet orders improves generalization to unseen orders. Together, copying tasks and varied alphabets allow our best small transformer to perform on par with frontier models on our analogy datasets.
We wanted to understand how the model arrived at its answers. For one transformation, we identified a candidate algorithm that approximates its computations and investigated it through mechanistic interpretability.
We used causal interventions to identify a key attention head. Changing its attention pattern at this head can steer the model between different transformations.
The models could solve some new combinations of transformations encountered during training, but struggled with entirely new transformations.
Our results suggest that copying can provide an intermediate step towards learning analogical reasoning in this setting. Understanding those intermediate steps may help us design training methods that support more systematic generalization.
The paper is joint work with Philipp Hellwig, Willem Zuidema and Claire Stevenson.