betaFeedback

WorksMathematics

In-context classification: Calibration and noise in linear attention with softmax readout

Abstract

We study in-context binary classification in a simple attention model trained to minimise a logistic loss. Each prompt has a latent logistic teacher, and the learner must infer its direction from Bernoulli-labeled context examples. We derive an asymptotic prediction for the test logit in a high-dimensional regime with context length proportional to token dimension, and total training prompts proportional to dimension squared. Our formula cleanly separates calibration, test-time context noise, and non-isotropic parameter-estimation noise as interpretable effects on in-context performance. Our analysis also identifies the ridgeless separability regime and addresses the effects of context length, pretraining-set size, regularisation, and sampling temperature on in-context classification performance. The theory's predictions closely agree with finite-dimensional simulations and fully trained linear-attention models, while experiments with standard softmax attention show qualitatively related behaviour beyond the regime assumed by our analysis.

Introduction

In-context learning (ICL) is the ability of a model to adapt its predictions from examples in a prompt, without updating its parameters ([6, 24, 25]). It is a striking capability of modern sequence models, which can, for instance, implement a range of statistical algorithms in-context ([3]). However, the statistical mechanism that turns a context into a new-task prediction is not fully understood.

Simplified ICL models offer a useful route to this question because they make explicit which prompt statistics an architecture can use ([2, 24, 29, 17, 20, 23, 16 a]). In particular, a significant body of recent work has explored ICL in the context of the test problem of linear regression. For these tasks, linear attention ([13]) has been shown to be a good surrogate for understanding how and what transformers learn ([1, 28, 26, 17, 16, 5]). Together, these works demonstrate how reduced models can yield substantial insight into the mechanisms of ICL.

Despite extensive progress in the theory of in-context learning, many works focus on regression; binary classification introduces qualitatively different questions and phenomena. In the setting studied here, each prompt is generated by a latent task direction, and its context labels are Bernoulli observations determined by that direction. A successful predictor must therefore output a calibrated probability rather than merely recover a sign. Logistic regression, a canonical high-dimensional inference problem, is a natural target for such investigation. This problem has been widely studied ([18, 22]), including its phase transitions ([7, 4]), universality ([21]), and generalisation ([12, 19]), leading to a rich understanding of a single instance of this estimation problem. By contrast, the in-context setting involves learning a general estimator that can approximately solve new instances of logistic regression. Recent works have investigated whether transformers can learn to do this, perhaps by performing normalised gradient descent [27]. Moreover, studies of multiclass classification have shown that properties of the data greatly affect the model’s ability to learn in-context [8]. Yet, a detailed understanding of in-context classification, comparable to what has been achieved for regression, is still lacking.

Here, we study in-context logistic regression using a reduced linear-attention model with a softmax readout. We derive a high-dimensional characterisation of the output logit, and corresponding test errors, in a proportional regime where context length scales with token dimension and the number of pretraining sequences scales with its square. We characterise the joint law of the output logit and teacher logit, leading to the following findings.

  • The form of the output logit is highly interpretable, and decomposes into three parts: scaling of the teacher-aligned signal, noise from test-time context, and anisotropy induced by finitely many pretraining sequences.

  • This separation distinguishes the roles of context length and training-set size, and recovers the Bayes logit in the joint large-context, large-pretraining-data ridgeless limit.

  • We predict the separability boundary at which the ridgeless logistic estimator ceases to have a finite solution.

  • Finally, we verify the theory through finite-dimensional simulations and show that its predicted logit distribution describes the output of a trained linear-attention model.

Data and model setup

Data generation. Following prior theoretical work on ICL [28, 26, 17], we train the model on a dataset of nn sequences of examples. Each sequence consists of (x,y)(x,y) pairs sampled from a latent task, and the model aims to learn the corresponding conditional distribution. Each sequence has a latent task vector w∈Rdw \in\mathbb{R}^{d} drawn uniformly from the unit sphere. Fix an inverse temperature β>0\beta> 0. Fixing ww, draw independent covariates xi∼N(0,Id)x_i \sim\mathcal{N}(0,I_d) and a query xq∼N(0,Id)x_q \sim\mathcal{N}(0,I_d), with

yi∣xi,w∼Bernoulli⁡(σ(βwTxi)),yq∣xq,w∼Bernoulli⁡(σ(βwTxq)),(1)y_i \mid x_i,w \sim\operatorname{Bernoulli}\left(\sigma(\beta w^{\mathsf{T}}x_i)\right), \qquad y_q \mid x_q,w \sim\operatorname{Bernoulli}\left(\sigma(\beta w^{\mathsf{T}}x_q)\right), \tag*{(1)}

where σ(t)=(1+e−t)−1\sigma(t) = (1+e^{-t})^{-1} is the sigmoid function.

Model and estimator. Following a standard sequence-embedding convention used in prior works [24, 28, 17], we embed each sequence as a matrix

Z=[x1⋯xℓxqy1⋯yℓ0]∈R(d+1)×(ℓ+1).Z = \begin{bmatrix} x_1 & \cdots& x_\ell& x_q \\ y_1 & \cdots& y_\ell& 0 \end{bmatrix} \in\mathbb{R}^{(d+1)\times(\ell+1)}.

The final zero is a placeholder for the query label yqy_q. We pass ZZ to a linear-attention operator and map the final, label-coordinate entry of the updated query column to a binary class probability. Specifically, writing zi=[xiT yi]Tz_i = [x_i^{\mathsf{T}}\ y_i]^{\mathsf{T}} and zq=[xqT 0]Tz_q = [x_q^{\mathsf{T}}\ 0]^{\mathsf{T}}, the query column updated by linear attention is

LA⁡Q,K,V(Z):,ℓ+1=zq+1ℓ∑i=1ℓ⟨Qzq,Kzi⟩Vzi.(2)\operatorname{LA}_{Q,K,V}(Z)_{:,\ell+1} = z_q + \frac{1}{\ell}\sum_{i=1}^{\ell}\langle Qz_q,Kz_i\rangle Vz_i. \tag*{(2)}

Here QQ, KK, V∈R(d+1)×(d+1)V \in\mathbb{R}^{(d+1)\times(d+1)} are the query, key, and value matrices, respectively, that parameterise linear attention. Since this is binary classification, the softmax depends only on the difference between the output logits. We use the final, label entry as the class-1 logit and fix the class-0 logit to zero,

rQ,K,V(Z)=[LA⁡Q,K,V(Z)]d+1,ℓ+1(3)r_{Q,K,V}(Z) = \left[\operatorname{LA}_{Q,K,V}(Z)\right]_{d+1,\ell+1} \tag*{(3)}
Out⁡(Z)=[softmax⁡(0,rQ,K,V(Z))]2=σ(rQ,K,V(Z)).(4)\operatorname{Out}(Z) = \left[\operatorname{softmax}(0,r_{Q,K,V}(Z))\right]_2 = \sigma(r_{Q,K,V}(Z)). \tag*{(4)}

Prior work on in-context linear regression has shown that linear attention admits a particularly clean reduced representation: by expanding (4) in terms of VV and QTKQ^{\mathsf{T}}K, not all components of these matrices contribute to learnable directions, and can be ignored without meaningfully changing the optimisation dynamics [28, 17]. We utilise this established reduction to simplify the output logit,

rQ,K,V(Z)≈xqT(Adℓ∑i=1ℓyixi+a1ℓ∑i=1ℓyi)(5)r_{Q,K,V}(Z) \approx x_q^{\mathsf{T}}\left(A\frac{d}{\ell}\sum_{i=1}^{\ell}y_i x_i+a\frac{1}{\ell}\sum_{i=1}^{\ell}y_i\right) \tag*{(5)}
A=1dVd+1,d+1(QTK)1:d,1:d,aT=Vd+1,d+1(QTK)1:d,d+1T.(6)A=\frac{1}{d}V_{d+1,d+1}(Q^{\mathsf{T}}K)_{1:d,1:d},\qquad a^{\mathsf{T}}=V_{d+1,d+1}(Q^{\mathsf{T}}K)^{\mathsf{T}}_{1:d,d+1}. \tag*{(6)}

We will later verify this by directly comparing our results for this reduced model to a fully parameterised, trained linear-attention model. We can write the reduced model more compactly by introducing the new parameter matrix Γ=[A a]∈Rd×(d+1)\Gamma=[A\ a]\in\mathbb{R}^{d\times(d+1)} and

rΓ(Z)=⟨Γ,H⟩,H=xq[vTc],v=dℓ∑i=1ℓyixi,c=1ℓ∑i=1ℓyi.(7)r_{\Gamma}(Z)=\langle\Gamma,H\rangle,\qquad H=x_q\begin{bmatrix}v^{\mathsf{T}}&c\end{bmatrix},\qquad v=\frac{d}{\ell}\sum_{i=1}^{\ell}y_i x_i,\quad c=\frac{1}{\ell}\sum_{i=1}^{\ell}y_i. \tag*{(7)}

Finally, applying softmax gives the class-probability estimator Out⁡Γ(Z)=σ(rΓ(Z))\operatorname{Out}_{\Gamma}(Z)=\sigma(r_{\Gamma}(Z)).

Optimal parameters given training batch. We consider a training batch with nn independent prompts, which yields nn independent feature matrices HμH_\mu (μ∈[n]\mu\in[n]) in the reduced logit rΓr_{\Gamma}. Write γ=vec⁡(Γ)\gamma=\operatorname{vec}(\Gamma) and hμ=vec⁡(Hμ)h_\mu=\operatorname{vec}(H_\mu) for their row-wise vectorisations in Rd(d+1)\mathbb{R}^{d(d+1)}. We use yμy_\mu as shorthand for the μth\mu^{\mathrm{th}} sequence’s query label yqy_q, and fit the reduced model by regularised Bernoulli negative log-likelihood:

γ^=arg min⁡γ{1n∑μ=1n[L(γThμ)−yμγThμ]+λd2∥γ∥2},L(t)=log⁡(1+et).(8)\widehat{\gamma}=\underset{\gamma}{\operatorname{arg\,min}}\left\{\frac{1}{n}\sum_{\mu=1}^{n}\left[L(\gamma^{\mathsf{T}}h_\mu)-y_\mu\gamma^{\mathsf{T}}h_\mu\right]+\frac{\lambda d}{2}\|\gamma\|^{2}\right\},\qquad L(t)=\log(1+e^t). \tag*{(8)}

The choice of λd\lambda d scaling ensures that the regularisation is applied evenly and consistently across dimensions, as measured by comparison to the empirical Hessian trace: the average Hessian eigenvalue grows with dd and so without this normalisation, the effective regularisation would be zero at large dd.

Asymptotic assumptions. We study the proportional limit n,ℓ,d→∞n,\ell,d\to\infty with constant

τ:=nd2,αtrain:=ℓd.\tau:=\frac{n}{d^2},\qquad\alpha_{\mathrm{train}}:=\frac{\ell}{d}.

High-dimensional characterisation

For the fitted, data-dependent parameters Γ^=[A∗ a∗]\widehat{\Gamma}=[A^*\ a^*], define the empirical order parameters

