An Asymptotic Theory of Chain-of-Thought in In-Context Learning

Kaito Takanami, Cengiz PehlevanNeurIPS 2026

TL;DR

Giving an AI more time to "think" out loud via Chain-of-Thought (CoT) reasoning doesn't always lead to smarter answers—sometimes it stalls out, and sometimes it actively spirals into "overthinking." By studying a mathematically solvable toy model of a Transformer, the authors uncover a crisp phase diagram explaining exact data conditions under which extra test-time reasoning exponentially improves accuracy, hits an information ceiling, or catastrophically amplifies tiny pretraining flaws.

What Problem Does This Paper Address?

As scaling up pretraining data and compute becomes harder, the AI community has pivoted toward test-time scaling: letting Large Language Models (LLMs) generate longer Chains-of-Thought (CoT) before locking in a final answer. Empirically, however, longer reasoning isn't a magic bullet. Depending on the setup, extra reasoning steps can steadily boost accuracy, plateau with diminishing returns, or degrade performance—a frustrating phenomenon dubbed overthinking.

Most studies view these quirks through the lens of problem difficulty, leaving us with heuristics rather than first principles. We lacked a unified mathematical theory explaining what governs the tipping points between helpful reasoning, saturation, and overthinking—specifically, how pretraining task diversity and test-time context length pull the strings behind the scenes.

Methods

To peer inside the black box without getting lost in the weeds of natural language, the authors strip CoT down to a clean, solvable mathematical skeleton: in-context linear regression weight prediction.

Instead of predicting words, a single-layer linear self-attention model is shown a prompt containing $L$ input-output pairs $(x, y)$ generated by a hidden vector of weights $w$ (of dimension $D$), and its goal is to guess $w$.

  • Pretraining: Across $M$ different tasks, the model learns a core update rule (parameterized as a matrix) to step from an initial guess toward the true $w$ in a single hop.
  • Test-time CoT: At inference, the model applies this learned update rule iteratively for $t$ steps. Each refined guess $\hat{w}_t$ is appended directly onto the prompt as a new token, mimicking how LLMs condition on their own generated reasoning tokens.

What is novel here is how they solve the error dynamics. Because the learned update matrix isn't symmetric, standard math shortcuts fail. The authors deploy heavy machinery from physics and random matrix theory—specifically a two-point generating function paired with multi-source cavity techniques—in the high-dimensional limit (where $D, L, M \to \infty$ at fixed ratios: context length $\alpha = L/D$ and pretraining task diversity $\tau = M/D$). Finally, they test whether their simplified math holds up in fully parameterized linear attention and nonlinear softmax attention models.

Datasets

Rather than scraping web text or using standard NLP benchmarks, this theoretical study relies entirely on synthetic Gaussian linear regression tasks. Both ground-truth task weights $w$ and contextual inputs $x$ are sampled from isotropic Gaussian distributions (with optional Gaussian label noise during pretraining, and noiseless prompts at test time). No external or newly curated empirical benchmark datasets are introduced.

Key Insights and Ideas

Phase diagram of the test-time scaling law and error dynamics across four distinct regimes.

Figure 1: Phase diagram of the test-time scaling law and representative error dynamics. (A) Heatmap of theoretical prediction of the generalization error (MSE) at a fixed test-time depth t = 80. The diagram is divided into four regimes: (I) the overthinking regime, τ < τc(α, σ2), where long test- time CoT amplifies the error; (II) the polynomial-decay regime, α > 1 and τ = τc(α, σ2), where the error decreases only polynomially; (III) the saturation regime, 0 < α < 1 and τ > τc(α, σ2), where the dynamics is stable but the error converges to a nonzero limit; and (IV) the exponential-decay regime, α > 1 and τ > τc(α, σ2), where the error decays exponentially to zero. (B,C) Theoretical prediction of the generalization error Et dynamics for (B) fixed α and (C) fixed τ. (A-C) Parameters: λ = 10−5, σ2 = 0.01.
  • Test-time scaling isn't one universal curve—it has sharp phase transitions: Depending on pretraining diversity ($\tau$) and context length ($\alpha$), test-time CoT splits cleanly into four regimes: exponential decay (error drops rapidly to zero), polynomial decay (a sluggish critical boundary), saturation (error stabilizes at a non-zero floor), and overthinking (error initially dips, then explodes exponentially).
  • Overthinking is a pretraining flaw, not a test-time flaw: When pretraining task diversity $\tau$ falls below a critical threshold $\tau_c$, the model learns a slightly crooked update operator. Applying it once or twice helps, so error drops at small depths—but looping it repeatedly compounds that systematic bias, blowing up the error. Better pretraining pushes this optimal stopping horizon further out.
  • Pretraining buys stability; context buys speed (and lowers the floor): Pretraining diversity ($\tau$) dictates whether iterative reasoning is stable, while in-context information ($\alpha$) dictates how fast error decays. If you give the model too few prompt examples ($\alpha < 1$), no amount of deep thinking can invent missing information, locking the model into the saturation regime.
  • More context can paradoxically lose at deep horizons: Because the critical stability threshold $\tau_c$ shifts with $\alpha$, adding more in-context examples can accidentally push a borderline-pretrained model across the phase boundary from stable saturation into unstable overthinking—meaning a richer prompt wins early, but loses badly if allowed to "think" too long!

