Is there a normal form / random matrix model for trained transformers?

Background Facts

▲▼
▲▼
▲▼
▲▼

This question is about the structure of attention heads in trained transformers.

TL;DR: Why do trained bilinear forms behave similarly to rank-one forms?

An attention head computes interactions between tokens x,yx,y using its bilinear form xTKTQyx^T K^T Q y, where QQ and KK are n×Nn \times N matrices and n≤N/2n \leq N/2. Write L=KTQ=S+TL = K^TQ = S + T for symmetric SS and antisymmetric TT.

The following facts hold away from a subset of Q,KQ,K of measure zero:

  • SS has signature (n,n,N−2n)(n,n,N-2n),
  • TT has rank 2n2n, with nn nonzero singular values each of multiplicity two,

So every head has three lists of nn positive numbers, each sorted in decreasing order: the positive eigenvalues λ+\lambda_+ of SS, the absolute values λ−\lambda_- of its negative eigenvalues, and the singular values σ(T)\sigma(T) of TT counted once.

In 21,080 trained heads from 18 open-source language models trained on natural language, two additional relations approximately hold for their spectral data. The first is that the antisymmetric spectrum is approximately determined by the symmetric spectrum.

(1) The singular values of TT are geometric means of the eigenvalues of SS:

σ(T)i≈(λ+)i(λ−)i,i=1,…,n.\sigma(T)_i\approx\sqrt{(\lambda_+)_i(\lambda_-)_i},\qquad i=1,\dots,n.

For a real vector xx write (x)+=max⁡(x,0)(x)_+=\max(x,0) and (x)−=max⁡(−x,0)(x)_-=\max(-x,0) entrywise. The squared Frobenius norm of LL splits into four nonnegative terms:

∥L∥2=∥T∥2+∥S∥2=∥T∥2+∥λ+∥2+∥λ−∥2=∥T∥2+2⟨λ+,λ−⟩+∥λ+−λ−∥2=∥T∥2+2⟨λ+,λ−⟩+∥(λ+−λ−)+∥2+∥(λ+−λ−)−∥2.\begin{aligned} \|L\|^2&=\|T\|^2+\|S\|^2\\ &=\|T\|^2+\|\lambda_+\|^2+\|\lambda_-\|^2\\ &=\|T\|^2+2\langle\lambda_+,\lambda_-\rangle+\|\lambda_+-\lambda_-\|^2\\ &=\|T\|^2+2\langle\lambda_+,\lambda_-\rangle+\|(\lambda_+-\lambda_-)_+\|^2+\|(\lambda_+-\lambda_-)_-\|^2. \end{aligned}

Dividing by ∥L∥2\|L\|^2 gives four nonnegative numbers summing to one:

a=∥T∥2∥L∥2,b=2⟨λ+,λ−⟩∥L∥2,c=∥(λ+−λ−)+∥2∥L∥2,d=∥(λ+−λ−)−∥2∥L∥2.a=\frac{\|T\|^2}{\|L\|^2},\quad b=\frac{2\langle\lambda_+,\lambda_-\rangle}{\|L\|^2},\quad c=\frac{\|(\lambda_+-\lambda_-)_+\|^2}{\|L\|^2},\quad d=\frac{\|(\lambda_+-\lambda_-)_-\|^2}{\|L\|^2}.

So to each nonzero bilinear form we get a point (a,b,c,d)(a,b,c,d) in the tetrahedron Δ\Delta. Let Θ={a=b, cd=0}⊂Δ\Theta=\{a=b,\ cd=0\} \subset \Delta. The second observation is that trained heads accumulate along Θ\Theta.

(2) Trained heads lie close to Θ\Theta and spread along it.

Question Statement

▲▼
▲▼
▲▼

Question. Is there a natural class of pairs (Q,K)(Q,K) given by either a normal form or a random matrix ensemble for which (1) and (2) hold?

Further Remarks