a^1=tr⁡(A∗),a^2=d∥A∗∥F2,a^0=∥a∗∥2.(9)\widehat{a}_1=\operatorname{tr}(A^*),\qquad\widehat{a}_2=d\|A^*\|_F^2,\qquad\widehat{a}_0=\|a^*\|^2. \tag*{(9)}

We will derive limiting deterministic values for these random parameters. The parameter a^0\widehat{a}_0 measures the strength of the vector component of γ^\widehat{\gamma}. For the other two, note that

a^2−a^12=d∥A∗∥F2−(tr⁡A∗)2=d∥A∗−tr⁡(A∗)dId∥F2≥0.\widehat{a}_2-\widehat{a}_1^2=d\|A^*\|_F^2-(\operatorname{tr}A^*)^2=d\left\|A^*-\frac{\operatorname{tr}(A^*)}{d}I_d\right\|_F^2\geq0.

This quantity is minimised at A∗∝IdA^*\propto I_d, so it measures the squared distance of A∗A^* from isotropy. We aim to derive a statistically equivalent expression for the test logit, where htesth_{\mathrm{test}} is drawn fresh from the distribution described above, and the optimal parameters γ^\widehat{\gamma} are set from a finite training set of sequences as above. We highlight that this will provide richer phenomenology than an analysis of the population optimal parameters, which we begin with to provide intuition.

Population limits

Consider Γpop=[Apop∗ apop∗]\Gamma_{\mathrm{pop}}=[A_{\mathrm{pop}}^{*}\ a_{\mathrm{pop}}^{*}] and γpop=vec⁡(Γpop)\gamma_{\mathrm{pop}}=\operatorname{vec}(\Gamma_{\mathrm{pop}}) defined by

γpop=arg⁡min⁡γ{Eh,yq[L(γ⊤h)−yqγ⊤h]+λd2∥γ∥2}=arg⁡min⁡γLpop(γ).(10)\gamma_{\mathrm{pop}}=\underset{\gamma}{\arg\min}\left\{\mathbb{E}_{h,y_q}\left[L(\gamma^{\top}h)-y_q\gamma^{\top}h\right]+\frac{\lambda d}{2}\lVert\gamma\rVert^{2}\right\}=\underset{\gamma}{\arg\min}\mathcal{L}_{\mathrm{pop}}(\gamma). \tag*{(10)}

For λ>0\lambda>0, this objective is strictly convex in γ\gamma and therefore has a unique minimiser. The linear features w⊤xw^{\top}x are rotationally invariant, since (Ow)⊤(Ox)=w⊤x(Ow)^{\top}(Ox)=w^{\top}x for every orthogonal OO. The structure of the linear-attention estimator then gives

Lpop(vec⁡([A a]))=Lpop(vec⁡([OAO⊤ Oa]))\mathcal{L}_{\mathrm{pop}}\left(\operatorname{vec}([A\ a])\right)=\mathcal{L}_{\mathrm{pop}}\left(\operatorname{vec}([OAO^{\top}\ Oa])\right)

for every orthogonal OO. Uniqueness of the population solution therefore implies Apop∗∝IdA_{\mathrm{pop}}^{*}\propto I_d and apop∗=0a_{\mathrm{pop}}^{*}=0. Thus isotropy emerges as τ→∞\tau\to\infty, whereas the finite-sample result can retain an anisotropic contribution.

We can separately consider the long-context limit. Holding nn and dd fixed, take ℓ→∞\ell\to\infty. Then

1dν=1ℓ∑i=1ℓyixi⟶Cβw,c=1ℓ∑i=1ℓyi⟶12.(11)\frac{1}{d}\nu=\frac{1}{\ell}\sum_{i=1}^{\ell}y_ix_i\longrightarrow C_{\beta}w,\qquad c=\frac{1}{\ell}\sum_{i=1}^{\ell}y_i\longrightarrow\frac{1}{2}. \tag*{(11)}

