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 sequences of examples. Each sequence consists of pairs sampled from a latent task, and the model aims to learn the corresponding conditional distribution. Each sequence has a latent task vector drawn uniformly from the unit sphere. Fix an inverse temperature . Fixing , draw independent covariates and a query , with
where 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
The final zero is a placeholder for the query label . We pass to a linear-attention operator and map the final, label-coordinate entry of the updated query column to a binary class probability. Specifically, writing and , the query column updated by linear attention is
Here , , 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,
Prior work on in-context linear regression has shown that linear attention admits a particularly clean reduced representation: by expanding (4) in terms of and , 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,
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 and
Finally, applying softmax gives the class-probability estimator .
Optimal parameters given training batch. We consider a training batch with independent prompts, which yields independent feature matrices () in the reduced logit . Write and for their row-wise vectorisations in . We use as shorthand for the sequence’s query label , and fit the reduced model by regularised Bernoulli negative log-likelihood:
The choice of 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 and so without this normalisation, the effective regularisation would be zero at large .
Asymptotic assumptions. We study the proportional limit with constant
High-dimensional characterisation
For the fitted, data-dependent parameters , define the empirical order parameters
We will derive limiting deterministic values for these random parameters. The parameter measures the strength of the vector component of . For the other two, note that
This quantity is minimised at , so it measures the squared distance of from isotropy. We aim to derive a statistically equivalent expression for the test logit, where is drawn fresh from the distribution described above, and the optimal parameters 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 and defined by
For , this objective is strictly convex in and therefore has a unique minimiser. The linear features are rotationally invariant, since for every orthogonal . The structure of the linear-attention estimator then gives
for every orthogonal . Uniqueness of the population solution therefore implies and . Thus isotropy emerges as , whereas the finite-sample result can retain an anisotropic contribution.
We can separately consider the long-context limit. Holding and fixed, take . Then
where is the first Hermite coefficient of the sigmoid activation. Thus the reduced-model logit becomes
We see that these two limits remove different sources of randomness. The large- 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 for . 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 . The full derivation and its assumptions are given in Appendix B. Schematically, we use a cavity approach [10]: we exclude one of the prompts from the loss and study the effect of this omission on the fitted parameters. In particular, we study the deterministic limits , , and of the empirical order parameters , which characterise properties of the optimised weights .
Result 1: Self-consistency equations for order parameters
The order parameters are determined implicitly as follows. Fix , , and . For any candidate pair such that , draw independent , , and then draw from the label distribution . Define , . Use the candidate order parameters to form the trained logit as the unique solution of
Define mean response and susceptibility jointly by
Then for positive , the scalars and are desired solutions when
These self-consistently determined scalars characterise the behaviour of the test logit of a fresh prompt , as given by the following main result. Before proceeding, we need to be careful when discussing the fixed point solutions and for a given data configuration determined by , , and , 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 data points in 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 to -dimensional points in general position, separability holds with probability tending to 1 as if ([9, 11]), and thus MLE exists with high probability if . 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 . 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 . The zero-signal case corresponds to the Cover transition above where the critical value of is 2.
Result 2: Ridgeless solution existence boundary
A finite-norm optimiser exists with high probability for , where is defined by
for and .
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 , as our estimator takes samples ( sequences) of features in dimensions. The zero-signal case would correspond to each of the query labels being chosen uniformly at random, and then the MLE should exist for . Increasing , or increasing 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 , as seen by Figure 2. Note that depends on both and , as will be discussed below (see Figure 5).
Figure 5. Heatmap of critical against and .
Finite-sample results: test logit and test error
Finally, we may use the self-consistency equations in Result 1 to characterise , and to determine the ICL test error. To allow for different context length at testing time, we introduce .
Result 3: Characterisation of logit distribution
Fix , , , and . Sample Gaussians . Then, assuming the empirical order parameters of the fitted concentrate to finite values, their limiting behaviour is
Here and are the deterministic self-consistent solutions given by Result 1. Further, the test logit has marginal distribution given by
The lack of in the final logit equation (i.e. ) is due to the isotropy and mean-0 properties of the data, as well as the fact that this corresponding block in the predictor, , 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 and increase, as expected from the population analysis.
Figure 1. The distribution of empirical matches our derived distribution . The ridgeless theory predicts recovery of the true logit distribution as . Increasing (right-hand plots) reduces variance, but alignment with requires both variance reduction and . For all, , , , .
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 , and Bayes error . For short contexts, the model effectively guesses, but nears the Bayes floor as context length increases. , , , , .
Result 4: Error formulas The cross entropy test loss is given by
and the classification error is given by
where is the standard normal CDF and , .
Findings
We highlight several interpretable implications of these results.
Effect of test-time context length. First note that only appears explicitly in ; and do not depend on . As 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 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 ()
Figure 2b. Non-zero ridge curve ()
fig:2: Empirical simulation refers to directly sampling sequences of length , computing , 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 , , . In (a), the empirical simulations take .
Calibration and noise. Under the marginal laws (18) and (19), the target logit is and the predicted logit is
By Result 3, this logit expression makes the various sources of error explicit: the scaling coefficient in front of , the variance due to test context length , and the variance due to anisotropy . While the factor 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,
This immediately allows us to write the conditional class probability as
Recall the model predicts the probability of outcome 1 as , where the actual probability is . This immediately gives us a clean formulation of calibration: the model is calibrated when . For (i.e. the model is skewed towards 1), if then the model is underconfident, while if the model is overconfident. The reverse is true for .
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 as . We see this occurs roughly at a rate of , 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 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 and on anisotropy (a) and calibration (b),(c). We compute , (and correspondingly, , ) using Result 1. In (b),(c), is taken simply as a real-valued variable and the function is computed by numerically taking the expectation in (22). In all plots we take (effectively infinite) to isolate the effects of and ; all labels refer to . For all, and . For (b) . For (c) .
Location of critical batch size. Figure 5 maps the predicted dependence of on context length and sampling inverse temperature . We see that increasing either or will increase the critical ratio . This can be understood from prior intuition: increasing either or will increase the "signal" of the features relative to the zero-signal (uniformly random ) 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 matrices, and ultimately studied the reduced model in terms of parameters . Despite this modelling choice for the theory, the prediction in Result 3 also accurately describes the linear-attention architecture with fully trained matrices. This is shown in Figure 6, where we see close agreement between the theory logit and the trained linear attention output distributions, with small deviation in the tails for small and .
Figure 6. Similarly to Figure 1, we compare the theory to full-parameter linear attention, namely, we train the full matrices. Here we plot a quantile-quantile comparison of the model’s output logit on new prompt matrices against the theory prediction and the true latent . In all plots, , , . Regularisation is applied to .
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 substantially broadens the softmax distribution and improves its alignment with the teacher distribution. The effect of increasing the task ratio 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 , whereas the theory reference performs better for . 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 , key , value , and output 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 and .
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 (given by equation (22)) with . 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 and let minimise the objective with prompt removed. Let
A quadratic expansion about gives
Minimizing at fixed yields
Logit convention. Before taking the high-dimensional limit, denotes the full-sample fitted logit, while denotes the logit of prompt when prompt is omitted from training. In particular, is the cavity logit for the held-out prompt. Only after invoking concentration and exchangeability do we identify the limiting joint law of with .
Step 2. Hessian prefactor. We are interested in writing a characterisation for the left-out Hessian prefactor terms that appear in the proximal equation
This is a heuristic argument; we mark the assumptions used below explicitly. We have
As in the quadratic expansion, we evaluate
Eventually we will compare this to the Hessian of the full loss. We have two choices of where to evaluate such an object, at or at . In the latter, they differ by a rank-one term
For the former, we must bound induced differences, as
We assume, without proof, that the matrix remainder
can be neglected in the normalised inverse-Hessian quadratic forms and traces used below. Expand
We have
and so
We can simplify the quadratic forms as follows. Recall the structure of and so for any matrix , we have
The s are mean-zero, sub-Gaussian, with independent coordinates, and so if we write matrices then
For the terms, conditional on ,
where
Averaging over the spherically uniform task distribution gives
For the leave-one-out inverse Hessians considered below, we assume
So we will write
Now we assume that are sufficiently well behaved so that the relevant normalised traces of the inverse Hessians at their respective minimisers are comparable, i.e.
Thus for , we write
We further assume that this quantity concentrates to a deterministic scalar . We then have
Estimating will be difficult and we wish to avoid it. For , we make the additional approximation, without proof, that the contribution of the final vector block of to the normalised inverse-Hessian trace is asymptotically negligible, so that the main block dominates. Thus,
For , this approximation is not required, since the term involving in the preceding equation vanishes. To summarise, we have that
for deterministic scalar defined self-consistently by
In the limit as , we have the nicer ridgeless characterisation
Step 3. Gaussian equivalent. We will construct a logit that is statistically equivalent to the left-out logits . To do this, we make a standard assumption commonly used in cavity arguments, that asymptotically there is no difference between and . Moreover, is independent of , since prompt is excluded from its training set. Here is drawn from the same distribution as the training distribution, namely context length is still and is not . This distinction is important, as here is not the test logit, which would describe sequences of length . Thus we have that
Write
Then
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 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
Conditional on , we have
and
Consequently,
Using concentration of quadratic forms,
Moreover, its covariance with is asymptotically zero. Under the self-averaging assumption above, it results in
where is independent of .
We next consider the traceless contribution. Since
we have
We have
Averaging over and gives
and
Therefore
Note that
and so
Finally, since , we have
Combining everything gives a joint statistically-equivalent characterisation
where
Step 4. Closing the proximal equation. We now assume that the empirical order parameters concentrate around the deterministic limits . We also assume that . Exchangeability then identifies the limiting joint law of with , where . From this point onward we use the scalar variables after converting empirical averages to expectations. The proof here will proceed in a heuristic fashion. For , we assume without proof that the limiting order parameters are with respect to ; we have numerically validated this. For , 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 with respect to our desired parameters to get
We focus first on the equation. For this expression simplifies; for general , we retain the term. Using the proximal equation, concentration , and approximating by an expectation, we have
We can expand
Furthermore, using the same tricks as previously, we can write the marginal for as
Thus
Now for , set
The vector first-order condition and the proximal equation give
Thus
Under the Gaussian equivalent above, and is independent of the other cavity variables. Hence Stein’s lemma gives
where . Therefore, asymptotically,
This forces and, moreover, . From the full derivative equation for we have
Using the proximal equation, this becomes
Taking the limit and using gives
In the ridgeless case, the final term vanishes. For finite ridge, we have the following self-consistency equation after using :
In the explicitly ridgeless case, we may expand at leading order, giving
Now
from differentiating the proximal equation, and so
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 . Thus,
The argument for a statistically equivalent characterisation proceeds exactly the same as in Step 3, except the moments involve now instead of . This gives the desired marginal distribution
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 . This assumption clearly does not hold in our setting, where not only do the model’s covariates not match the teacher covariates , but the s are not Gaussian. That said, we present the following schematic argument for the applicability of their result to our setting: each takes the form
We see that is Gaussian, and is nearly Gaussian (conditional on ), allowing us to exploit the tensorised form of to transfer the result of Koriyama and Bellec [14] (similar to how we exploited this form in arguing the concentration of quadratic forms ). 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
Given the above, all that remains is to directly apply the result. We take independently, and define by the limiting joint distribution of . We know from the previous marginal characterisation that
where with . Normalising the variance of 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 only appears in the variance term that contributes randomness that is independent of the actual signal .
To be concrete, for the cross-entropy loss, we can write
where
does not depend on . Thus
and the result follows as .
For the classification loss, write
where again
Thus is a decreasing function in for and increasing in for . We see that is an increasing function of , and so is decreasing in for and increasing in for . These cases exactly correspond to and , and so is always a decreasing function of .
References
- [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]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]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]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]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]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]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]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]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]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]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]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]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]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.
- [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
- [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
- [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
- [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.
- [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.
- [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.
- [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.
- [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
- [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
- [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
- [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
- [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
- [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
- [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.