▲▼
▲▼
▲▼
▲▼

Random models. If Q,KQ,K have independent Gaussian entries, both relations hold approximately, but with λ+≈λ−\lambda_+\approx\lambda_-, so all profiles sit at the single point (12,12,0,0)(\tfrac12,\tfrac12,0,0) of Θ\Theta. If K=rQ+1−r2 GK=rQ+\sqrt{1-r^2}\,G with Q,GQ,G independent Gaussian, the profile moves along Θ\Theta to c−d≈r∣r∣c-d\approx r|r|. So the observed spread along Θ\Theta seems likely to be due to a correlation between QQ and KK that remains to be described.

Rank one matrices. Rank one matrices satisfy the first observation exactly. Let L=uvTL=uv^T with u,vu,v unit and t=uTvt=u^Tv. Then S=12(uvT+vuT)S=\tfrac12(uv^T+vu^T) has eigenvectors u+vu+v and u−vu-v with eigenvalues 1+t2\tfrac{1+t}2 and −1−t2-\tfrac{1-t}2, so λ+=1+t2\lambda_+=\tfrac{1+t}2 and λ−=1−t2\lambda_-=\tfrac{1-t}2. The antisymmetric part T=12(uvT−vuT)T=\tfrac12(uv^T-vu^T) has two equal singular values σ\sigma with 2σ2=∥T∥2=1−t222\sigma^2=\|T\|^2=\tfrac{1-t^2}2, so σ(T)=121−t2=λ+λ−.\sigma(T)=\tfrac12\sqrt{1-t^2}=\sqrt{\lambda_+\lambda_-}. Consequently LL has (a,b,c,d)=(1−t22,1−t22,(t)+2,(t)−2)(a,b,c,d)=\bigl(\tfrac{1-t^2}2,\tfrac{1-t^2}2,(t)_+^2,(t)_-^2\bigr), so Θ={(aL,bL,cL,dL):rk L=1}.\Theta = \{(a_L,b_L,c_L,d_L) : \mathrm{rk}\,L = 1\}. So in some sense, bilinear forms in trained attention heads are behaving like rank-one forms even though their effective rank is far from one.

Details and data: arXiv:2609.22990

abcd_simplex_all

Sign in to comment

1 answer

▲▼
▲▼
▲▼
▲▼

Short answer: yes. There is a natural class of query/key forms for which relations (1) and (2) hold exactly, and a natural Gaussian ensemble whose profiles converge to profiles of forms in that class. Every theorem in this answer is checked in Lean, and the full project (proofs, scripts, data) is at github.com/andrewcritch/question-2026-11-20-odesky.

Notation and relations (1) and (2) are as in the question: SS, TT, λ+\lambda_+, λ−\lambda_-, σ(T)\sigma(T), a,b,c,da,b,c,d and Θ\Theta, all computed from the form L=K⊤QL=K^\top Q of a head. The profile of LL is π(L):=(a(L),b(L),c(L),d(L))\pi(L):=(a(L),b(L),c(L),d(L)).

Attribution. This solution was found by a collaboration between AI models: Claude Opus 5.5, GPT-6 Astra and GPT-6.1 Sol (both via Codex), Gemini 4 Carbon (via Antigravity), and Grok 4.7 (via Grok Build). Claude Opus 5.5 coordinated the work, found the ordering condition that makes relations (1) and (2) exact, built the ensemble from the other models' ideas, and ran the measurements on trained models; GPT-6 Astra found the exact identity for aa and the rearrangement argument that the ordering condition sharpens; a second Claude Opus 5.5 instance proposed writing the ensemble through Q+KQ+K and K−QK-Q; Gemini 4 Carbon proposed tying how closely each query row aligns with its key row to how large the pair is, and found the correction at a fixed ratio N/nN/n; Grok 4.7 characterized the structure of trained heads outside the ensemble; and GPT-6.1 Sol and Claude Opus 5.5 subagents wrote the Lean proofs. attribution.md gives the details.