where Cβ:=EG∼N(0,1)[Gσ(βG)]=βE[σ′(βG)]C_{\beta}:=\mathbb{E}_{G\sim\mathcal{N}(0,1)}[G\sigma(\beta G)]=\beta\mathbb{E}[\sigma'(\beta G)] is the first Hermite coefficient of the sigmoid activation. Thus the reduced-model logit becomes

rΓ(Z)⟶dCβxq⊤Aw+12xq⊤a.(12)r_{\Gamma}(Z)\longrightarrow dC_{\beta}x_q^{\top}Aw+\frac{1}{2}x_q^{\top}a. \tag*{(12)}

We see that these two limits remove different sources of randomness. The large-nn limit removes randomness from finite-sequence anisotropy, while the long-context limit removes randomness due to misestimation of the task in each sequence. Only in the jointly long-context, population-training limit do we see both of these effects disappearing; in the ridgeless case, this amounts to a recovery of the Bayes logit r(Z)→βGqr(Z)\to\beta G_q for Gq∼N(0,1)G_q\sim\mathcal{N}(0,1). We will see such different sources of randomness in the finite-sample calculation below.

Finite-sample results: order parameters

We derive an equivalent distribution for the test logit, using fitted parameters γ^=vec⁡(Γ^)\widehat{\gamma}=\operatorname{vec}(\widehat{\Gamma}). The full derivation and its assumptions are given in Appendix B. Schematically, we use a cavity approach [10]: we exclude one of the nn prompts from the loss and study the effect of this omission on the fitted parameters. In particular, we study the deterministic limits a1a_1, a2a_2, and a0a_0 of the empirical order parameters (a^1,a^2,a^0)(\widehat{a}_1,\widehat{a}_2,\widehat{a}_0), which characterise properties of the optimised weights γ^\widehat{\gamma}.

Result 1: Self-consistency equations for order parameters

The order parameters are determined implicitly as follows. Fix αtrain\alpha_{\mathrm{train}}, τ\tau, β\beta and λ\lambda. For any candidate pair (a1,a2)(a_1,a_2) such that a2≥a12a_2\ge a_1^2, draw independent GqG_q, GtrG_{\mathrm{tr}}, G⊥∼N(0,1)G_{\perp}\sim\mathcal{N}(0,1) and then draw from the label distribution Y∣Gq∼Bernoulli⁡(σ(βGq))Y\mid G_q\sim\operatorname{Bernoulli}(\sigma(\beta G_q)). Define Cβ=Eg∼N(0,1)[gσ(βg)]C_{\beta}=\mathbb{E}_{g\sim\mathcal{N}(0,1)}[g\sigma(\beta g)], Δ=Cβ2+1/(2αtrain)\Delta=C_{\beta}^{2}+1/(2\alpha_{\mathrm{train}}). Use the candidate order parameters to form the trained logit RsR_s as the unique solution of

Rs+s(σ(Rs)−Y)=a1CβGq+a12αtrainGtr+(a2−a12)Δ G⊥.(13)R_s+s\bigl(\sigma(R_s)-Y\bigr)=a_1C_{\beta}G_q+\frac{a_1}{\sqrt{2\alpha_{\mathrm{train}}}}G_{\mathrm{tr}}+\sqrt{(a_2-a_1^2)\Delta}\,G_{\perp}. \tag*{(13)}

Define mean response χ(s)\chi(s) and susceptibility ss jointly by

χ(s)≡E[11+sσ′(Rs)],χ(s)−λΔs=1−1τ.(14)\chi(s)\equiv\mathbb{E}\left[\frac{1}{1+s\sigma'(R_s)}\right],\qquad\chi(s)-\frac{\lambda}{\Delta}s=1-\frac{1}{\tau}. \tag*{(14)}

Then for positive ss, the scalars a1a_1 and a2a_2 are desired solutions when

a1=E[Rs(CβGq+Gtr/2αtrain)]Δ+sλ,a2=E[Rs2]−Δ(1−χ)a12−sλa12Δχ+sλ.(15)a_1=\frac{\mathbb{E}\left[R_s\left(C_{\beta}G_q+G_{\mathrm{tr}}/\sqrt{2\alpha_{\mathrm{train}}}\right)\right]}{\Delta+s\lambda},\qquad a_2=\frac{\mathbb{E}[R_s^2]-\Delta(1-\chi)a_1^2-s\lambda a_1^2}{\Delta\chi+s\lambda}. \tag*{(15)}

These self-consistently determined scalars characterise the behaviour of the test logit R=rΓ^(Znew)R = r_{\widehat{\Gamma}}(Z_{\mathrm{new}}) of a fresh prompt ZnewZ_{\mathrm{new}}, as given by the following main result. Before proceeding, we need to be careful when discussing the fixed point solutions a1a_1 and a2a_2 for a given data configuration determined by αtrain\alpha_{\mathrm{train}}, τ\tau, β\beta and λ\lambda, as it is not clear if such finite solutions exist. This is a well-known problem in logistic regression in the absence of regularisation ([7]).

Simply stated, if nn data points in dd dimensions have binary labels such that the two classes are linearly separable (i.e., by a hyperplane), then there is no finite maximum likelihood estimator: the likelihood can be increased by increasing the norm of the classifier weights without bound. If we assign independent random binary labels 0 and 1 with probability 1/21/2 to nn dd-dimensional points in general position, separability holds with probability tending to 1 as n,d→∞n,d \to\infty if n/d<2n/d < 2 ([9, 11]), and thus MLE exists with high probability if n/d>2n/d > 2. However, logistic regression makes it more difficult to determine the separability threshold as now the labels are no longer uniform, but themselves depend on the data through w⊤xw^{\top}x. Candes and Sur [7] and later Koriyama and Bellec [14] show that there is a relationship between the effective signal strength and the transition value of n/dn/d. The zero-signal case corresponds to the Cover transition above where the critical value of n/dn/d is 2.

Result 2: Ridgeless solution existence boundary

A finite-norm optimiser Γ^\widehat{\Gamma} exists with high probability for τ>τc\tau> \tau_c, where τc\tau_c is defined by

τc−1=inf⁡t∈RE[max⁡(0,G+tU)2(1−σ(βGq))+min⁡(0,G+tU)2σ(βGq)](16)\tau_c^{-1} = \inf_{t \in\mathbb{R}} \mathbb{E}\left[\max(0,G+tU)^2(1-\sigma(\beta G_q))+\min(0,G+tU)^2\sigma(\beta G_q)\right] \tag*{(16)}

for G,Gq,Gtr∼i.i.d.N(0,1)G,G_q,G_{\mathrm{tr}} \mathrel{\overset{\mathrm{i.i.d.}}{\sim}} \mathcal{N}(0,1) and U=(CβGq+Gtr/2αtrain)/ΔU = (C_\beta G_q + G_{\mathrm{tr}}/\sqrt{2\alpha_{\mathrm{train}}})/\sqrt{\Delta}.

We expect a similar phenomenon to occur in the ridgeless case of our theory; we have formalised this intuition in Result 2; see Appendix § 11 for an informal argument. Here the correct order parameter instead is n/(d(d+1))≈n/d2=τn/(d(d+1)) \approx n/d^2 = \tau, as our estimator takes nn samples (nn sequences) of features hh in d(d+1)d(d+1) dimensions. The zero-signal case would correspond to each of the nn query labels yqy_q being chosen uniformly at random, and then the MLE should exist for τ>2\tau> 2. Increasing β\beta, or increasing αtrain\alpha_{\mathrm{train}} so that the context more accurately represents its latent task, should increase the transition value away from 2. Indeed, empirically, we find a very good match between the location of empirical error blowup and the above predicted τc\tau_c, as seen by Figure 2. Note that τc\tau_c depends on both β\beta and αtrain\alpha_{\mathrm{train}}, as will be discussed below (see Figure 5).

Figure 5. Heatmap of critical τc\tau_c against α\alpha and β\beta.

Finite-sample results: test logit and test error

Finally, we may use the self-consistency equations in Result 1 to characterise γ^\widehat{\gamma}, and to determine the ICL test error. To allow for different context length at testing time, we introduce αtest=ℓtest/d\alpha_{\mathrm{test}} = \ell_{\mathrm{test}}/d.

Result 3: Characterisation of logit distribution

Fix αtrain\alpha_{\mathrm{train}}, τ\tau, β\beta, and λ\lambda. Sample Gaussians Gq,Gvar∼i.i.d.N(0,1)G_q,G_{\mathrm{var}} \sim_{\mathrm{i.i.d.}} \mathcal{N}(0,1). Then, assuming the empirical order parameters of the fitted Γ^\widehat{\Gamma} concentrate to finite values, their limiting behaviour is

(a^1,a^2,a^0)≈(a1,a2,0).(17)(\widehat{a}_1,\widehat{a}_2,\widehat{a}_0) \approx(a_1,a_2,0). \tag*{(17)}

Here a1a_1 and a2a_2 are the deterministic self-consistent solutions given by Result 1. Further, the test logit R=rΓ^(Znew)R = r_{\widehat{\Gamma}}(Z_{\mathrm{new}}) has marginal distribution given by

true query target yq∼Bernoulli⁡(σ(βGq))(18)\text{true query target } y_q \sim\operatorname{Bernoulli}(\sigma(\beta G_q)) \tag*{(18)}
predicted query logit R=a1CβGq+Gvara22αtest+(a2−a12)Cβ2.(19)\text{predicted query logit } R = a_1 C_\beta G_q + G_{\mathrm{var}}\sqrt{\frac{a_2}{2\alpha_{\mathrm{test}}}+(a_2-a_1^2)C_\beta^2}. \tag*{(19)}

The lack of a0a_0 in the final logit equation (i.e. a^0≈0\widehat{a}_0 \approx0) is due to the isotropy and mean-0 properties of the data, as well as the fact that this corresponding block in the predictor, a⊤xq/2a^{\top}x_q/2, contains no task information.

We provide empirical verification of this result in Figure 1 for a range of data parameters. Note that both the theoretical and empirical distributions tend towards the true logit distribution as αtrain\alpha_{\mathrm{train}} and τ\tau increase, as expected from the population analysis.

Figure 1. The distribution of empirical htestγ⋆h_{\mathrm{test}}\gamma^{\star} matches our derived distribution RR. The ridgeless theory predicts recovery of the true logit distribution as αtrain,τ→∞\alpha_{\mathrm{train}},\tau\to\infty. Increasing τ\tau (right-hand plots) reduces variance, but alignment with GtrueG_{\mathrm{true}} requires both variance reduction and a1Cβ/β→1a_1 C_\beta/\beta\to1. For all, β=1\beta= 1, λ=10−6\lambda= 10^{-6}, d=32d = 32, αtest=αtrain\alpha_{\mathrm{test}} = \alpha_{\mathrm{train}}.

This characterisation of the joint distribution of the latent and predicted logits makes it easy to compute the limiting cross-entropy loss and classification error, verified in Figures 2 and Figure 3.

Figure 3. Simulation versus theory for classification error. We can compare to random guessing error 1/21/2, and Bayes error 1−E[σ(β∣Gq∣)]1 - \mathbb{E}[\sigma(\beta|G_q|)]. For short contexts, the model effectively guesses, but nears the Bayes floor as context length increases. d=32d = 32, αtrain=αtest\alpha_{\mathrm{train}} = \alpha_{\mathrm{test}}, τ=10\tau= 10, β=1\beta= 1, λ=10−8\lambda= 10^{-8}.

Result 4: Error formulas The cross entropy test loss is given by

ECE=EGq,Gvar[L(R)−σ(βGq)R](20)\mathcal{E}_{\mathrm{CE}} = \mathbb{E}_{G_q,G_{\mathrm{var}}}\left[L(R)-\sigma(\beta G_q)R\right] \tag*{(20)}

and the classification error is given by

Eclass=P(1{R≥0}≠Y)=EGq[σ(βGq)(1−ϕ)+(1−σ(βGq))ϕ](21)\mathcal{E}_{\mathrm{class}} = \mathbb{P}\left(1\{R \ge0\} \ne Y\right) = \mathbb{E}_{G_q}\left[\sigma(\beta G_q)(1-\phi)+(1-\sigma(\beta G_q))\phi\right] \tag*{(21)}

where Φ\Phi is the standard normal CDF and ϕ=Φ(a1CβGq/V)\phi= \Phi\left(a_1 C_\beta G_q/\sqrt{V}\right), V=a2/(2αtest)+(a2−a12)Cβ2V = a_2/(2\alpha_{\mathrm{test}}) + (a_2-a_1^2)C_\beta^2.

Findings

We highlight several interpretable implications of these results.

Effect of test-time context length. First note that αtest\alpha_{\mathrm{test}} only appears explicitly in VV; a1a_1 and a2a_2 do not depend on αtest\alpha_{\mathrm{test}}. As αtest\alpha_{\mathrm{test}} increases, this contribution to non-signal variance will vanish and ICL error will strictly decrease, both as measured by cross-entropy loss or by classification error (see Appendix § 12 for proof). This is an artifact of our choice of linear attention architecture, which explicitly averages its inputs through the 1/ℓ1/\ell term that appears in the architecture definition (2); thus, longer test contexts always reduce noise and improve error [16]. Whether or not this particular phenomenon generalises to other architectures is a question for future work.

Figure 2a. Ridgeless curve (λ=0\lambda= 0)

Figure 2b. Non-zero ridge curve (λ=0.001\lambda= 0.001)

fig:2: Empirical simulation refers to directly sampling nn sequences of length ℓ\ell, computing γ^\widehat{\gamma}, and evaluating this parameter matrix on freshly sampled sequences. This is compared to the theoretical prediction in Result 4. The critical ratio is given by eq. (16). Here d=64d = 64, αtrain=4=αtest\alpha_{\mathrm{train}} = 4 = \alpha_{\mathrm{test}}, β=1\beta= 1. In (a), the empirical simulations take λ=10−8\lambda= 10^{-8}.

Calibration and noise. Under the marginal laws (18) and (19), the target logit is Gtrue=βGqG_{\mathrm{true}} = \beta G_q and the predicted logit is

R=a1CββGtrue+VGvar,V=a22αtest+(a2−a12)Cβ2,Gvar∼N(0,1).R = \frac{a_1 C_\beta}{\beta}G_{\mathrm{true}} + \sqrt{V}G_{\mathrm{var}}, \qquad V = \frac{a_2}{2\alpha_{\mathrm{test}}} + (a_2-a_1^2)C_\beta^2,\qquad G_{\mathrm{var}} \sim\mathcal{N}(0,1).

By Result 3, this logit expression makes the various sources of error explicit: the scaling coefficient a1Cβ/βa_1C_\beta/\beta in front of GtrueG_{\mathrm{true}}, the variance due to test context length αtest\alpha_{\mathrm{test}}, and the variance due to anisotropy a2−a12a_2-a_1^2. While the factor a1Cβ/βa_1C_\beta/\beta might initially appear to be a direct measure of “calibration” or alignment between our prediction and the true label, we must realise that each of these factors interact nontrivially. To see this, write the conditional distribution of the target in terms of the prediction, namely,

Gtrue∣R∼N(a1βCβa12Cβ2+VR,β2a12Cβ2+VV).G_{\mathrm{true}} \mid R \sim\mathcal{N}\left(\frac{a_1\beta C_\beta}{a_1^2C_\beta^2+V}R,\frac{\beta^2}{a_1^2C_\beta^2+V}V\right).

This immediately allows us to write the conditional class probability as

p(R):=P(Y=1∣R)=EZ∼N(0,1)[σ(mR+vZ)],m=a1βCβa12Cβ2+V,v2=β2a12Cβ2+VV.(22)p(R) := \mathbb{P}(Y = 1 \mid R) = \mathbb{E}_{Z\sim\mathcal{N}(0,1)}[\sigma(mR+vZ)], \qquad m = \frac{a_1\beta C_\beta}{a_1^2C_\beta^2+V}, \qquad v^2 = \frac{\beta^2}{a_1^2C_\beta^2+V}V. \tag*{(22)}

Recall the model predicts the probability of outcome 1 as σ(R)\sigma(R), where the actual probability is p(R)p(R). This immediately gives us a clean formulation of calibration: the model is calibrated when p(R)=σ(R)p(R) = \sigma(R). For R>0R > 0 (i.e. the model is skewed towards 1), if σ(R)<p(R)\sigma(R) < p(R) then the model is underconfident, while if σ(R)>p(R)\sigma(R) > p(R) the model is overconfident. The reverse is true for R<0R < 0.

Figure 4 demonstrates the effect of data finiteness, on both anisotropy and calibration. We indeed recover the population intuition that additional pretraining data induces isotropy, as a2−a12→0a_2 - a_1^2 \to0 as τ→∞\tau\to\infty. We see this occurs roughly at a rate of τ−1\tau^{-1}, although this remains unproven. Additionally, we see the nontrivial interactions of context length and pretraining sequences on calibration in Figure 4(b) and Figure 4(c). In particular, while increasing τ\tau reduces error due to variance, it does not necessarily produce better calibration. Depending on the data configuration, the model may instead move between underconfidence and overconfidence. These nontrivial nonmonotonicities deserve further exploration, which we leave to future work.

Figure 4. Effects of data parameters αtrain\alpha_{\mathrm{train}} and τ\tau on anisotropy (a) and calibration (b),(c). We compute a1a_1, a2a_2 (and correspondingly, mm, vv) using Result 1. In (b),(c), RR is taken simply as a real-valued variable and the function p(R)p(R) is computed by numerically taking the expectation in (22). In all plots we take αtest=108\alpha_{\mathrm{test}} = 10^8 (effectively infinite) to isolate the effects of αtrain\alpha_{\mathrm{train}} and τ\tau; all labels α\alpha refer to αtrain\alpha_{\mathrm{train}}. For all, λ=0\lambda= 0 and β=1\beta= 1. For (b) αtrain=4\alpha_{\mathrm{train}} = 4. For (c) τ=20\tau= 20.

Location of critical batch size. Figure 5 maps the predicted dependence of τc\tau_c on context length αtrain\alpha_{\mathrm{train}} and sampling inverse temperature β\beta. We see that increasing either αtrain\alpha_{\mathrm{train}} or β\beta will increase the critical ratio τc\tau_c. This can be understood from prior intuition: increasing either αtrain\alpha_{\mathrm{train}} or β\beta will increase the "signal" of the features relative to the zero-signal (uniformly random yqsy_{qs}) case, thus making separability easier to achieve, and pushing the critical sample ratio away from 2.

Beyond the reduced model

It is important to characterise how well this model extends beyond the theoretical regime. Recall we began with the fully-parameterised linear attention architecture in terms of K,Q,VK,Q,V matrices, and ultimately studied the reduced model in terms of parameters Γ\Gamma. Despite this modelling choice for the theory, the prediction in Result 3 also accurately describes the linear-attention architecture with fully trained K,Q,VK,Q,V matrices. This is shown in Figure 6, where we see close agreement between the theory logit RR and the trained linear attention output distributions, with small deviation in the tails for small α\alpha and τ\tau.

Figure 6. Similarly to Figure 1, we compare the theory to full-parameter linear attention, namely, we train the full K,Q,VK,Q,V matrices. Here we plot a quantile-quantile comparison of the model’s output logit on new prompt matrices ZZ against the theory prediction RR and the true latent βGq\beta G_q. In all plots, d=16d=16, λ=10−6\lambda=10^{-6}, β=1\beta=1. Regularisation is applied to ∥K∥F2+∥Q∥F2+∥V∥F2\lVert K\rVert_F^2+\lVert Q\rVert_F^2+\lVert V\rVert_F^2.

We do not expect the exact theoretical characterisation to transfer directly to other architectures. In particular, conclusions about test-time context length likely depend on the explicit averaging structure of linear attention. Regardless,

Figure 7 shows that the trained softmax-attention model exhibits some qualitatively similar behaviour. We include the linear-attention theory distribution strictly as a reference; it is not a theoretical prediction for the softmax model. Across all four settings, the softmax logits have noticeably lower variance than both the linear-attention theory prediction and the teacher logits. Increasing the context ratio α\alpha substantially broadens the softmax distribution and improves its alignment with the teacher distribution. The effect of increasing the task ratio τ\tau is less straightforward: it reduces the softmax-logit variance in these experiments rather than producing uniformly closer agreement with the teacher. The softmax model achieves lower cross-entropy than the linear-attention theory reference for τ=5\tau= 5, whereas the theory reference performs better for τ=20\tau= 20. These results suggest potentially interesting differences in calibration and confidence between the two architectures, which we leave for future investigation.

Figure 7. An analogous comparison to Figure 1, but the logits here are from a trained transformer-style softmax attention block. In particular, we use standard scaled dot-product softmax attention with fully trainable query QQ, key KK, value VV, and output OO weights. We initialise these at identity to improve training dynamics. The model is trained for 100 epochs with AdamW with weight decay 0.1 and early stopping. We set d=32d=32 and β=4\beta=4.

Conclusion

We have characterised the high-dimensional asymptotics of in-context binary classification, using a reduced linear-attention model with a softmax readout. The resulting joint law of the latent and predicted logits separates three distinct effects of data on ICL performance: scaling of the teacher-aligned signal, noise from finite test contexts, and anisotropy induced by finitely many pretraining tasks. This decomposition yields explicit predictions for cross-entropy loss, classification error. Furthermore, we identify the separability boundary beyond which the ridgeless logistic estimator has no finite solution. For all our results, finite-dimensional simulations closely match these predictions, and fully trained linear-attention models resemble closely our predicted logit distribution.

Our analysis also shows that improvements in loss and calibration need not match. Longer test contexts monotonically remove a source of noise in the reduced architecture, whereas increasing the number of pretraining tasks removes anisotropic noise without necessarily improving calibration. Consequently, calibration may vary nonmonotonically even as predictive error improves. Our theory and its predictions are specific to the reduced linear-attention setting. We provide softmax-attention experiments as qualitative evidence beyond that regime. Extending the calculation to richer architectures is a natural direction for future work.

Acknowledgments and Disclosure of Funding

We thank Luca Pesce for helpful discussions. A.R. was supported by the Alumni Sponsored Internship Program (ASIP) of Williams College. M.L. is supported by a Graduate Fellowship from the Kempner Institute for the Study of Natural and Artificial Intelligence. Y.M.L. gratefully acknowledges support from a Harvard College Professorship, the Harvard FAS Dean’s Fund for Promising Scholarship, and DARPA grant DIAL-FP-038. J.Z.-V. was supported by a Junior Fellowship from the Harvard Society of Fellows. C.P. is supported by an NSF CAREER Award (IIS-2239780), DARPA grants DIAL-FP-038 and AIQ-HR00112520041, and the Simons Collaboration on the Physics of Learning and Neural Computation. This work has been made possible in part by a gift from the Chan Zuckerberg Initiative Foundation to establish the Kempner Institute for the Study of Natural and Artificial Intelligence.

AI Use Statement

We used generative AI tools for various steps throughout the research and writing processes. We describe this as follows.

  • Synthetic dataset generation. No.

  • Develop theoretical models. No.

  • Formulate mathematical claims. AI was used to help state our formulas more clearly in the document; it was not used to formulate the actual mathematics.

  • Provide critical components for proofs. No.

  • Assist in the writing of proofs. Yes. GPT 5.6 and 6 were used to verify and check our proofs and formulas; GPT 6 suggested a simplification of an expression in Appendix § 10 such that (14) does not involve the inverse Hessian trace explicitly, which helps with numerical stability.

  • Propose or refine hypotheses. No.

  • Design research methodology. No.

  • Provide feedback on research methodology. Yes, namely verification of our proof and method.

  • Implement methods. Yes. GPT 5.6 and GPT 6 were used to generate substantial blocks of the code, particularly for simulations of the theory; all implementations and code were commented, rewritten, and verified by the lead authors. The most significant use of AI to generate code was for the final softmax experiments, which we offer as a preliminary investigation.

  • Assist with translation. No.

  • Clean and reformat datasets. No.

  • Support data analysis. No.

  • Interpret results. AI was used in the writing process, with specific prompts, where we asked specific questions in order to improve the clarity, readability, and logical flow of our results. Some of this naturally includes interpretation. Additionally, upon a review pass of the manuscript, GPT 5.6 suggested the comparison of p(R)p(R) (given by equation (22)) with σ(R)\sigma(R). All additional interpretation and experiment design were then done by the authors.

  • Brainstorming. Yes. The conception of this paper occurred through a brainstorming session between the senior author and an agent model. In particular, this included the suggestion that the softmax-readout linear attention architecture might be analysable at the population level, and suggested the initial rotational symmetry approach.

AI was not used to draft the manuscript or generate the literature review; it was used to polish prose and for suggestions on overall presentation. We have reviewed all AI-assisted work. We take responsibility for the final content of this work, including text, claims, or artefacts produced with the aid of generative AI.

Numerics and code

Code and additional numerical details will be made available on GitHub.

Derivation of the cavity result

The following provides a derivation of Result 1 and Result 3 together. Note that Result 4 follows immediately from 3.

Proof. We will decompose the proof into steps.

Step 1. Proximal equation. Write fy(z)=L(z)−yzf_y(z)=L(z)-yz and let γ^[ν]\widehat{\gamma}_{[\nu]} minimise the objective with prompt ν\nu removed. Let

H[ν]=1n∑μ≠νσ′(Rμ,[ν])hμhμT+λdId(d+1),Rμ,[ν]=hμTγ^[ν].(23)\mathcal{H}_{[\nu]}=\frac{1}{n}\sum_{\mu\ne\nu}\sigma'(R_{\mu,[\nu]})h_\mu h_\mu^{\mathsf{T}}+\lambda d I_{d(d+1)},\qquad R_{\mu,[\nu]}=h_\mu^{\mathsf{T}}\widehat{\gamma}_{[\nu]}. \tag*{(23)}

A quadratic expansion about γ^[ν]\widehat{\gamma}_{[\nu]} gives

γ^≈arg min⁡γ{1nfyν(hνTγ)+12(γ−γ^[ν])TH[ν](γ−γ^[ν])}.(24)\widehat{\gamma}\approx\underset{\gamma}{\operatorname{arg\,min}}\left\{\frac{1}{n}f_{y_\nu}(h_\nu^{\mathsf{T}}\gamma)+\frac{1}{2}(\gamma-\widehat{\gamma}_{[\nu]})^{\mathsf{T}}\mathcal{H}_{[\nu]}(\gamma-\widehat{\gamma}_{[\nu]})\right\}. \tag*{(24)}

Minimizing at fixed z=hνTγz=h_\nu^{\mathsf{T}}\gamma yields

Rν=prox⁡sνfyν(Rν,[ν]),Rν,[ν]=Rν+sν(σ(Rν)−yν),sν=1nhνTH[ν]−1hν.(25)R_\nu=\operatorname{prox}_{s_\nu f_{y_\nu}}(R_{\nu,[\nu]}),\qquad R_{\nu,[\nu]}=R_\nu+s_\nu(\sigma(R_\nu)-y_\nu),\qquad s_\nu=\frac{1}{n}h_\nu^{\mathsf{T}}\mathcal{H}_{[\nu]}^{-1}h_\nu. \tag*{(25)}

Logit convention. Before taking the high-dimensional limit, Rμ:=hμTγ^R_\mu:=h_\mu^{\mathsf{T}}\widehat{\gamma} denotes the full-sample fitted logit, while Rμ,[ν]:=hμTγ^[ν]R_{\mu,[\nu]}:=h_\mu^{\mathsf{T}}\widehat{\gamma}_{[\nu]} denotes the logit of prompt μ\mu when prompt ν\nu is omitted from training. In particular, Rμ,[μ]R_{\mu,[\mu]} is the cavity logit for the held-out prompt. Only after invoking concentration and exchangeability do we identify the limiting joint law of (Rμ,[μ],Rμ,yμ)(R_{\mu,[\mu]},R_\mu,y_\mu) with (Rloo,Rs,Y)(R_{\mathrm{loo}},R_s,Y).

Step 2. Hessian prefactor. We are interested in writing a characterisation for the left-out Hessian prefactor terms that appear in the proximal equation

sν:=1nhνTH[ν]−1hν.s_\nu:=\frac{1}{n}h_\nu^{\mathsf{T}}\mathcal{H}_{[\nu]}^{-1}h_\nu.

This is a heuristic argument; we mark the assumptions used below explicitly. We have

L[ν]=1n∑μ≠ν(L(γThμ)−yμγThμ)+λd2∥γ∥2\mathcal{L}_{[\nu]}=\frac{1}{n}\sum_{\mu\ne\nu}\left(L(\gamma^{\mathsf{T}}h_\mu)-y_\mu\gamma^{\mathsf{T}}h_\mu\right)+\frac{\lambda d}{2}\lVert\gamma\rVert^2
dL[ν]dγ=1n∑μ≠ν(L′(γThμ)−yμ)hμ+λdγ\frac{\mathrm{d}\mathcal{L}_{[\nu]}}{\mathrm{d}\gamma}=\frac{1}{n}\sum_{\mu\ne\nu}\left(L'(\gamma^{\mathsf{T}}h_\mu)-y_\mu\right)h_\mu+\lambda d\gamma
H[ν]=1n∑μ≠νL′′(Rμ,[ν])hμhμT+λdId(d+1)\mathcal{H}_{[\nu]}=\frac{1}{n}\sum_{\mu\ne\nu}L''(R_{\mu,[\nu]})h_\mu h_\mu^{\mathsf{T}}+\lambda d I_{d(d+1)}

As in the quadratic expansion, we evaluate

H[ν]:=d2L[ν]dγ2(γ=γ[ν]∗).\mathcal{H}_{[\nu]}:=\frac{\mathrm{d}^2\mathcal{L}_{[\nu]}}{\mathrm{d}\gamma^2}\left(\gamma=\gamma^*_{[\nu]}\right).

Eventually we will compare this to the Hessian of the full loss. We have two choices of where to evaluate such an object, at γ=γ∗\gamma=\gamma^* or at γ=γ[ν]∗\gamma=\gamma^*_{[\nu]}. In the latter, they differ by a rank-one term

H(γ[ν]∗):=d2Ldγ2(γ=γ[ν]∗)=H[ν]+1nL′′(Rν,[ν])hνhνT.\mathcal{H}(\gamma^*_{[\nu]}):=\frac{\mathrm{d}^2\mathcal{L}}{\mathrm{d}\gamma^2}\left(\gamma=\gamma^*_{[\nu]}\right)=\mathcal{H}_{[\nu]}+\frac{1}{n}L''(R_{\nu,[\nu]})h_\nu h_\nu^{\mathsf{T}}.

For the former, we must bound Rμ−Rμ,[ν]R_\mu-R_{\mu,[\nu]} induced differences, as

H(γ∗):=d2Ldγ2(γ=γ∗)=H[ν]+1nL′′(Rν)hνhνT+1n∑μ≠ν(L′′(Rμ)−L′′(Rμ,[ν]))hμhμT.\mathcal{H}(\gamma^\ast):=\frac{\mathrm{d}^2\mathcal{L}}{\mathrm{d}\gamma^2}(\gamma=\gamma^\ast)=\mathcal{H}_{[\nu]}+\frac{1}{n}L^{\prime\prime}(R_\nu)h_\nu h_\nu^{\mathsf{T}}+\frac{1}{n}\sum_{\mu\ne\nu}\left(L^{\prime\prime}(R_\mu)-L^{\prime\prime}(R_{\mu,[\nu]})\right)h_\mu h_\mu^{\mathsf{T}}.

We assume, without proof, that the matrix remainder

1n∑μ≠ν(L′′(Rμ)−L′′(Rμ,[ν]))hμhμT\frac{1}{n}\sum_{\mu\ne\nu}\left(L^{\prime\prime}(R_\mu)-L^{\prime\prime}(R_{\mu,[\nu]})\right)h_\mu h_\mu^{\mathsf{T}}

can be neglected in the normalised inverse-Hessian quadratic forms and traces used below. Expand

H(γ∗)−1:=H−1≈(H[ν]+1nL′′(Rν)hνhνT)−1=H[ν]−1−1nL′′(Rν)1+L′′(Rν)sνH[ν]−1hνhνTH[ν]−1\begin{aligned} \mathcal{H}(\gamma^\ast)^{-1}:=\mathcal{H}^{-1}\approx\left(\mathcal{H}_{[\nu]}+\frac{1}{n}L^{\prime\prime}(R_\nu)h_\nu h_\nu^{\mathsf{T}}\right)^{-1} \\ &=\mathcal{H}_{[\nu]}^{-1}-\frac{1}{n}\frac{L^{\prime\prime}(R_\nu)}{1+L^{\prime\prime}(R_\nu)s_\nu}\mathcal{H}_{[\nu]}^{-1}h_\nu h_\nu^{\mathsf{T}}\mathcal{H}_{[\nu]}^{-1} \end{aligned}
so1nhνTH−1hν≈sν1+L′′(Rν)sν.\text{so}\qquad\frac{1}{n}h_\nu^{\mathsf{T}}\mathcal{H}^{-1}h_\nu\approx\frac{s_\nu}{1+L^{\prime\prime}(R_\nu)s_\nu}.

We have

I=H−1H=λdH−1+1n∑μL′′(Rμ)H−1hμhμTI=\mathcal{H}^{-1}\mathcal{H}=\lambda d\mathcal{H}^{-1}+\frac{1}{n}\sum_\mu L^{\prime\prime}(R_\mu)\mathcal{H}^{-1}h_\mu h_\mu^{\mathsf{T}}

and so

1n∑μ=1n11+L′′(Rμ)sμ−λdntr⁡(H−1)≈1−1τ.\frac{1}{n}\sum_{\mu=1}^{n}\frac{1}{1+L^{\prime\prime}(R_\mu)s_\mu}-\frac{\lambda d}{n}\operatorname{tr}\left(\mathcal{H}^{-1}\right)\approx1-\frac{1}{\tau}.

We can simplify the sμs_\mu quadratic forms as follows. Recall the structure of h=vec⁡(xtestuT)h=\operatorname{vec}(x_{\mathrm{test}}u^{\mathsf{T}}) and so for any matrix A∈Rd(d+1)×d(d+1)A\in\mathbb{R}^{d(d+1)\times d(d+1)}, we have

1nhTAh=1nxiuaAia,jbxjub.\frac{1}{n}h^{\mathsf{T}}Ah=\frac{1}{n}x_{i}u_{a}A_{ia,jb}x_{j}u_{b}.

The xxs are mean-zero, sub-Gaussian, with independent coordinates, and so if we write matrices Bij=uaAia,jbubB_{ij}=u_{a}A_{ia,jb}u_{b} then

1nhTAh≈1ntr⁡(BE[xxT])=1ntr⁡(B).\frac{1}{n}h^{\mathsf{T}}Ah\approx\frac{1}{n}\operatorname{tr}\left(B\mathbb{E}[xx^{\mathsf{T}}]\right)=\frac{1}{n}\operatorname{tr}(B).

For the uu terms, conditional on ww,

E[uT∣w]=[dCβwT  12]\mathbb{E}[u^{\mathsf{T}}\mid w]=\left[dC_\beta w^{\mathsf{T}}\ \ \frac{1}{2}\right]
E[uuT∣w]=[d2Cβ2wwT+dαtrain(12Id−Cβ2wwT)(dCβ2+Cβ2αtrain)w(dCβ2+Cβ2αtrain)wT14+14αtraind]\mathbb{E}\left[uu^{\mathsf{T}}\mid w\right]= \begin{bmatrix} d^2C_\beta^2ww^{\mathsf{T}}+\dfrac{d}{\alpha_{\mathrm{train}}}\left(\dfrac{1}{2}I_d-C_\beta^2ww^{\mathsf{T}}\right) & \left(\dfrac{dC_\beta}{2}+\dfrac{C_\beta}{2\alpha_{\mathrm{train}}}\right)w\\ \left(\dfrac{dC_\beta}{2}+\dfrac{C_\beta}{2\alpha_{\mathrm{train}}}\right)w^{\mathsf{T}} & \dfrac{1}{4}+\dfrac{1}{4\alpha_{\mathrm{train}}d} \end{bmatrix}

where

Cβ:=Eg∼N(0,1)[gσ(βg)].C_\beta:=\mathbb{E}_{g\sim\mathcal{N}(0,1)}[g\sigma(\beta g)].

Averaging over the ∥w∥=1\lVert w\rVert=1 spherically uniform task distribution gives

E[uT]=[0  12](26)\mathbb{E}[u^{\mathsf{T}}]=\left[0\ \ \frac{1}{2}\right] \tag*{(26)}
E[uuT]≈[d(Cβ2+12αtrain)Id00T14]=:Σβ(27)\mathbb{E}[uu^{\mathsf{T}}]\approx \begin{bmatrix} d\left(C_\beta^2+\dfrac{1}{2\alpha_{\mathrm{train}}}\right)I_d & 0\\ 0^{\mathsf{T}} & \dfrac{1}{4} \end{bmatrix} =:\Sigma_\beta \tag*{(27)}

For the leave-one-out inverse Hessians considered below, we assume

1nhTAh≈1ntr⁡(A(Id⊗Σβ)).\frac{1}{n}h^{\mathsf{T}}Ah \approx\frac{1}{n}\operatorname{tr}\left(A(I_d \otimes\Sigma_\beta)\right).

So we will write

sν≈1ntr⁡(H[ν]−1(Id⊗Σβ)).s_\nu\approx\frac{1}{n}\operatorname{tr}\left(\mathcal{H}_{[\nu]}^{-1}(I_d \otimes\Sigma_\beta)\right).

Now we assume that L,L[ν]\mathcal{L},\mathcal{L}_{[\nu]} are sufficiently well behaved so that the relevant normalised traces of the inverse Hessians at their respective minimisers are comparable, i.e.

1ntr⁡(H[ν]−1Σh)≈1ntr⁡(H−1Σh).\frac{1}{n}\operatorname{tr}\left(\mathcal{H}_{[\nu]}^{-1}\Sigma_h\right) \approx\frac{1}{n}\operatorname{tr}\left(\mathcal{H}^{-1}\Sigma_h\right).

Thus for Σh=Id⊗Σβ\Sigma_h = I_d \otimes\Sigma_\beta, we write

sν≈1ntr⁡(H[ν]−1Σh)≈1ntr⁡(H−1Σh):=s.s_\nu\approx\frac{1}{n}\operatorname{tr}\left(\mathcal{H}_{[\nu]}^{-1}\Sigma_h\right) \approx\frac{1}{n}\operatorname{tr}\left(\mathcal{H}^{-1}\Sigma_h\right) := s.

We further assume that this quantity concentrates to a deterministic scalar ss. We then have

1n∑μ=1n11+L′′(Rμ)s−λdntr⁡(H−1)=1−1τ.\frac{1}{n}\sum_{\mu=1}^{n}\frac{1}{1+L^{\prime\prime}(R_\mu)s}-\frac{\lambda d}{n}\operatorname{tr}\left(\mathcal{H}^{-1}\right)=1-\frac{1}{\tau}.

Estimating tr⁡(H−1)\operatorname{tr}\left(\mathcal{H}^{-1}\right) will be difficult and we wish to avoid it. For λ>0\lambda>0, we make the additional approximation, without proof, that the contribution of the final vector block of Σβ\Sigma_\beta to the normalised inverse-Hessian trace is asymptotically negligible, so that the main block dominates. Thus,

s≈1ntr⁡(H−1(Id⊗Σβ))≈dΔntr⁡(H−1).s \approx\frac{1}{n}\operatorname{tr}\left(\mathcal{H}^{-1}(I_d \otimes\Sigma_\beta)\right) \approx\frac{d\Delta}{n}\operatorname{tr}\left(\mathcal{H}^{-1}\right).

For λ=0\lambda=0, this approximation is not required, since the term involving tr⁡(H−1)\operatorname{tr}\left(\mathcal{H}^{-1}\right) in the preceding equation vanishes. To summarise, we have that

sν=1nhνTH[ν]−1hν≈ss_\nu=\frac{1}{n}h_\nu^{\mathsf{T}}\mathcal{H}_{[\nu]}^{-1}h_\nu\approx s

for deterministic scalar ss defined self-consistently by

1−1τ=E[11+L′′(Rs)s]−λΔs.1-\frac{1}{\tau}=\mathbb{E}\left[\frac{1}{1+L^{\prime\prime}(R_s)s}\right]-\frac{\lambda}{\Delta}s.

In the limit as λ→0\lambda\to0, we have the nicer ridgeless characterisation

1−1τ=E[11+L′′(Rs)s].1-\frac{1}{\tau}=\mathbb{E}\left[\frac{1}{1+L^{\prime\prime}(R_s)s}\right].

Step 3. Gaussian equivalent. We will construct a logit that is statistically equivalent to the left-out logits RlooR_{\mathrm{loo}}. To do this, we make a standard assumption commonly used in cavity arguments, that asymptotically there is no difference between hμTγ[μ]∗h_\mu^{\mathsf{T}}\gamma^*_{[\mu]} and hnewTγ∗h_{\mathrm{new}}^{\mathsf{T}}\gamma^*. Moreover, γ[μ]∗\gamma^*_{[\mu]} is independent of hμh_\mu, since prompt μ\mu is excluded from its training set. Here hnewh_{\mathrm{new}} is drawn from the same distribution as the training distribution, namely context length is still ℓ\ell and is not ℓtest\ell_{\mathrm{test}}. This distinction is important, as hnewTγ∗h_{\mathrm{new}}^{\mathsf{T}}\gamma^* here is not the test logit, which would describe sequences of length ℓtest\ell_{\mathrm{test}}. Thus we have that

Rloo=dxqT(A∗v+ca∗),v:=dℓ∑i=1ℓyixi,c:=1ℓ∑i=1ℓyi.R_{\mathrm{loo}}\mathrel{\overset{d}{=}}x_q^{\mathsf{T}}(A^*v+ca^*),\qquad v:=\frac{d}{\ell}\sum_{i=1}^{\ell}y_ix_i,\qquad c:=\frac{1}{\ell}\sum_{i=1}^{\ell}y_i.

Write

A∗=a^1dId+Aˉ∗,a^1:=tr⁡(A∗),tr⁡(Aˉ∗)=0.A^* = \frac{\hat a_1}{d}I_d+\bar A^*, \qquad\hat a_1 := \operatorname{tr}(A^*), \qquad\operatorname{tr}(\bar A^*)=0.

Then

Rloo=a^1dxqTv+xqTAˉ∗v+c xqTa∗.R_{\mathrm{loo}}=\frac{\hat a_1}{d}x_q^\mathsf{T}v+x_q^\mathsf{T}\bar A^*v+c\,x_q^\mathsf{T}a^*.

We analyse these three terms separately.

We make a standard cavity self-averaging assumption: conditional on the leave-one-out estimator, the relevant overlaps and quadratic forms of a fresh prompt concentrate around some deterministic limits. Since xqx_q is Gaussian and independent of context variables and the leave-one-out estimator, the terms below are conditionally jointly Gaussian. As their conditional covariances concentrate, their limiting joint law is derived by the corresponding covariance calculations below.

First, write

xq=Gqw+xperp,Gq:=xqTw∼N(0,1),xperp∼N(0,Id−wwT).x_q=G_qw+x_{\mathrm{perp}}, \qquad G_q:=x_q^\mathsf{T}w\sim\mathcal{N}(0,1), \qquad x_{\mathrm{perp}}\sim\mathcal{N}(0,I_d-ww^\mathsf{T}).

Conditional on ww, we have

E[v∣w]=dCβw\mathbb{E}[v\mid w]=dC_\beta w

and

Cov⁡(v∣w)=d2αtrainId−dCβ2αtrainwwT.\operatorname{Cov}(v\mid w)=\frac{d}{2\alpha_{\mathrm{train}}}I_d-\frac{dC_\beta^2}{\alpha_{\mathrm{train}}}ww^\mathsf{T}.

Consequently,

1dxqTv=CβGq+1dxqT(v−dCβw).\frac{1}{d}x_q^\mathsf{T}v=C_\beta G_q+\frac{1}{d}x_q^\mathsf{T}(v-dC_\beta w).

Using concentration of quadratic forms,

Var⁡(1dxqT(v−dCβw))≈12αtrain.\operatorname{Var}\left(\frac{1}{d}x_q^\mathsf{T}(v-dC_\beta w)\right)\approx\frac{1}{2\alpha_{\mathrm{train}}}.

Moreover, its covariance with GqG_q is asymptotically zero. Under the self-averaging assumption above, it results in

a^1dxqTv≈da^1CβGq+a^12αtrainGtr,\frac{\hat a_1}{d}x_q^\mathsf{T}v\mathrel{\overset{d}{\approx}}\hat a_1C_\beta G_q+\frac{\hat a_1}{\sqrt{2\alpha_{\mathrm{train}}}}G_{\mathrm{tr}},

where Gtr∼N(0,1)G_{\mathrm{tr}}\sim\mathcal{N}(0,1) is independent of GqG_q.

We next consider the traceless contribution. Since

tr⁡(Aˉ∗)=0,\operatorname{tr}(\bar A^*)=0,

we have

E[xqTAˉ∗v]≈dCβE[xqTAˉ∗w]=0.\mathbb{E}\left[x_q^\mathsf{T}\bar A^*v\right]\approx dC_\beta\mathbb{E}\left[x_q^\mathsf{T}\bar A^*w\right]=0.

We have

E[(xqTAˉ∗v)2]≈d2Cβ2E[(xqTAˉ∗w)2]+d2αtrainE[xqTAˉ∗Aˉ∗Txq].\mathbb{E}\left[\left(x_q^\mathsf{T}\bar A^*v\right)^2\right]\approx d^2C_\beta^2\mathbb{E}\left[\left(x_q^\mathsf{T}\bar A^*w\right)^2\right]+\frac{d}{2\alpha_{\mathrm{train}}}\mathbb{E}\left[x_q^\mathsf{T}\bar A^*\bar A^{*\mathsf{T}}x_q\right].

Averaging over xqx_q and ∥w∥2=1\lVert w\rVert^2=1 gives

E[(xqTAˉ∗w)2]=1d∥Aˉ∗∥F2\mathbb{E}\left[\left(x_q^\mathsf{T}\bar A^*w\right)^2\right]=\frac{1}{d}\lVert\bar A^*\rVert_F^2

and

E[xqTAˉ∗Aˉ∗Txq]=∥Aˉ∗∥F2.\mathbb{E}\left[x_q^\mathsf{T}\bar A^*\bar A^{*\mathsf{T}}x_q\right]=\lVert\bar A^*\rVert_F^2.

Therefore

E[(xqTAˉ∗v)2]≃dd∥Aˉ∗∥F2(cβ2+12αtrain).\mathbb{E}\left[\left(x_q^{\mathsf{T}}\bar{A}^{*}v\right)^2\right]\mathrel{\mathop{\simeq}^{d}} d\|\bar{A}^{*}\|_{F}^{2}\left(c_{\beta}^{2}+\frac{1}{2\alpha_{\mathrm{train}}}\right).

Note that

d∥Aˉ∗∥F2=a^2−a^12.d\|\bar{A}^{*}\|_{F}^{2}=\widehat{a}_{2}-\widehat{a}_{1}^{2}.

and so

xqTAˉ∗v≃dGtraceless(a^2−a^12)(cβ2+12αtrain).x_q^{\mathsf{T}}\bar{A}^{*}v\mathrel{\mathop{\simeq}^{d}}G_{\mathrm{traceless}}\sqrt{\left(\widehat{a}_{2}-\widehat{a}_{1}^{2}\right)\left(c_{\beta}^{2}+\frac{1}{2\alpha_{\mathrm{train}}}\right)}.

Finally, since c≃1/2c \simeq1/2, we have

cxqTa∗≃dGveca^04,a^0:=∥a∗∥2.c x_q^{\mathsf{T}}a^{*}\mathrel{\mathop{\simeq}^{d}}G_{\mathrm{vec}}\sqrt{\frac{\widehat{a}_{0}}{4}},\qquad\widehat{a}_{0}:=\|a^{*}\|^{2}.

Combining everything gives a joint statistically-equivalent characterisation

Rloo≃da^1cβGq+a^112αtrainGtr+Gtraceless(a^2−a^12)(cβ2+12αtrain)+Gveca^04,R_{\mathrm{loo}}\mathrel{\mathop{\simeq}^{d}}\widehat{a}_{1}c_{\beta}G_q+\widehat{a}_{1}\frac{1}{\sqrt{2\alpha_{\mathrm{train}}}}G_{\mathrm{tr}}+G_{\mathrm{traceless}}\sqrt{\left(\widehat{a}_{2}-\widehat{a}_{1}^{2}\right)\left(c_{\beta}^{2}+\frac{1}{2\alpha_{\mathrm{train}}}\right)}+G_{\mathrm{vec}}\sqrt{\frac{\widehat{a}_{0}}{4}},

where

Gq,Gtr,Gtraceless,Gvec∼i.i.d.N(0,1).G_q,G_{\mathrm{tr}},G_{\mathrm{traceless}},G_{\mathrm{vec}}\mathrel{\sim^{\mathrm{i.i.d.}}}\mathcal{N}(0,1).

Step 4. Closing the proximal equation. We now assume that the empirical order parameters (a^1,a^2,a^0)(\widehat{a}_{1},\widehat{a}_{2},\widehat{a}_{0}) concentrate around the deterministic limits (a1,a2,a0)(a_{1},a_{2},a_{0}). We also assume that sμ→ss_{\mu}\to s. Exchangeability then identifies the limiting joint law of (Rμ,[μ],Rμ,yμ)(R_{\mu,[\mu]},R_{\mu},y_{\mu}) with (Rloo,Rs,Y)(R_{\mathrm{loo}},R_s,Y), where Rloo=Rs+s(σ(Rs)−Y)R_{\mathrm{loo}}=R_s+s(\sigma(R_s)-Y). From this point onward we use the scalar variables (Rloo,Rs,Y)(R_{\mathrm{loo}},R_s,Y) after converting empirical averages to expectations. The proof here will proceed in a heuristic fashion. For λ→0\lambda\to0, we assume without proof that the limiting order parameters are O(1)O(1) with respect to dd; we have numerically validated this. For λ≠0\lambda\ne0, additional control of the scaling of the order parameters is required, so we retain the corresponding terms in the final expression.

To proceed, we can differentiate L\mathcal{L} with respect to our desired parameters to get

∂L∂a^1=1n∑μ(σ(Rμ)−yμ)xq,μTvμd+λa^1=0\frac{\partial\mathcal{L}}{\partial\widehat{a}_{1}}=\frac{1}{n}\sum_{\mu}\left(\sigma(R_{\mu})-y_{\mu}\right)\frac{x_{q,\mu}^{\mathsf{T}}v_{\mu}}{d}+\lambda\widehat{a}_{1}=0
∂L∂a=1n∑μ(σ(Rμ)−yμ)cμxq,μ+λda=0.\frac{\partial\mathcal{L}}{\partial a}=\frac{1}{n}\sum_{\mu}\left(\sigma(R_{\mu})-y_{\mu}\right)c_{\mu}x_{q,\mu}+\lambda da=0.

We focus first on the a^1\widehat{a}_{1} equation. For λ=0\lambda=0 this expression simplifies; for general λ\lambda, we retain the λa^1\lambda\widehat{a}_{1} term. Using the proximal equation, concentration a^1→a1\widehat{a}_{1}\to a_{1}, and approximating 1/n∑μ1/n\sum_{\mu} by an expectation, we have

E[(Rloo−Rs)1dxqTv]+sλa1=0.\mathbb{E}\left[\left(R_{\mathrm{loo}}-R_s\right)\frac{1}{d}x_q^{\mathsf{T}}v\right]+s\lambda a_{1}=0.

We can expand

E[Rloo1dxqTv]=1dE[tr⁡((AvvT+a(cv)T)xqxqT)]=1dE[tr⁡(AvvT+a(cv)T)]=a1(cβ2+12αtrain).\begin{aligned} \mathbb{E}\left[R_{\mathrm{loo}}\frac{1}{d}x_q^{\mathsf{T}}v\right]=\frac{1}{d}\mathbb{E}\left[\operatorname{tr}\left((Avv^{\mathsf{T}}+a(cv)^{\mathsf{T}})x_qx_q^{\mathsf{T}}\right)\right] \\ &=\frac{1}{d}\mathbb{E}\left[\operatorname{tr}\left(Avv^{\mathsf{T}}+a(cv)^{\mathsf{T}}\right)\right] \\ &=a_{1}\left(c_{\beta}^{2}+\frac{1}{2\alpha_{\mathrm{train}}}\right). \end{aligned}

Furthermore, using the same tricks as previously, we can write the marginal for xqTvx_q^{\mathsf{T}}v as

1dxqTv=cβGq+12αtrainGtr.\frac{1}{d}x_q^{\mathsf{T}}v=c_\beta G_q+\frac{1}{\sqrt{2\alpha_{\mathrm{train}}}}G_{\mathrm{tr}}.

Thus

a1=E[Rs(cβGq+12αtrainGtr)]Δ+sλ.a_1=\frac{\mathbb{E}\left[R_s\left(c_\beta G_q+\frac{1}{\sqrt{2\alpha_{\mathrm{train}}}}G_{\mathrm{tr}}\right)\right]}{\Delta+s\lambda}.

Now for aa, set

W:=ca∗Txq.W:=ca^{*\mathsf{T}}x_q.

The vector first-order condition and the proximal equation give

0=E[(σ(Rs)−Y)W]+λda^0=1sE[(Rloo−Rs)W]+λda^0.\begin{aligned} 0&=\mathbb{E}\left[(\sigma(R_s)-Y)W\right]+\lambda d\hat{a}_0\\ &=\frac{1}{s}\mathbb{E}\left[(R_{\mathrm{loo}}-R_s)W\right]+\lambda d\hat{a}_0. \end{aligned}

Thus

E[RlooW]−E[RsW]+sλda^0=0.\mathbb{E}[R_{\mathrm{loo}}W]-\mathbb{E}[R_sW]+s\lambda d\hat{a}_0=0.

Under the Gaussian equivalent above, W≈da^0/4 GvecW\overset{d}{\approx}\sqrt{\hat{a}_0/4}\,G_{\mathrm{vec}} and GvecG_{\mathrm{vec}} is independent of the other cavity variables. Hence Stein’s lemma gives

E[RlooW]≈a^04,E[RsW]≈a^04χ(s),\mathbb{E}[R_{\mathrm{loo}}W]\approx\frac{\hat{a}_0}{4},\qquad\mathbb{E}[R_sW]\approx\frac{\hat{a}_0}{4}\chi(s),

where χ(s)=E[(1+sσ′(Rs))−1]\chi(s)=\mathbb{E}[(1+s\sigma'(R_s))^{-1}]. Therefore, asymptotically,

a^0(1−χ(s)4+sλd)⟶0.\hat{a}_0\left(\frac{1-\chi(s)}{4}+s\lambda d\right)\longrightarrow0.

This forces a0=0a_0=0 and, moreover, sλda^0→0s\lambda d\hat{a}_0\to0. From the full derivative equation for γ\gamma we have

E[(σ(Rs)−Y)Rs]+λd(a^2d+a^0)=0.\mathbb{E}[(\sigma(R_s)-Y)R_s]+\lambda d\left(\frac{\hat{a}_2}{d}+\hat{a}_0\right)=0.

Using the proximal equation, this becomes

E[RlooRs]−E[Rs2]+sλd(a^2d+a^0)=0.\mathbb{E}[R_{\mathrm{loo}}R_s]-\mathbb{E}[R_s^2]+s\lambda d\left(\frac{\hat{a}_2}{d}+\hat{a}_0\right)=0.

Taking the limit and using sλda^0→0s\lambda d\hat{a}_0\to0 gives

E[RlooRs]−E[Rs2]+sλa2=0.\mathbb{E}[R_{\mathrm{loo}}R_s]-\mathbb{E}[R_s^2]+s\lambda a_2=0.

In the ridgeless case, the final term vanishes. For finite ridge, we have the following self-consistency equation after using a0=0a_0=0:

a2=E[Rs2]−Δ(1−χ)a12−sλa12Δχ+sλ.a_2=\frac{\mathbb{E}[R_s^2]-\Delta(1-\chi)a_1^2-s\lambda a_1^2}{\Delta\chi+s\lambda}.

In the explicitly ridgeless case, we may expand E[RlooRs]\mathbb{E}[R_{\mathrm{loo}}R_s] at leading order, giving

E[RlooRs]=a1E[Rs(cβGq+12αtrainGtr)]+E[RsGtraceless(a2−a12)(cβ2+12αtrain)]=a12(cβ2+12αtrain)+(a2−a12)(cβ2+12αtrain)E[∂Rs∂Rloo]by Stein’s lemma.\begin{aligned} \mathbb{E}[R_{\mathrm{loo}}R_s] ={}&a_1\mathbb{E}\left[R_s\left(c_\beta G_q+\frac{1}{\sqrt{2\alpha_{\mathrm{train}}}}G_{\mathrm{tr}}\right)\right]\\ &+\mathbb{E}\left[R_sG_{\mathrm{traceless}}\sqrt{(a_2-a_1^2)\left(c_\beta^2+\frac{1}{2\alpha_{\mathrm{train}}}\right)}\right]\\ ={}&a_1^2\left(c_\beta^2+\frac{1}{2\alpha_{\mathrm{train}}}\right) +(a_2-a_1^2)\left(c_\beta^2+\frac{1}{2\alpha_{\mathrm{train}}}\right) \mathbb{E}\left[\frac{\partial R_s}{\partial R_{\mathrm{loo}}}\right] \quad\text{by Stein’s lemma.} \end{aligned}

Now

∂Rs∂R∞=11+sσ′(Rs)\frac{\partial R_s}{\partial R_{\infty}}=\frac{1}{1+s\sigma'(R_s)}

from differentiating the proximal equation, and so

a2=(1−1E[11+sσ′(Rs)])a12+E[Rs2](Cβ2+12αtrain)E[11+sσ′(Rs)].a_2=\left(1-\frac{1}{\mathbb{E}}\left[\frac{1}{1+s\sigma'(R_s)}\right]\right)a_1^2+\frac{\mathbb{E}[R_s^2]}{\left(C_\beta^2+\frac{1}{2\alpha_{\mathrm{train}}}\right)\mathbb{E}\left[\frac{1}{1+s\sigma'(R_s)}\right]}.

Step 5. Characterisation of the test logit. Here we apply a similar argument to one used in Step 3. We wish to characterise the test logit htest⊤γ∗h_{\mathrm{test}}^\top\gamma^*. Thus,

Rtest=xq⊤(A∗v+ca∗),v:=dℓtest∑i=1ℓtestyixi,c:=1ℓtest∑i=1ℓtestyi.R_{\mathrm{test}}=x_q^\top(A^*v+ca^*),\qquad v:=\frac{d}{\ell_{\mathrm{test}}}\sum_{i=1}^{\ell_{\mathrm{test}}}y_i x_i,\qquad c:=\frac{1}{\ell_{\mathrm{test}}}\sum_{i=1}^{\ell_{\mathrm{test}}}y_i.

The argument for a statistically equivalent characterisation proceeds exactly the same as in Step 3, except the moments involve αtest\alpha_{\mathrm{test}} now instead of αtrain\alpha_{\mathrm{train}}. This gives the desired marginal distribution

yq∼Bernoulli⁡(σ(βGq))y_q\sim\operatorname{Bernoulli}(\sigma(\beta G_q))
Rtest=a1CβGq+a112αtestGtr+Gtraceless(a2−a12)Δtest,Δtest:=Cβ2+12αtest.R_{\mathrm{test}}=a_1C_\beta G_q+a_1\frac{1}{\sqrt{2\alpha_{\mathrm{test}}}}G_{\mathrm{tr}}+G_{\mathrm{traceless}}\sqrt{(a_2-a_1^2)\Delta_{\mathrm{test}}},\qquad\Delta_{\mathrm{test}}:=C_\beta^2+\frac{1}{2\alpha_{\mathrm{test}}}.

This concludes the proof of Result 1 and Result 3.

Schematic derivation of solution boundary Result 2

This claim follows by applying the result of Koriyama and Bellec [14] to our problem setting, which requires an additional heuristic transfer argument. The setting considered by Koriyama and Bellec [14] is the classic teacher-student setting where the model being trained has Gaussian covariates xx. This assumption clearly does not hold in our setting, where not only do the model’s covariates hh not match the teacher covariates xx, but the hhs are not Gaussian. That said, we present the following schematic argument for the applicability of their result to our setting: each hh takes the form

h=vec⁡(H),H=xqu⊤,u⊤=[dℓ∑i=1ℓyixi⊤  1ℓ∑i=1ℓyi2].h=\operatorname{vec}(H),\qquad H=x_q u^\top,\qquad u^\top=\left[\frac{d}{\ell}\sum_{i=1}^{\ell}y_i x_i^\top\ \ \frac{1}{\ell}\sum_{i=1}^{\ell}y_i^2\right].

We see that xqx_q is Gaussian, and uu is nearly Gaussian (conditional on ww), allowing us to exploit the tensorised form of hh to transfer the result of Koriyama and Bellec [14] (similar to how we exploited this form in arguing the concentration of quadratic forms h⊤Rhh^\top Rh). We stress that this is a heuristic argument.

The second caveat is that the statement in Result 2 is quite informal. The correct statement is

P(finite solution to ridgeless problem exists)→{0τ<τc,1τ>τc.\mathbb{P}(\text{finite solution to ridgeless problem exists})\to \begin{cases} 0 & \tau<\tau_c,\\ 1 & \tau>\tau_c. \end{cases}

Given the above, all that remains is to directly apply the result. We take G∼N(0,1)G\sim\mathcal{N}(0,1) independently, and define (U,Y)(U,Y) by the limiting joint distribution of (xq⊤v/(dΔ),yq)(x_q^\top v/(d\sqrt{\Delta}),y_q). We know from the previous marginal characterisation that

U∝CβGq+12αtrainGtrU\propto C_\beta G_q+\frac{1}{\sqrt{2\alpha_{\mathrm{train}}}}G_{\mathrm{tr}}

where Gq,Gtr∼N(0,1)G_q,G_{\mathrm{tr}}\sim\mathcal{N}(0,1) with Y∼Bernoulli⁡(σ(βGq))Y\sim\operatorname{Bernoulli}(\sigma(\beta G_q)). Normalising the variance of UU gives the required result.

Properties of loss functions with context length

Here we justify our claim that increasing test-time context length strictly decreases both losses. Intuitively, this follows because αtest\alpha_{\mathrm{test}} only appears in the variance term VV that contributes randomness that is independent of the actual signal GqG_q.

To be concrete, for the cross-entropy loss, we can write

ECE=E[L(R)]−E[σ(βGq)a1CβGq]=EG∼N(0,1)[log⁡(1+exp⁡(cG))]−a1Cβ2\mathcal{E}_{\mathrm{CE}} = \mathbb{E}[L(R)] - \mathbb{E}[\sigma(\beta G_q)a_1 C \beta G_q] = \mathbb{E}_{G \sim\mathcal{N}(0,1)}[\log(1+\exp(cG))] - a_1 C \beta^2

where

c=a2(12αtest+Cβ2)c = \sqrt{a_2\left(\frac{1}{2\alpha_{\mathrm{test}}}+C_\beta^2\right)}

does not depend on GG. Thus

∂ECE∂c=E[Gexp⁡(cG)1+exp⁡(cG)]=E[cexp⁡(cG)(1+exp⁡(cG))2]≥0\frac{\partial\mathcal{E}_{\mathrm{CE}}}{\partial c} = \mathbb{E}\left[\frac{G\exp(cG)}{1+\exp(cG)}\right] = \mathbb{E}\left[\frac{c\exp(cG)}{(1+\exp(cG))^2}\right] \ge0

and the result follows as ∂c/∂αtest<0\partial c/\partial\alpha_{\mathrm{test}} < 0.

For the classification loss, write

Eclass=E[σ(βGq)]+E[(1−2σ(βGq))ϕ]\mathcal{E}_{\mathrm{class}} = \mathbb{E}[\sigma(\beta G_q)] + \mathbb{E}[(1-2\sigma(\beta G_q))\phi]

where again

ϕ=Φ(sGq),s=a1Cβa22αtest+(a2−a12)Cβ2.\phi= \Phi(sG_q), \qquad s = \frac{a_1 C \beta}{\sqrt{\frac{a_2}{2\alpha_{\mathrm{test}}}+(a_2-a_1^2)C_\beta^2}}.

Thus ϕ\phi is a decreasing function in ss for G<0G<0 and increasing in ss for G>0G>0. We see that ss is an increasing function of αtest\alpha_{\mathrm{test}}, and so ϕ\phi is decreasing in αtest\alpha_{\mathrm{test}} for G<0G<0 and increasing in αtest\alpha_{\mathrm{test}} for G>0G>0. These cases exactly correspond to 1−2σ(βGq)>01-2\sigma(\beta G_q)>0 and 1−2σ(βGq)<01-2\sigma(\beta G_q)<0, and so Eclass\mathcal{E}_{\mathrm{class}} is always a decreasing function of αtest\alpha_{\mathrm{test}}.

References

  1. [1]Kwangjun Ahn, Xiang Cheng, Minhak Song, Chulhee Yun, Ali Jadbabaie, and Suvrit Sra. Linear attention is (maybe) all you need (to understand transformer optimization). In International Conference on Learning Representations, volume 2024, pages 17686–17698, 2024.arxiv.org/abs/2310.01082
  2. [2]Ekin Akyürek, Dale Schuurmans, Jacob Andreas, Tengyu Ma, and Denny Zhou. What learning algorithm is in-context learning? investigations with linear models. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=Og0X4H8yN4I.arxiv.org/abs/2211.15661
  3. [3]Yu Bai, Fan Chen, Huan Wang, Caiming Xiong, and Song Mei. Transformers as statisticians: Provable in-context learning with in-context algorithm selection. In A. Oh, T. Naumann, A. Globerson, K. Saenko, M. Hardt, and S. Levine, editors, Advances in Neural Information Processing Systems, volume 36, pages 57125–57211. Curran Associates, Inc., 2023. URL https://proceedings.neurips.cc/paper_files/paper/2023/file/b2e63e36c57e153b9015fece2352a9f9-Paper-Conference.pdf.arxiv.org/abs/2306.04637
  4. [4]Jean Barbier, Florent Krzakala, Nicolas Macris, Léo Miolane, and Lenka Zdeborová. Optimal errors and phase transitions in high-dimensional generalized linear models. Proceedings of the National Academy of Sciences, 116(12): 5451–5460, 2019.DOI
  5. [5]Blake Bordelon, Mary I. Letey, and Cengiz Pehlevan. Theory of scaling laws for in-context regression: Depth, width, context and time, 2025. URL https://arxiv.org/abs/2510.01098.
  6. [6]Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877–1901, 2020.arxiv.org/abs/2005.14165
  7. [7]Emmanuel J. Candes and Pragya Sur. The phase transition for the existence of the maximum likelihood estimate in high-dimensional logistic regression, 2018. URL https://arxiv.org/abs/1804.09753.
  8. [8]Stephanie C. Y. Chan, Adam Santoro, Andrew K. Lampinen, Jane X. Wang, Aaditya Singh, Pierre H. Richemond, Jay McClelland, and Felix Hill. Data distributional properties drive emergent in-context learning in transformers, 2022.arxiv.org/abs/2205.05055
  9. [9]Thomas M Cover. Geometrical and statistical properties of systems of linear inequalities with applications in pattern recognition. IEEE transactions on electronic computers, (3):326–334, 1965.DOI
  10. [10]Noureddine El Karoui. On the impact of predictor geometry on the performance on high-dimensional ridge-regularized generalized robust regression estimators. Probability Theory and Related Fields, 170(1):95–175, 2018.DOI
  11. [11]Elizabeth Gardner. The space of interactions in neural network models. Journal of Physics A: Mathematical and General, 21(1):257, Jan 1988. doi: 10.1088/0305-4470/21/1/030. URL https://doi.org/10.1088/0305-4470/21/1/030.
  12. [12]Federica Gerace, Bruno Loureiro, Florent Krzakala, Marc Mézard, and Lenka Zdeborová. Generalisation error in learning with random features and the hidden manifold model. In International Conference on Machine Learning, pages 3452–3462. PMLR, 2020.DOI
  13. [13]Angelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, and François Fleuret. Transformers are RNNs: Fast autoregressive transformers with linear attention. In International conference on machine learning, pages 5156–5165. PMLR, 2020.arxiv.org/abs/2006.16236
  14. [14]Takuya Koriyama and Pierre C. Bellec. Phase transitions for the existence of unregularized m-estimators in single index models, 2025. URL https://arxiv.org/abs/2501.03163.
  15. [16]Mary Letey, Jacob A Zavatone-Veth, Yue M. Lu, and Cengiz Pehlevan. Pretrain-test task alignment governs generalization in in-context learning. In The Fourteenth International Conference on Learning Representations, 2026b. URL https://openreview.net/forum?id=KZLeg0MQ2r.arxiv.org/abs/2509.26551
  16. [17]Yue M. Lu, Mary Letey, Jacob A. Zavatone-Veth, Anindita Maiti, and Cengiz Pehlevan. Asymptotic theory of in-context learning by linear attention. Proceedings of the National Academy of Sciences, 122(28):e2502599122, 2025. doi: 10.1073/pnas.2502599122. URL https://www.pnas.org/doi/abs/10.1073/pnas.2502599122.DOI
  17. [18]Xiaoyi Mai, Zhenyu Liao, and Romain Couillet. A large scale analysis of logistic regression: Asymptotic performance and new insights. In ICASSP 2019 - 2019 IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), pages 3357–3361, 2019. doi: 10.1109/ICASSP.2019.8683376.DOI
  18. [19]Song Mei and Andrea Montanari. The generalization error of random features regression: Precise asymptotics and the double descent curve. Communications on Pure and Applied Mathematics, 75(4):667–766, 2022.
  19. [20]Kazusato Oko, Yujin Song, Taiji Suzuki, and Denny Wu. Pretrained transformer efficiently learns low-dimensional target functions in-context, 2024. URL https://arxiv.org/abs/2411.02544.
  20. [21]Luca Pesce, Florent Krzakala, Bruno Loureiro, and Ludovic Stephan. Are gaussian data all you need? extents and limits of universality in high-dimensional generalized linear estimation, 2023. URL https://arxiv.org/abs/2302.08923.
  21. [22]Pragya Sur and Emmanuel J. Candès. A modern maximum-likelihood theory for high-dimensional logistic regression. Proceedings of the National Academy of Sciences, 116(29):14516–14525, 2019. ISSN 1091-6490. doi: 10.1073/pnas.1810420116. URL http://dx.doi.org/10.1073/pnas.1810420116.
  22. [23]Bhavya Vasudeva, Deqing Fu, Tianyi Zhou, Elliott Kau, Youqi Huang, and Vatsal Sharan. Transformers learn low sensitivity functions: Investigations and implications. In International Conference on Learning Representations, volume 2025, pages 7805–7834, 2025.arxiv.org/abs/2403.06925
  23. [24]Johannes Von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento, Alexander Mordvintsev, Andrey Zhmoginov, and Max Vladymyrov. Transformers learn in-context by gradient descent. In Andreas Krause, Emma Brunskill, Kyunghyun Cho, Barbara Engelhardt, Sivan Sabato, and Jonathan Scarlett, editors, Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 35151–35174. PMLR, 23–29 Jul 2023. URL https://proceedings.mlr.press/v202/von_oswald23a.html.arxiv.org/abs/2212.07677
  24. [25]Jason Wei, Yi Tay, Rishi Bommasani, Colin Raffel, Barret Zoph, Sebastian Borgeaud, Dani Yogatama, Maarten Bosma, Denny Zhou, Donald Metzler, Ed H. Chi, Tatsunori Hashimoto, Oriol Vinyals, Percy Liang, Jeff Dean, and William Fedus. Emergent abilities of large language models. Transactions on Machine Learning Research, 2022. ISSN 2835-8856. URL https://openreview.net/forum?id=yzkSU5zdwD.arxiv.org/abs/2206.07682
  25. [26]Jingfeng Wu, Difan Zou, Zixiang Chen, Vladimir Braverman, Quanquan Gu, and Peter Bartlett. How many pretraining tasks are needed for in-context learning of linear regression? In The Twelfth International Conference on Learning Representations, 2024. URL https://openreview.net/forum?id=vSh5ePa0ph.arxiv.org/abs/2310.08391
  26. [27]Chenyang Zhang and Yuan Cao. Transformers efficiently perform in-context logistic regression via normalized gradient descent. arXiv preprint arXiv:2605.06609, 2026.arxiv.org/abs/2605.06609
  27. [28]Ruiqi Zhang, Spencer Frei, and Peter L. Bartlett. Trained transformers learn linear models in-context. Journal of Machine Learning Research, 25(49):1–55, 2024. URL http://jmlr.org/papers/v25/23-1042.html.arxiv.org/abs/2306.09927
  28. [29]Yufeng Zhang, Fengzhuo Zhang, Zhuoran Yang, and Zhaoran Wang. What and how does in-context learning learn? bayesian model averaging, parameterization, and generalization, 2023. URL https://arxiv.org/abs/2305.19420.

Paper details

vlnc:W_bqqj27ur
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 7

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Mathematics

GPT 5.6, GPT 6, an agent model

View statement
Looking for related papers…
Contents