A reader can follow the argument of A Mathematical Framework for Transformer Circuits without being able to build what it describes. The Transformer Circuit Exercises close that gap for attention heads: the reader writes down, entry by entry, the weight matrices of small attention heads that carry out a stated algorithm. The page calls itself "a companion problem set" for the framework paper and says the exercises helped the authors "make sure we really understand the full mechanistic story of transformers all the way down to individual parameters, and not blurring over any confusions" (introduction). The paper's "Additional Resources" section links it as "a companion problem set of problems we found helpful in building our intuition for attention heads". This note describes what the exercises ask, how the solutions are presented, how the page changed after release, and where the collection uses it.
Date and authorship
The page has no byline, no date and no author list (its front matter lists no authors). The Transformer Circuits Thread's index places it under "December 2021", tagged "note, exercises", with the description "Some exercises we've developed to improve our understanding of how neural networks implement algorithms at the parameter level"; the index's page source gives the date 2021-12-17, which this note uses. The earliest Internet Archive capture is from 22 December 2021, the date the framework paper was published. The authors are not named; the framework paper's acknowledgments thank Tuomas Oikarinen for catching "several typos in the accompanying exercises".
Terms used in this note
- Residual stream. The vector at each token position that every layer reads from and adds its output to.
- Query, key, value and output matrices ($W_Q$, $W_K$, $W_V$, $W_O$, written $W_{out}$ in places on the page). The four matrices that define one attention head. Queries and keys decide which earlier positions the head attends to; values and the output matrix decide what it copies from them and where in the residual stream it writes.
- Virtual attention head. The combined effect of two heads in sequence, which the framework paper shows can act like a further head (here, one looking two tokens back).
- Induction head. A head that finds an earlier occurrence of the current token and attends to the token that followed it, so the model can continue a sequence it has seen earlier in the context.
- K-composition. A later head using an earlier head's output to form its keys.
What the exercises ask
The page has a warm-up and three exercises, with solutions below them.
- Warm-up. Describe the transformer and a single attention head in terms of its four matrices; say which matrix controls the subspace a head reads and which the subspace it writes, and what their product means; say which two matrices decide where a head attends; rewrite a head using only the two products $W_Q^T W_K$ and $W_{out} W_V$, and give their rank; and say what $W_V^2 W_{out}^1$ and its singular values reveal about whether one head reads another's output. The solution for the warm-up is a pointer to the framework paper.
- Exercise 1: a virtual attention head. With 16-dimensional residual stream and 4-dimensional heads, the reader builds two previous-token heads in successive layers so that the second copies three dimensions of the previous token and one dimension from two tokens back. The point of the exercise, stated on the page, is that "the two heads dedicated 7/8ths of their capacity to one task and 1/8th to another", so a model can look two tokens back without spending a whole head on it.
- Exercise 2: an induction head by pointer arithmetic. Using a sinusoidal position embedding, the reader builds heads that attend to tokens with similar content, to the present position, to the previous position (by rotating each sine and cosine pair, as with a 2D rotation matrix), and to similar tokens other than itself; then a head that copies the attended token's position; and finally a head that attends to the token after an earlier copy of the present token.
- Exercise 3: an induction head by K-composition. The page notes that some position encodings, such as rotary attention, do not pass positional information through $W_V$, so the method of Exercise 2 is unavailable; the reader instead builds a first head that copies the previous token's content into a subspace and a second head that uses that subspace in its keys. The page says the authors have "seen" this alternative mechanism in such transformers.
The page says "there are at least two algorithms for implementing induction heads". Exercises 2 and 3 build the two that the framework paper describes. In its section "How Induction Heads Work" the paper calls K-composition with a previous-token head "the minimal way to create an induction head", the mechanism its own models use; in "Pointer Arithmetic with Positional Embeddings" it notes that models with positional embeddings in the residual stream can do "pointer arithmetic" on them, and reports observing "at least one case in GPT-2" of an induction head built that way. The framework paper's own models use a position mechanism that, like rotary attention, does not put positional information into the residual stream.
How the solutions are presented
Solutions to Exercises 2 and 3 are written as matrices of embedding basis vectors, with short explanations; the page notes that composing an arbitrary rotation into both matrices of a pair gives a functionally equivalent head, and that it shows "the most straightforward version". The solution to Exercise 1(b) says "there are many correct answers here". In the version read for this note (fetched 13 November 2026), the solutions to Exercise 1 are four annotated images of the matrices (the value and output matrices, and the 16 by 16 combined matrices), marking which dimensions each head reads and writes.
Revisions since release
The page is undated and has no changelog, but it was revised after release. Its acknowledgments, absent from the capture of 22 December 2021, thank Tuomas Oikarinen and Callum Canavan "for catching several typos in the original version of these exercises". Comparing that capture with the current page shows, among other changes (the comparison is this note's):
- In Exercise 2(a) the original solution read "$W_Q = W_v$"; the current one reads $W_Q = W_K$. In 2(e) a subscript $u_4^{sin}$ became $u_3^{sin}$.
- In 2(f) the rotation applied to the copied position was reversed, with the added explanation that it rotates "forwards instead of backwards" relative to 2(c).
- In Exercise 3 the first head's value matrix was changed from position vectors to content vectors, which matches the text's statement that the head copies the previous token's content.
- The Exercise 1 solutions, originally typed matrices, were replaced by the annotated images. In the original typed solution, the second head's combined matrix placed its three copied dimensions one column away from the dimensions its value matrix reads; the current image places them in the same columns. (This reading of the original matrices is the note's.)
A reader working from an older copy or a mirror should check against the current page. The page is still listed on the index and served; beyond these corrections, no exercises have been added since 2021, and the page does not say whether it will be extended.
Research questions
- How often do trained models use pointer arithmetic? The framework paper reports one observed case in GPT-2. Examining the induction heads of several trained models whose position embeddings sit in the residual stream, and testing each against the two constructions, would show how common each mechanism is.
- Do trained models use small virtual heads like Exercise 1's? The exercise shows that two heads can share a fraction of their capacity to look two tokens back. Measuring the composition terms between previous-token heads in a small trained model would show whether such partial virtual heads occur.
- How well do the exercises teach what they claim to? The page reports the authors' own experience. Comparing readers who did the exercises with readers who did not, on questions about the framework paper, would measure whether hand-building heads improves understanding.
- What other errors remain? The page was corrected after readers reported typos. Checking each solution's matrices numerically (constructing the heads and running them on test sequences) would confirm that every solution does what its exercise asks.
How it connects
- The paper it accompanies. A Mathematical Framework for Transformer Circuits (December 2021) links the exercises in its "Additional Resources" section and its acknowledgments, and the collection's note on it lists the exercises among its references. The warm-up questions are answered in that paper.
- Induction heads. Exercises 2 and 3 build the mechanism studied in In-context Learning and Induction Heads (March 2022). This connection is the note's; the exercises page does not link that later paper.
- Other December 2021 resources. The same index section lists Transformer Circuit Videos, PySvelte and Garcon. For the earlier vision-model work the site says it builds on, see the original Distill Circuits thread.
- The GPT walkthrough in this library. For the transformer pieces in code, see Building Self-Attention Step by Step and Assembling the Transformer Block.
References
- Anthropic. (2021). Transformer Circuit Exercises. Transformer Circuits Thread. https://transformer-circuits.pub/2021/exercises/index.html. No byline or date on the page; date from the site index. Current version fetched 13 November 2026; original version from the Internet Archive capture of 22 December 2021 (https://web.archive.org/web/20211222165530/https://transformer-circuits.pub/2021/exercises/index.html). record
- Elhage, N., Nanda, N., Olsson, C., et al. (2021). A Mathematical Framework for Transformer Circuits. Transformer Circuits Thread, 22 December 2021. https://transformer-circuits.pub/2021/framework/index.html. Sections "Additional Resources" and "Acknowledgments". record · 8 pages
- Transformer Circuits Thread, index page, entry "Exercises". https://transformer-circuits.pub/ (read 13 November 2026). record