The Transformer Block and the Residual Stream
Attention alone averages tokens into one another; the residual connection keeps each token itself, and turns the block into a shared channel that heads read with linear maps and write into by addition, which makes the logits an exact sum of paths, keeps an identity path open for the gradient, and lets two heads compose into an induction head
Overview & Motivation
The attention topic read attention as a kernel smoother: each token’s output is a weighted average of the values of the tokens it attends to. Averaging has a consequence when we do it twice. Average a set of points, average the averages, and keep going, and every point drifts toward one consensus. Take ten tokens in the plane and send them through twelve layers of attention with nothing else in the block. At a moderate temperature their cloud, whose widest pair starts apart, shrinks until every token sits at the same point to within . Add one term to each layer, the token itself, and the same twelve layers leave every token distinct, with the cloud times wider than it began.
That added term is the residual connection, and this topic is about what it builds. With it, a transformer block stops being a map that replaces its input and becomes a write into a shared vector, the residual stream, which every later layer can read. We develop the consequences in order:
- Attention alone collapses. A row-stochastic matrix shrinks the cloud of tokens by at least a computable factor, so wide-kernel attention stacks lose every distinction between tokens. With the skip, and value maps of norm at most , each layer keeps at least one minus that factor of the cloud’s diameter.
- LayerNorm is a sphere in a hyperplane. It projects onto the hyperplane orthogonal to the all-ones vector, then radially onto a sphere, and its Jacobian forgets the radial direction.
- The identity path. The Jacobian of a residual stack multiplies out into a sum over every subset of layers, and the empty subset is the identity. Every layer receives the top gradient unchanged, and where LayerNorm sits decides what happens to the rest.
- The stream as a channel. An attention-only model’s logits are exactly a sum over chains of heads, and two heads talk only through the subspaces where one writes and the other reads.
- Induction heads. We train a two-layer model from scratch and watch two heads compose through the stream, a previous-token head and a head whose keys read it, into a circuit that completes
[A][B] … [A]with[B]. One layer cannot do this, and we show why.
Then the finance case. On filings about companies that never occur in training, a model trained on the filings completes none of their multi-word names, and the induction model, which never saw a filing, completes of them.
The block, assembled
We write a sequence of tokens as a matrix , one row per position, and let matrices act on the right, . Write for the all-ones vector.
Definition 1 (The transformer block).
A head has maps and and sends to
with the softmax taken row by row and either or the causal mask ( above the diagonal). Rotary positions (Definition 4 of the positional-encodings topic) may rotate the queries and keys. Multi-head attention is , and an MLP is on each row, with here. The pre-LN block is
and the post-LN block is , then , with the LayerNorm of Definition 3. The residual stream is the sequence of matrices that the blocks pass along: each sublayer reads it and writes back by addition.
The post-LN block is Vaswani and colleagues’ (2017) original; the pre-LN block is what most large models use now, for a reason Theorem 2 makes precise. The skip itself is He and colleagues’ (2016).
Proposition 1 (Heads are smoothers that write; the MLP is a memory).
(i) Without rotary positions or query and key biases, , where is the attention topic’s scaled dot-product attention. Each head is a Nadaraya–Watson smoother, and the block adds smoothed copies of the stream, each mapped into it by its own .
(ii) , where the key is the -th column of and the value is the -th row of .
Proof.
For (i), the head’s formula is the attention topic’s Definition 2 applied to , , and , followed by ; summing over heads is block matrix multiplication of the concatenated head outputs by the stacked output maps , and that attention is a Nadaraya–Watson smoother is that topic’s Proposition 1. For (ii), the entries of are , and multiplying the vector by sums its entries times the rows .
∎Read (ii) beside attention. Attention takes a weighted sum of values whose keys come from the context, with weights normalized by a softmax. The MLP takes a sum of values whose keys are parameters, gated by an unnormalized . Geva and colleagues (2021) read trained MLPs this way, as memories keyed on patterns in the input. The notebook checks (i) head by head against the attention topic’s attention function and (ii) row by row, both to .
Attention alone collapses
Every row of an attention matrix is a probability vector, so the matrix is row-stochastic, a Markov transition matrix on positions. formalML’s random-walks topic proves that a mixing chain forgets where it started (its Theorem 3), by a spectral argument about one fixed chain. A stack applies a different matrix at every layer, so we need a bound that survives a product of different matrices, and Dobrushin’s contraction is that tool. Write for the diameter of the cloud of rows of , in any norm on , and for the operator norm of in the same norm.
Definition 2 (The Dobrushin coefficient; the smoothing stack).
For a row-stochastic , the Dobrushin coefficient is
The pure attention stack is , and the stack with the skip is .
The two forms of agree because for any numbers, and two probability vectors each sum to . So exactly when all rows are equal, and when two rows have disjoint supports. Dobrushin (1956) introduced it for nonstationary Markov chains; Seneta’s book (1981) calls it a coefficient of ergodicity.
Theorem 1 (Attention contracts toward consensus).
Let be row-stochastic.
(i) , in every norm.
(ii) If each row of a score matrix has range , then .
(iii) The pure attention stack satisfies .
Proof.
For (i), fix rows and and let . Then and , with . If the two rows are equal. Otherwise the positive and negative parts of , which sum to zero together, have equal mass , so for two probability vectors and . Then
whose norm is at most . Maximize over and .
For (ii), every entry of row satisfies . So for every pair of rows, and Definition 2 gives .
For (iii), , so . By (i), , and we induct on .
∎Part (ii) is the attention topic’s temperature talking. Scores at inverse temperature have range proportional to , so a wide kernel (small , high temperature) keeps well below and the collapse in (iii) is geometric. Dong, Cordonnier, and Loukas (2021) prove more: pure self-attention with value maps loses rank doubly exponentially in depth. We prove the geometric rate and cite theirs.
The laboratory’s cloud makes this concrete. Ten tokens in the plane pass through twelve layers of with , so queries, keys, and values are the tokens themselves. The first layer’s is , , , , and at , , , , and . For , the pure stack’s diameter falls below by layer twelve, under the bound of (iii) at every layer. At , stays above through layer twelve, so the bound falls slowly: it allows at layer twelve, and the diameter is . Attention here is not close to the identity. The scores are dot products, so long tokens win: six of the ten tokens put less than half their weight on themselves, and every row’s largest weight in the first layer falls on one of four long tokens, which act as leaders. By layer twelve the cloud has gathered into two tight clusters, of eight tokens and two, with a relative spread of . It looks frozen, and it is not. Run on, and the clusters merge: the diameter is at layer sixteen and at layer eighteen, still under the bound. Theorem 1 holds throughout; over twelve layers its rate is too slow to force the collapse. Geshkovski and colleagues (2023) observe two such timescales numerically in a related dynamics, a continuous-time flow of tokens on a sphere: clusters form fast and merge slowly, toward the single point they prove is the long-time limit.
Proposition 2 (The skip keeps the diameter).
For , , and every pair satisfies . Over a stack, if every , then
Proof.
For any pair, , and by Theorem 1 (i) applied to , with , the second term has norm at most . The reverse triangle inequality gives the pairwise claim, and a pair with gives the first claim. Iterating gives the product, and for by induction.
∎Pure attention multiplies the diameter by at most per layer. The skip adds each token back, so every old difference survives inside the new one, beside a correction of norm at most , and a stack of small updates, with , cannot erase the diameter. A smaller gap can go. Take , , and with rows , , and , so . Then : the first two tokens merge, and the diameter stays . The proposition protects the widest gap, and any gap wider than the correction, not every pair. In all five of the laboratory’s runs with the skip, the diameter never shrinks.
What the skip keeps is the diameter, though, not its share of the stream. If every row of is the same, is one common vector, and adds that vector to every token: the differences stay where they were while the common part grows. A wide kernel heads there, and not by staying wide. At the first is close to uniform, but the stream grows, the scores grow with it, and runs , , , , , , , over the first eight layers. It falls at the end because the rows agree, not because they are flat: within seven layers every row sits on one token, the same for all of them. From there the cloud only translates. Its diameter stops at times its start, and its relative spread halves each layer, to at layer twelve. Proposition 2 is a statement about the first quantity, not the second.
LayerNorm is a sphere in a hyperplane
Every sublayer of a pre-LN block reads the stream through LayerNorm, so its geometry is the geometry of every read.
Definition 3 (LayerNorm and RMSNorm).
For , , not a multiple of , with mean and variance , LayerNorm is , with its learned gain and bias , as at initialization. For , RMSNorm is .
LayerNorm is Ba, Kiros, and Hinton’s (2016), who add a small constant to that we take to be ; RMSNorm is Zhang and Sennrich’s (2019). Picture : the plane through the origin, and on it the circle of radius . LayerNorm drops each point onto the plane, then moves it along its ray to the circle, outward or inward.
Proposition 3 (LayerNorm is a sphere in a hyperplane).
Let , , and . Then : the orthogonal projection onto the hyperplane , followed by the radial projection onto the sphere of radius inside it. Consequently for and any , , and .
Proof.
, and , so . Next, , and normalizing removes . A point already on the sphere in has and , so . The last identity is Definition 3 applied to .
∎Brody, Alon, and Yahav (2023) give this reading and argue that each of its two parts matters to the attention that follows. The first part is a projection of the kind formalStatistics’ linear-regression topic builds least squares from (its Theorem 1): centering is the projection off the intercept direction.
Corollary 1 (LayerNorm's Jacobian).
Let , , and . Then
a symmetric matrix that sends both and itself to . Its singular values are , with multiplicity , and , twice.
Proof.
With , the differential of is , and . Since , , which gives the formula. and , so is sent to . and , so . Finally is the orthogonal projection onto the -dimensional complement of .
∎LayerNorm does not care how long its input is, and its gradient says so: it loses the radial component and is scaled by . That scale is where depth enters. For a standard Gaussian vector, , concentrates near , the thin shell of formalRAG’s high-dimensional-geometry topic (its Theorem 1), so at large LayerNorm’s radial step barely moves such a vector: the notebook’s median is below at and above at . Measured from itself, so that the centering counts too, the median at is . The radius belongs to unit variance: at the same radial change is about . LayerNorm acts when the stream’s norm drifts away from , and in a pre-LN stack it does.
The identity path
Theorem 2 (The identity path).
(i) For a residual stack , with the Jacobian of at the point the forward pass visits,
a sum of terms in which the empty subset contributes . So the gradient of a loss at is the gradient at , unchanged, plus a term for every nonempty set of sublayers.
(ii) In a pre-LN stack with , , so with . As the stream grows, that LayerNorm factor of shrinks, and the identity term has no such factor. This bounds one factor of each branch, not a whole gradient.
(iii) In a post-LN stack, and . Every path, the skip-only path included, passes through LayerNorm Jacobians.
Proof.
For (i), the multivariate chain rule of formalCalculus’ Jacobian topic (its Theorem 2) gives and composes these by multiplication. Multiplying out the product of binomials chooses, at each layer, either or , which gives one term per subset with its factors in layer order. Parts (ii) and (iii) are the chain rule applied to the two block forms, with Corollary 1 for the norm.
∎Veit, Wilber, and Belongie (2016) read (i) as an ensemble of paths of different lengths. It is also the attention topic’s one-hop property (its Proposition 5) one level up: there, the gradient from a later position reached an earlier one in a single hop through an attention weight; here, the gradient from the top of the stack reaches every layer through a single identity.
Parts (ii) and (iii) are where LayerNorm’s placement matters. Xiong and colleagues (2020, their Theorem 1) show by mean-field arguments that at initialization the gradient of the last block’s MLP weights is in a post-LN stack and in a pre-LN one, and they trace post-LN’s need for learning-rate warmup to the first bound. We do not prove their theorem. We measure the scaling it predicts, on random stacks with , four heads, and a ReLU MLP of width , read out by a random linear map through one final LayerNorm, as root-mean-squares over eight draws:
| depth | pre-LN, last | post-LN | pre-LN |
|---|---|---|---|
From to the pre-LN gradient falls by a factor of , against ; the post-LN gradient does not move, and at it is times the pre-LN one. The last column is the mechanism, and it is the readout’s. In a pre-LN stack each block adds to the stream, its squared norm grows linearly in depth, and the gradient reaches the last block through the final LayerNorm, whose Jacobian scales as , so like : the first and last columns multiply to , , and . It is a statement about the last block, not every branch. The first block’s gradient is , , and at the same depths, and does not shrink. A post-LN stack pins the stream at . The shape of the gradient across layers depends on the initialization, and ours differs from the figure Xiong and colleagues report; we claim the scaling, not the shape.
The stream as a channel
To see the stream at work we remove everything that is not attention.
Definition 4 (The attention-only model; circuits; composition).
The attention-only model has an embedding and an unembedding ; it reads tokens as (one row per token), updates with causal heads, rotary positions, and query and key biases, and outputs logits . It has no MLP and no LayerNorm. Head writes through its OV circuit , of rank at most . A path is a chain of heads with . The composition score of heads and is , with for K-composition, for Q-composition, and for V-composition.
This is the setting of Elhage and colleagues’ (2021) framework, which names the residual stream and the two circuits. The OV circuit’s rank bound is the singular-value picture of formalML’s SVD topic (its Theorem 1), and it is the same kind of bound as the attention topic’s one-head rank bound (its Proposition 7), which limits , seen from the write side. The composition score measures how much of what one head writes the other reads.
Theorem 3 (The path expansion).
Let be the attention matrix of head in the forward pass. Then
where the empty path contributes the direct path . With layers of heads there are paths.
Proof.
Each layer is . An attention matrix acts on the token index, from the left, and on the feature index, from the right, so and the two kinds of factor can be collected separately. Substituting into for each and distributing chooses, at each layer, either the skip or one head, and the chosen heads form a path. Collecting the left factors and the right factors gives the formula; at each layer there are choices.
∎The direct path is a function of the current token alone: a bigram model, built into the embedding and unembedding. The one-head paths copy what a head attends to; the two-head paths compose. The expansion is exact, and the notebook checks it against the forward pass of the trained model of the next section, whose two layers of two heads give paths, to about . Dong, Cordonnier, and Loukas use a decomposition of this kind to prove their collapse rate. One caution keeps it honest: the depend on the stream, so the expansion is linear in the values, not in the attention. Q- and K-composition live inside the patterns, and only V-composition appears in the products of OV circuits.
Proposition 4 (Orthogonal subspaces do not talk).
If for every layer-0 head , then the keys of head computed from equal those computed from , and its K-composition scores are . If also for every , the same holds for its queries, and its attention pattern is the same with or without layer 0’s output.
Proof.
, and the key bias and the rotation are applied after this product. The same computation with gives the queries, and the pattern depends on the stream only through queries and keys.
∎The stream is one -dimensional space shared by every head, and heads communicate only through the subspaces where one writes and another reads. The notebook builds a model whose layer-0 heads write into the first of coordinates while the layer-1 keys read only the last , and computing those keys from leaves the pattern unchanged to . The keys are only half of a score, though. The queries still read , and removing layer 0’s output moves each row of the pattern by a mean total variation of . Restrict the queries to the last coordinates as well, and the pattern with and without layer 0’s output agrees to .
Induction heads
Here is a task that needs two heads to talk. Draw a random block of tokens from a vocabulary of , of period between and , and repeat it to tokens. From position on, the next token is predictable, by a rule Olsson and colleagues (2022) call induction: find where the current token occurred before, and copy what came after it, [A][B] … [A] → [B]. We train attention-only models with and two heads of width per layer, rotary positions, and hand-written gradients, for Adam steps on fresh sequences, and test on more, scoring the positions from on:
| model | loss (nats) | accuracy |
|---|---|---|
| two layers | ||
| one layer | ||
| two layers, layer 1’s keys read from |
Guessing uniformly costs nats. The two-layer model solves the task; the one-layer model does not come close. The last row cuts one connection: layer 1’s keys are computed from the embeddings instead of the stream, so they cannot read anything layer 0 wrote, and the solved model falls apart, below even the one-layer model.
The two-layer model’s heads say how it works. Head puts of its weight on the previous token, on average. Its content-free score, the part that comes from its query and key biases alone, is for a key positions back: the positional-encodings topic’s kernel over offsets, and it peaks at , with against at . So head is a positional head: through position its weight on the previous token is about , and it writes a copy of each token’s predecessor into the stream at that token. The mean hides a drop. From position the mean weight is under , shared about evenly with the key positions back, where the kernel has its next peak, . The model’s accuracy does not fall there: it stays between and from position on. Both layer-1 heads put and of their weight on the position , just after the current token’s occurrence one period back, the induction target, and and on the positions after any earlier occurrence. Nearly all of those hold a correct copy of the next token. A block can repeat a token by chance, and then, at of the scored positions, one of them holds another token; the heads put about of their weight on such positions. Every K-composition score is between and , against to for Q-composition and to for V-composition, and above the largest K-score the same model had at its initialization, . Those scores do not separate the two layer-0 heads, so we cut them one at a time. Give layer 1’s keys plus head ‘s write alone, and the model stays solved, at nats and accuracy . Give them head ‘s write alone, and it fails, at nats and . Their keys read what head wrote.
Proposition 5 (What one layer's keys see).
In a one-layer model, the score of head is a function of alone. In particular it does not change when the token at position changes. In two layers, the key at reads , which contains when some layer-0 head attends to the previous token.
Proof.
In one layer, the query at is the rotation by of and the key at is the rotation by of . The two-layer formula is Definition 4’s update at .
∎Induction must attend to the position whose predecessor is the current token, and a one-layer score cannot see predecessors, so it cannot pick that position out by its content. Two layers can, through K-composition. Proposition 5 is about information, not a bound on loss: a one-layer model can still raise the probability of every token it has seen, and how close it gets to that in training is a measurement. The notebook changes the token before position and recomputes the last layer’s score at : in the one-layer model it moves by less than , and in the two-layer model by nats on average.
Theorem 3 shows where the answer lives. At the scored positions, the paths that end in a layer-1 head carry more than of the correct token’s centered logit (the median over positions), and the direct path and layer-0 paths alone rank the correct token first less than of the time. The logit lens (nostalgebraist 2020) reads the stream through the unembedding between layers, . This model has no final LayerNorm, so the lens is its own readout, and the probability of the correct token after the embedding, after layer , and after layer is , , and , with chance . The answer exists only after the second layer reads the first. On models with a final LayerNorm the lens reads applied to , a heuristic that Belrose and colleagues (2023) refine by training a probe for each layer.
The stream, interactively
The laboratory has two figures. Figure A is the geometry: the ten tokens of the collapse experiment, layer by layer, with and without the skip at five temperatures, beside their diameters and Theorem 1’s bound, and the LayerNorm picture at , where you can center a cloud, normalize it, and scale it without moving the result. Figure B is the trained model: the previous-token head’s and the induction head’s attention on a test sequence of period , the correct token’s logit split into its paths at any position you pick, the logit lens, the ablation, and the filing from the case study below.
A wide kernel (small β) keeps τ below 1, and the pure stack shrinks the cloud to a point, under Theorem 1’s bound. A narrow kernel (β = 4) lets a few long tokens win the rows: τ stays near 1, the bound falls slowly, and at layer 12 the cloud holds two clusters, which merge by layer 18, past this slider. With the skip the diameter never shrinks in these runs (Proposition 2 is the floor beneath them), but at β = 0.25 the relative spread still falls: the skip keeps the diameter, not its share.
The previous-token head’s weight sits just left of the diagonal, at j = i − 1, until position 39, where part of it moves to j = i − 39. The induction head attends to the earlier positions whose predecessor is the current token: i − p + 1 (outlined), and one or more periods further back on a long repetition. Unless the block repeats a token by chance, each holds a copy of the next token. Its keys can find them because the previous-token head wrote predecessors into the stream (Proposition 5).
Finance case study: completing a company’s name
Where this goes next
- Contextual embeddings. The same block without the causal mask, trained to fill in masked tokens, gives contextual word vectors; the contextual-embeddings topic builds it on this one.
- Scaling laws. Depth and width are the axes along which models scale, and the growing pre-LN stream of Theorem 2 (ii) is one reason depth is not free; the scaling-laws topic takes the empirical side.
- Euler steps. A residual block is one step of Euler’s method for the flow , whose global error formalCalculus’ numerical-ODEs topic bounds (its Theorem 1); a deep stack of small updates discretizes a trajectory of the tokens, and Geshkovski and colleagues study the clusters of a related flow.
- Superposition. A -dimensional stream carried embeddings, drawn at random and then trained, that the induction head still copied. Many nearly orthogonal directions fit in few dimensions: the trained table’s root-mean-square cosine is . That is the concentration idea behind formalRAG’s Johnson–Lindenstrauss topic, though its Theorem 3 needs more than dimensions for points, so it does not cover this case.
Honest caveats
Implementation
The companion notebook (notebookPath) imports transformer_block_residual_stream.py, which owns every number on this page. That module imports the positional-encodings topic’s module for its rotations, and through it the attention topic’s attention function and rounding conventions, the neural-language-models topic’s gradient checker and Adam constants, and the shared finance corpus. It trains three attention-only models from scratch in NumPy, two on repeated random sequences and one on filings, with hand-written gradients, and runs a harness of assertion-based tests in about twenty-five seconds on a laptop CPU. The tests cover:
- Proposition 1 against the attention topic’s attention function, and the MLP as a key–value sum.
- Proposition 3 and Corollary 1 at , , , and , against central differences, and the thin shell.
- Theorem 1 on random instances in three norms, and Theorem 1 and Proposition 2 on the laboratory’s cloud and on random stacks with random value maps; the narrow-kernel run through layer eighteen, the wide-kernel run landing on one token, and the merged pair.
- Theorem 2 against the chain rule and the subset sum; the pre-LN and post-LN gradient scaling.
- Theorem 3 on the trained model and on a random three-layer model; Proposition 4 on a constructed model, keys alone and keys with queries; Proposition 5 on both trained models.
- The induction experiments, the heads by position, the composition scores, the per-head cut, the paths, and the logit lens; the finance table.
- Every hand-written gradient against central differences: the attention-only model at random coordinates, and both stacks at every coordinate.
The laboratory reads its data from a JSON file that one of those tests requires to equal the module’s viz_payload() exactly, so the figure cannot drift from the code.
References & Further Reading
- paper Attention Is All You Need — Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, and Illia Polosukhin (2017) NeurIPS 30. The post-LN block, Definition 1
- paper Deep Residual Learning for Image Recognition — Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun (2016) CVPR 2016. The residual connection
- paper Layer Normalization — Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E. Hinton (2016) LayerNorm, Definition 3
- paper Root Mean Square Layer Normalization — Biao Zhang and Rico Sennrich (2019) NeurIPS 32. RMSNorm, Definition 3
- paper On Layer Normalization in the Transformer Architecture — Ruibin Xiong, Yunchang Yang, Di He, Kai Zheng, Shuxin Zheng, Chen Xing, Huishuai Zhang, Yanyan Lan, Liwei Wang, and Tie-Yan Liu (2020) ICML 2020. Gradient bounds at initialization for post-LN and pre-LN (their Theorem 1), measured after Theorem 2
- paper Attention Is Not All You Need: Pure Attention Loses Rank Doubly Exponentially with Depth — Yihe Dong, Jean-Baptiste Cordonnier, and Andreas Loukas (2021) ICML 2021. The doubly exponential collapse of pure attention, beside Theorem 1, and a path decomposition, beside Theorem 3
- paper Residual Networks Behave Like Ensembles of Relatively Shallow Networks — Andreas Veit, Michael Wilber, and Serge Belongie (2016) NeurIPS 29. A residual network as a collection of paths, Theorem 2's reading
- blog A Mathematical Framework for Transformer Circuits — Nelson Elhage, Neel Nanda, Catherine Olsson, Tom Henighan, Nicholas Joseph, Ben Mann, Amanda Askell, et al. (2021) Transformer Circuits Thread. The residual stream, QK and OV circuits, composition scores, and the path expansion: Definition 4, Theorem 3, Proposition 4
- paper In-context Learning and Induction Heads — Catherine Olsson, Nelson Elhage, Neel Nanda, Nicholas Joseph, Nova DasSarma, Tom Henighan, et al. (2022) Transformer Circuits Thread. Induction heads and their role in in-context learning
- paper Transformer Feed-Forward Layers Are Key-Value Memories — Mor Geva, Roei Schuster, Jonathan Berant, and Omer Levy (2021) EMNLP 2021. The MLP as a key–value memory, Proposition 1 (ii)
- blog interpreting GPT: the logit lens — nostalgebraist (2020) LessWrong. Reading the residual stream through the unembedding
- paper Eliciting Latent Predictions from Transformers with the Tuned Lens — Nora Belrose, Igor Ostrovsky, Lev McKinney, Zach Furman, Logan Smith, Danny Halawi, Stella Biderman, and Jacob Steinhardt (2023) The tuned lens, a trained refinement of the logit lens
- paper On the Expressivity Role of LayerNorm in Transformers' Attention — Shaked Brody, Uri Alon, and Eran Yahav (2023) Findings of ACL 2023. LayerNorm as a projection and a scaling, Proposition 3
- paper A Mathematical Perspective on Transformers — Borjan Geshkovski, Cyril Letrouit, Yury Polyanskiy, and Philippe Rigollet (2023) Tokens as interacting particles on a sphere in continuous time: clusters that form fast and merge slowly, observed numerically, beside Theorem 1's narrow-kernel run
- book Non-negative Matrices and Markov Chains — E. Seneta (1981) 2nd ed., Springer. Coefficients of ergodicity, Definition 2 and Theorem 1 (i)
- paper Central Limit Theorem for Nonstationary Markov Chains. I — R. L. Dobrushin (1956) Theory of Probability and Its Applications 1. The ergodicity coefficient, Definition 2