1. Coordinates

Let L=K⊤QL=K^\top Q have rank n≥1n\ge1. Write L=UΣV⊤L=U\Sigma V^\top, where Σ=diag(σ1,…,σn)\Sigma=\mathrm{diag}(\sigma_1,\dots,\sigma_n) holds the nn nonzero singular values σ1,…,σn>0\sigma_1,\dots,\sigma_n>0 (in any order), and U,V∈RN×nU,V\in\mathbb R^{N\times n} have orthonormal columns uiu_i, viv_i. Let W:=U⊤VW:=U^\top V, the n×nn\times n matrix of cosines Wij=ui⊤vjW_{ij}=u_i^\top v_j between the left and right singular vectors of LL.

  • For N≥2nN\ge2n, the pair (Σ,W)(\Sigma,W) determines LL up to the congruence L↦OLO⊤L\mapsto OLO^\top with OO orthogonal. The profile and relations (1) and (2) are invariant under this congruence, so (Σ,W)(\Sigma,W) determines them.
  • Let ti:=Wii=ui⊤vit_i:=W_{ii}=u_i^\top v_i, the tilt of the pair (ui,vi)(u_i,v_i); let F:=∑iσi2F:=\sum_i\sigma_i^2, m2:=∑iσi2ti2/Fm_2:=\sum_i\sigma_i^2t_i^2/F, and q:=∑i≠jσiσjWijWji/Fq:=\sum_{i\ne j}\sigma_i\sigma_jW_{ij}W_{ji}/F. Then exactly
    a=12(1−m2−q),a−b=c+d−m2−q.a=\tfrac12(1-m_2-q),\qquad a-b=c+d-m_2-q.
  • Let F∈R2n×NF\in\mathbb R^{2n\times N} be the matrix whose rows are the nn rows of QQ followed by the nn rows of KK. For every head with rank⁡F=2n\operatorname{rank}F=2n, ∑ilog⁡σ(T)i=12∑ilog⁡(λ+,iλ−,i)\sum_i\log\sigma(T)_i=\tfrac12\sum_i\log(\lambda_{+,i}\lambda_{-,i}), because ∏iσ(T)i2=∏iλ+,iλ−,i=det⁡G/4n\prod_i\sigma(T)_i^2=\prod_i\lambda_{+,i}\lambda_{-,i}=\det G/4^n, where G:=FF⊤G:=FF^\top is the 2n×2n2n\times2n Gram matrix of the rows of FF. So the log-ratios ri:=log⁡σ(T)i−12log⁡(λ+,iλ−,i)r_i:=\log\sigma(T)_i-\tfrac12\log(\lambda_{+,i}\lambda_{-,i}) sum to zero, and if they are all equal they are all zero: relation (1) can fail only through the spread of the rir_i over ii.

Lean checks these three facts, in Congruence.lean, Identities.lean and LogDet.lean; proofs in words are in the project record, record.md, entries R1, R4 and R5.

2. Normal form

A sum of rank-one forms on orthogonal planes is L=∑iσiuivi⊤L=\sum_i\sigma_iu_iv_i^\top with σi>0\sigma_i>0, unit vectors ui,viu_i,v_i with ui≠±viu_i\ne\pm v_i, and the planes span(ui,vi)\mathrm{span}(u_i,v_i) mutually orthogonal (so WW is diagonal). The summand σiuivi⊤\sigma_iu_iv_i^\top is block ii; its tilt ti=ui⊤vit_i=u_i^\top v_i (defined in §1) lies in (−1,1)(-1,1). Put αi:=σi(1+ti)/2\alpha_i:=\sigma_i(1+t_i)/2 and βi:=σi(1−ti)/2\beta_i:=\sigma_i(1-t_i)/2. The blocks are similarly ordered if (αi−αj)(βi−βj)≥0(\alpha_i-\alpha_j)(\beta_i-\beta_j)\ge0 for all i,ji,j. LL is in normal form if the blocks of LL are similarly ordered and the tilts of LL are all ≥0\ge0 or all ≤0\le0.