Key Results

  • Exact Asymptotic Scaling Laws: The authors derive exact closed-form equations for test-time Mean Squared Error ($\mathcal{E}_t$). In the ideal limit (infinite pretraining $\tau \to \infty$, ridgeless learning, and rich context $\alpha \gg 1$), error vanishes as $\mathcal{E}_t \asymp t^{-3/2} (4/\alpha)^t$, proving that richer context directly accelerates the exponential decay rate.
  • Optimal Stopping Near the Edge of Overthinking: In the overthinking regime ($\tau < \tau_c$), there is a sweet-spot reasoning depth $t^*$ before error rebounds. As pretraining improves toward the critical boundary ($\tau \to \tau_c^-$), this useful horizon diverges as $t^* \propto (\tau_c - \tau)^{-1}$, and the best achievable error shrinks polynomially as $(t^*)^{-1/2}$.
  • Validation in Nonlinear Transformers: Experiments with $D=50$ up to depth $t=20$ confirm that both fully learned linear attention and standard softmax attention reproduce the exact same qualitative phase diagram—recovering the overthinking U-curves at low $M$, flat saturation plateaus at low $L$, and steady error decay when both $M$ and $L$ are abundant (though softmax normalization tempers the decay rate to be more gradual than pure linear attention).

Limitations and Future Work

As the authors openly note, this crystal-clear math comes from studying a highly idealized world: a single-layer linear learner tackling isotropic Gaussian regression, where "reasoning" simply means iteratively refining a weight vector. Real-world LLMs feature deep multi-layer architectures, structured/anisotropic data, and discrete natural-language reasoning steps that branch and backtrack rather than just doing gradient-like steps. Extending this asymptotic theory to richer data geometries, deeper Transformers, and more complex CoT structures—alongside empirical tests on real LLMs—is the natural next frontier.

Summary updated

Abstract

Chain-of-thought (CoT) reasoning has become a widely used mechanism for eliciting multi-step reasoning in large language models by generating intermediate reasoning steps at inference time. Yet the scaling behavior of generalization with CoT depth remains poorly understood. To address this question, we study a theoretically solvable model of CoT for in-context weight prediction in linear regression, where test-time reasoning is represented as an iterative refinement of the weight-parameter estimate. Using tools from random matrix theory under high-dimensional asymptotics, we derive an exact formula for the generalization error as a function of reasoning depth, pretraining data amount, and context length. Our analysis reveals a sharp phase transition separating exponential and polynomial improvement, saturation, and overthinking, and characterizes how the optimal reasoning depth scales. We further show that deeper reasoning is most effective with sufficiently rich pretraining and in-context information, whereas limited pretraining or context makes longer reasoning prone to error amplification or saturation. We also validate these predictions through experiments on fully learned linear attention and softmax attention models. Our results provide a unified theoretical account of how test-time CoT depth affects generalization.
BibTeX
@inproceedings{takanami2026asymptotic,
  author = {Kaito Takanami and Cengiz Pehlevan},
  title = {{An Asymptotic Theory of Chain-of-Thought in In-Context Learning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=B3HqjP2biY},
}

Loading related content...

Figure