Lemma 1. The symmetric part of block ii has eigenvalues αi>0\alpha_i>0 and −βi<0-\beta_i<0, and the antisymmetric part of block ii has singular value αiβi\sqrt{\alpha_i\beta_i} with multiplicity 2. (Proof: the rank-one computation in the question, applied to each block.)

Theorem 1. Let LL be a sum of n≥1n\ge1 rank-one forms on orthogonal planes. Then:

  1. a≤ba\le b, with equality if and only if the blocks of LL are similarly ordered.
  2. If the blocks are similarly ordered, relation (1) holds with equality at every index k=1,…,nk=1,\dots,n.
  3. If the blocks are similarly ordered, then c−d=∑iwiti∣ti∣c-d=\sum_iw_it_i|t_i| with wi:=σi2/Fw_i:=\sigma_i^2/F; d=0d=0 if and only if every ti≥0t_i\ge0; and c=0c=0 if and only if every ti≤0t_i\le0.
  4. π(L)∈Θ\pi(L)\in\Theta, i.e., relation (2) holds, if and only if LL is in normal form.
  5. Every point of Θ\Theta other than the two endpoints of Θ\Theta is π(L′)\pi(L') for some L′L' in normal form.

Proof sketch of Theorem 1. By Lemma 1, λ+\lambda_+ is the list of the αi\alpha_i sorted decreasingly, and λ−\lambda_- is the list of the βi\beta_i sorted decreasingly. So b=2∑kλ+,kλ−,k/Fb=2\sum_k\lambda_{+,k}\lambda_{-,k}/F pairs the αi\alpha_i with the βi\beta_i in sorted order, while a=2∑iαiβi/Fa=2\sum_i\alpha_i\beta_i/F pairs them block by block. By the rearrangement inequality, a≤ba\le b, with equality exactly when one permutation sorts both lists; that permutation also gives items 2 and 3. Equal tilts ti=tt_i=t give the rank-one profiles, which gives item 5. Lean checks Lemma 1 in Geometry.lean and Spectral.lean, and Theorem 1 in TheoremAExtra.lean and Main.lean.

By Theorem 1(4), among sums of rank-one forms on orthogonal planes, the forms that "behave like rank-one forms", in the question's phrase, are exactly the forms in normal form. Items 1–4 of Theorem 1 hold for every number n≥1n\ge1 of blocks. Theorem 1 says nothing about forms whose planes are not orthogonal.

3. Random ensemble

Fix n≥1n\ge1, a law μ\mu on R\mathbb R, and functions f,g:R→(0,∞)f,g:\mathbb R\to(0,\infty) that are both nondecreasing. Draw an i.i.d. sequence ρ1,ρ2,…\rho_1,\rho_2,\dots from μ\mu; a head with nn blocks uses ρ1,…,ρn\rho_1,\dots,\rho_n. For each N≥2nN\ge2n, let P,M∈Rn×NP,M\in\mathbb R^{n\times N} be the first NN columns of two infinite arrays of i.i.d. standard Gaussian entries, independent of each other and of the ρi\rho_i. Define QQ and KK by

Q+K=2 diag(f(ρ1),…,f(ρn))P/N,K−Q=2 diag(g(ρ1),…,g(ρn))M/N.Q+K=2\,\mathrm{diag}\bigl(\sqrt{f(\rho_1)},\dots,\sqrt{f(\rho_n)}\bigr)P/\sqrt N,\qquad K-Q=2\,\mathrm{diag}\bigl(\sqrt{g(\rho_1)},\dots,\sqrt{g(\rho_n)}\bigr)M/\sqrt N.

Theorem 2. Fix the values of ρ1,…,ρn\rho_1,\dots,\rho_n (since P,MP,M are independent of ρ\rho, this is conditioning on ρ\rho). As N→∞N\to\infty with nn fixed, almost surely π(L)\pi(L) converges to π(L∞)\pi(L_\infty), where L∞L_\infty is a sum of rank-one forms on orthogonal planes with αi=f(ρi)\alpha_i=f(\rho_i) and βi=g(ρi)\beta_i=g(\rho_i). The blocks of L∞L_\infty are similarly ordered, because ff and gg are nondecreasing. Hence a−b→0a-b\to0, and relation (1) holds with equality in the limit. If f−gf-g does not change sign on R\mathbb R, then L∞L_\infty is in normal form, so relation (2) holds in the limit. If also E[(f+g)(ρ)2]<∞\mathbb E[(f+g)(\rho)^2]<\infty for ρ∼μ\rho\sim\mu, then, as n→∞n\to\infty, almost surely

c(L∞)−d(L∞)  →  E[(f−g)(ρ) ∣(f−g)(ρ)∣]E[(f+g)(ρ)2].c(L_\infty)-d(L_\infty)\;\to\;\frac{\mathbb E[(f-g)(\rho)\,|(f-g)(\rho)|]}{\mathbb E[(f+g)(\rho)^2]}.

The right-hand side is the (f+g)2(f+g)^2-weighted mean of t∣t∣t|t|, where t=(f−g)/(f+g)t=(f-g)/(f+g) is the tilt of a block of L∞L_\infty.

Proof sketch of Theorem 2. Let x1,…,x2n∈RNx_1,\dots,x_{2n}\in\mathbb R^N be the nn rows of P/NP/\sqrt N followed by the nn rows of M/NM/\sqrt N. As N→∞N\to\infty, the Gram matrix of x1,…,x2nx_1,\dots,x_{2n} tends to II almost surely, by the strong law of large numbers. So these rows lie within a distance δ→0\delta\to0 of an orthonormal family. The form whose rows are built from the orthonormal family, in place of x1,…,x2nx_1,\dots,x_{2n}, is exactly a sum of rank-one forms on orthogonal planes with αi=f(ρi)\alpha_i=f(\rho_i) and βi=g(ρi)\beta_i=g(\rho_i). Replacing the orthonormal family by x1,…,x2nx_1,\dots,x_{2n} changes SS and T⊤TT^\top T by O(δ)O(\delta) in operator norm. By Weyl's inequality, every sorted eigenvalue of SS and of T⊤TT^\top T then changes by O(δ)O(\delta), uniformly in NN. The squared Frobenius norms of LL and TT are polynomials in the Gram matrix, so they converge too. The n→∞n\to\infty limit of c−dc-d follows from the strong law of large numbers applied to the formula of Theorem 1(3). Hence Theorem 2 holds. Lean checks the convergence statement as theoremB_ae in TheoremBFull.lean, the consequences and the limit of c−dc-d in TheoremBExtra.lean, and the strong law for the ratio as ratio_slln in Probability.lean.

In words: row ii of Q+KQ+K has squared norm close to 4f(ρi)4f(\rho_i) (a "match" strength), row ii of K−QK-Q has squared norm close to 4g(ρi)4g(\rho_i) (a "mismatch" strength), and ff and gg are both nondecreasing in a shared latent parameter ρi\rho_i. Special cases of the ensemble:

  • f,gf,g constant: take the question's correlated Gaussian model K=rQ+1−r2 GK=rQ+\sqrt{1-r^2}\,G, with ∣r∣<1|r|<1 and Q,GQ,G having independent standard Gaussian entries. For each entry, (Q+K,  K−Q)(Q+K,\;K-Q) has the law of two independent centered Gaussians with variances 2(1+r)2(1+r) and 2(1−r)2(1-r). For f=(1+r)/2f=(1+r)/2 and g=(1−r)/2g=(1-r)/2, this is the law of the corresponding entry of (2f P,  2g M)(2\sqrt f\,P,\;2\sqrt g\,M), i.e., of N (Q+K,  K−Q)\sqrt N\,(Q+K,\;K-Q) in the ensemble.
  • f=gf=g constant: for r=0r=0, the question's model has QQ and KK with independent standard Gaussian entries, and the previous item matches it entry by entry, up to the factor N\sqrt N, with f=g=12f=g=\tfrac12. This case is the Gaussian baseline. By Theorem 2, its limit profile is the midpoint (12,12,0,0)(\tfrac12,\tfrac12,0,0) of Θ\Theta.

4. Comparison with trained heads

The numbers in this section are measurements on model weights, not theorems; the one theorem this section uses is Theorem 1(1). All measurements use raw L=K⊤QL=K^\top Q (the LayerNorm gains are not multiplied into QQ and KK; for RoPE, LL at relative position 0), in GPT-2 small (144 heads), GPT-2 medium (384 heads) and Pythia-160m (RoPE, 144 heads). Each value is the median over heads. The relation-(1) relative error is ∥σ(T)−λ+λ−∥/∥σ(T)∥\|\sigma(T)-\sqrt{\lambda_+\lambda_-}\|/\|\sigma(T)\|, with entrywise products and square roots. The Gaussian baseline replaces QQ and KK by independent Gaussian matrices of the same shape. The scripts are in delegations/round1_brief/: gpt2_W.py and comono.py for GPT-2 small, medium.py for GPT-2 medium and large, pythia.py, and bloom.py; the results are entries R3, R13, R15, R16, R18 and R19 of record.md.

quantity GPT-2 small GPT-2 medium Pythia-160m Gaussian baseline
Kendall τ(α,β)\tau(\alpha,\beta) from σi\sigma_i and tit_i (1 = similarly ordered) 0.76 0.77 0.85 —
diagonal share of ∣W∣F2|W|_F^2 0.18 0.21 0.13 0.016
off-diagonal RMS of WW / N−1/2N^{-1/2} 1.34 1.35 1.30 1.00
relation-(1) relative error 0.059 0.051 0.044 0.011
fraction of heads with a>ba>b 0.31 0.22 0.31 —
corr(q, a−b)\mathrm{corr}(q,\,a-b) across heads −0.97 −0.97 −0.96 —

Reading:

  • Training raises the diagonal share of ∥W∥F2\|W\|_F^2. In GPT-2 small, the diagonal share is 0.18, about 11 times its Gaussian-baseline value 0.016.
  • The off-diagonal entries of WW are mostly at the size that random vectors give. Their RMS matches the off-diagonal RMS of WW for random frames in dimension about 0.55N0.55N, in GPT-2 small and in GPT-2 medium.
  • Trained heads depart from the normal form in two separate ways. Departure 1 is imperfect similar ordering of α\alpha and β\beta (Kendall τ≈0.77\tau\approx0.77). Departure 1 pushes aa below bb and accounts for most of the relation-(1) error. Departure 2 is the reciprocal off-diagonal overlap qq (defined in §1), which decides the sign of a−ba-b. By Theorem 1(1), every sum of rank-one forms on orthogonal planes has a≤ba\le b, so the roughly 30% of trained heads with a>ba>b are not sums of rank-one forms on orthogonal planes. Across heads, a−ba-b tracks −q-q (correlation −0.97-0.97). The heads with the largest a−ba-b are layer-0 heads with q≈−0.2q\approx-0.2, from an antisymmetric coupling among the top singular directions of WW.
  • Relation (1) has a larger error in trained heads than under the Gaussian baseline. The Gaussian baseline has its limit profile at the midpoint of Θ\Theta, where relation (1) has a small error. Training moves the profiles of heads away from the midpoint, along Θ\Theta, and adds departures 1 and 2.

5. Summary

Relations (1) and (2) hold exactly for the forms in normal form (Theorem 1). For the Gaussian ensemble of §3 with f−gf-g of one sign, the profile of LL converges to the profile of a form in normal form as the embedding dimension NN grows (Theorem 2), and, entry by entry, the question's correlated Gaussian model has the same law as that ensemble with constant f,gf,g, up to the factor N\sqrt N. Trained attention heads are close to the normal form, and §4 measured their departures from it.

6. Lean verification

Every theorem and identity in §1–§3 is checked in Lean 4 with Mathlib (hereafter, Lean), in lean/, with no unproved steps; #print axioms on each headline theorem gives only propext, Classical.choice and Quot.sound. In these checks, Lean computes the profile from decreasingly sorted eigenvalues of SS and T⊤TT^\top T (Mathlib's sorted eigenvalues, or decreasing lists of the characteristic-polynomial roots, which a lemma identifies) and from squared Frobenius norms. For degenerate heads, Lean pads missing entries of the spectral lists with zeros and takes x/0=0x/0=0; the statements about the relation-(1) error assume T≠0T\ne0, where its denominator is positive. For the limit form L∞L_\infty and the special cases, Lean works with the formulas of Theorem 1 in terms of α\alpha and β\beta, which Main.lean and Limit.lean identify with the profile of the operator.

claim Lean theorems file
§1: every L=K⊤QL=K^\top Q of rank nn has the form UΣV⊤U\Sigma V^\top used in §1, and the profile, the spectral lists and the relation-(1) error depend only on LL exists_svd_rows, gprof_of_formL_eq Bridge.lean
§1: (Σ,W)(\Sigma,W) determines LL up to orthogonal congruence, and so the profile, the spectral lists (hence relation (1)) and the relation-(1) error exists_isometry_of_same_W, gprof_isometry, gprof_eq_of_same_W, lists_isometry, formL_isometry Congruence.lean, Bridge.lean, Extras.lean
§1: a=12(1−m2−q)a=\tfrac12(1-m_2-q) and a−b=c+d−m2−qa-b=c+d-m_2-q gA_identity, gprof_sum_eq_one, gA_sub_gB_identity Identities.lean
§1: the log-determinant identity, through ∏kσ(T)k2=∏kλ+,kλ−,k=det⁡G/4n\prod_k\sigma(T)_k^2=\prod_k\lambda_{+,k}\lambda_{-,k}=\det G/4^n logdet_identity, prod_sig_eq_det, prod_lam_eq_det LogDet.lean
Lemma 1 charpoly_S, charpoly_neg_T_sq, roots_S_pos, roots_S_neg, roots_neg_T_sq_pos, α_pos, β_pos Spectral.lean, Geometry.lean
Theorem 1(1)–(4) main_a_le_b, main_a_eq_b_iff, main_relation_one, main_c_sub_d, main_d_eq_zero_iff, main_c_eq_zero_iff, main_mem_Theta_iff Main.lean, TheoremAExtra.lean
Theorem 1(5), with a witness of one block in R2\mathbb R^2 theta_attained TheoremAExtra.lean
Theorem 2: convergence of the profile and of the relation-(1) error, to the profile of an actual sum L∞L_\infty of rank-one forms on orthogonal planes theoremB_ae, blocks_of_limit_gram, gprof_at_limit TheoremBFull.lean, TheoremB.lean, Limit.lean
Theorem 2: similar ordering, a=ba=b for L∞L_\infty (so, with the previous row, a−b→0a-b\to0), and π(L∞)∈Θ\pi(L_\infty)\in\Theta when f−gf-g does not change sign on R\mathbb R similarlyOrdered_of_monotone, limit_a_eq_b, limit_mem_Theta TheoremBExtra.lean
Theorem 2: the n→∞n\to\infty limit of c(L∞)−d(L∞)c(L_\infty)-d(L_\infty) cd_eq_ratio, cd_limit_ae TheoremBExtra.lean
§3: the Gaussian baseline has limit profile (12,12,0,0)(\tfrac12,\tfrac12,0,0); for each entry, (Q+K,K−Q)(Q+K,K-Q) in the question's correlated model has the law of independent centered Gaussians with variances 2(1±r)2(1\pm r), for ∣r∣<1\lvert r\rvert<1 const_profile, correlated_gaussian_law SpecialCases.lean
§1 and §3: the log-ratios sum to zero and vanish when equal; the weighted-mean reading of Theorem 2 logratio_sum_zero, eq_zero_of_sum_zero_of_const, weighted_tilt Extras.lean

7. Caveats

  • The table in §4 covers GPT-2 small, GPT-2 medium and Pythia-160m (RoPE) only. BLOOM-560m (ALiBi, 384 heads) and GPT-2 large (720 heads) give values close to those of the table, as medians over heads: diagonal share of ∥W∥F2\|W\|_F^2: 0.18 and 0.24; Kendall τ\tau: 0.76 and 0.78; relation-(1) relative error: 0.044 and 0.050; fraction of heads with a>ba>b: 0.19 and 0.21; corr(q,a−b)\mathrm{corr}(q,a-b): −0.97-0.97 and −0.98-0.98.
  • Whether the LayerNorm gains are multiplied into LL matters for how close heads are to Θ\Theta: with the gains and centering multiplied in, 20% of GPT-2-small heads have ∣a−b∣>0.1|a-b|>0.1, against 7.6% for raw LL (gpt2_more.py).
  • Some finite-NN ensembles reproduce departures 1 and 2 of §4. One example, in delegations/answers/round2/, uses eight parameters per head, and its median relation-(1) relative error over heads equals the measured median. But these ensembles are descriptive fits, not natural ensembles, and none of them reproduces the layer-0 heads with the largest a−ba-b.
  • Theorem 2 states convergence as N→∞N\to\infty with nn fixed. At a fixed ratio N=κnN=\kappa n with n→∞n\to\infty, the limit can differ, and Theorem 2 does not cover that regime. A numerical observation, not a theorem: for constant f,gf,g, simulations agree with 1−2a→(1+1/κ)(f−g)2/((f+g)2+(f−g)2/κ)1-2a\to(1+1/\kappa)(f-g)^2/\bigl((f+g)^2+(f-g)^2/\kappa\bigr), against (f−g)2/(f+g)2(f-g)^2/(f+g)^2 for the iterated limit, which is 1−2a1-2a of L∞L_\infty (at f=2f=2, g=1g=1, n=400n=400, N=800N=800: 1−2a=0.15981-2a=0.1598 measured, 0.15790.1579 predicted, 0.11110.1111 for the iterated limit). Writing xx for the iterated-limit value and yy for the fixed-ratio value, x≤y≤x(1+1/κ)x\le y\le x(1+1/\kappa): for f≠gf\ne g, a relative difference of at most 1/κ1/\kappa, which is 5–8% for the measured models (κ=12\kappa=12–2020), and for f=gf=g, x=y=0x=y=0; Lean checks this bound as fixed_ratio_bound in Ratio.lean, and the value of xx as const_one_sub_two_a in Extras.lean.
  • Some parts of this answer are not mathematical theorems, so Lean does not check them: the measurements of §4 and of the caveats above (other models, LayerNorm, finite-NN fits), and the fixed-ratio formula of the previous caveat, which is a numerical observation.
  • Thanks Andrew! Actually GPT 6.1 showed me the same construction at some point; while this random model recovers (1) and (2) and is certainly interesting, I wasn't able to convince myself that it's the right model for trained attention heads. The data in your paragraph 4 give a comparison to trained heads based on the spectra of SS and TT, but it'd be more convincing to have a comparison with L=S+TL=S+T itself. When I compared this model with trained heads I got the impression that this construction wasn't the whole story, though I don't doubt that it's probably an important ingredient!

    – Andrew O'Desky

Sign in to comment

Sign in to answer