Manuscript Offprint
arXiv:2611.06438Understanding the Out-of-Distribution Generalization of Chain-of-Thought Reasoning in LLMs
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
Abstract
Chain-of-Thought (CoT) reasoning substantially improves Large Language Models (LLMs), yet its out-of-distribution (OOD) generalization mechanism remains theoretically underexplored. We study CoT as compositional OOD generalization: the target task lacks complete reasoning trajectories or direct input-output pairs, while training provides only in-distribution (ID) atomic step data. We show that CoT generalizes by repeatedly applying a shared single-step predictor to compose reusable ID transitions. Theoretically, let denote the number of reasoning steps in the target task, the number of training samples per sub-task, and the number of output tokens per step; then the OOD task risk is controlled by the sum of the ID sub-task risks, scaled by a coefficient of order that is independent of , although the summed risk itself may still grow with . A Rademacher-complexity analysis further shows that the estimation term is of order , rather than linear in , due to predictor sharing under a uniform capacity control on the shared class. For autoregressive Next-Token Prediction, the final-task risk is bounded by the best-in-class step-level risk scaled by the same coefficient of order , plus an estimation term of order . A parity-coupled construction further shows that, for the sub-task empirical risk minimizer, the expected final-task risk is at least the best in-class risk plus when . Experiments on Atom-Task and GSM8K support the theory: CoT enables short-to-long and compositional generalization, while explicit state tracking is crucial.
Our code is available at https://github.com/maxliang114514/CoT-OOD.
1 Introduction
Chain-of-Thought (CoT) reasoning has become a central mechanism for improving the reasoning ability of Large Language Models (LLMs). By prompting or training models to generate intermediate steps, CoT substantially improves mathematical and logical reasoning [1–8]. Recent reasoning-oriented systems further treat step generation as an explicit training signal [9–11], shifting LLM reasoning from direct pattern matching toward structured stepwise computation [12]. Despite this empirical success, a fundamental theoretical question remains open: why can CoT-trained models generalize to complex reasoning tasks that are not directly observed during training?
Existing theoretical studies provide important insights into the expressivity and computational role of CoT. Some works show that CoT can increase the effective depth of Transformers or enable serial computation [13–15], while others analyze task decomposition, in-context learning, or localized reasoning settings [16–18]. However, most existing analyses are either qualitative, restricted to narrow or two-step settings, or do not provide explicit generalization bounds for the autoregressive Next-Token Prediction (NTP) regime commonly used by modern large-scale LLMs. As a result,
*Corresponding author.
Preprint.
the out-of-distribution (OOD) generalization mechanism of multi-step CoT remains theoretically underexplored.

Figure 1: CoT as compositional OOD generalization. Left: without CoT, the model must learn a direct mapping from input to final answer , whose target distribution may be unavailable during training. With CoT, the same predictor is repeatedly applied to in-distribution step distributions, mapping each state to update . Right: a two-hop translation example solves an unseen English-to-German query by composing learned English-to-French and French-to-German steps.
This paper studies the mechanism of CoT through compositional OOD generalization. We consider a target task requiring a complex multi-step mapping from an input state to a final answer , while neither complete reasoning trajectories () nor direct input-output pairs () are available during training. Thus, the target task's composition is OOD relative to the observed atomic transitions. We refer to this setting as compositional OOD; Section 3.2 separately treats mismatched training and target step distributions (Corollary 4). Instead, the model has access to in-distribution (ID) atomic step data: samples (), where is the reasoning state before step and is the next incremental output. Here, denotes the total number of generation steps: the first are intermediate reasoning updates, and is the final answer.
Under this view, CoT does not require the model to learn the entire OOD mapping at once from scratch. Instead, it repeatedly applies a shared single-step predictor. At each step, the model reads the current state , generates containing new tokens, and updates the state by appending these tokens while keeping a fixed context length . CoT therefore converts a complex target mapping into a composition of reusable ID atomic transitions (Fig. 1). This motivates our central question:
When a model learns only atomic step transitions, can repeated CoT composition generalize to unseen multi-step OOD tasks, and how does the resulting error scale with the reasoning depth ?
Contributions We answer this question by developing a generalization framework for CoT-based task decomposition. First, we prove that the risk of the complex OOD task can be upper-bounded by the sum of risks over ID sub-tasks, scaled by a coefficient of order that is independent of . The coefficient results from deterministic argmax decoding together with the bounded sequence loss and the local error floor that a hard-decoding (argmax) error induces. CoT thus avoids fitting the unseen composite mapping directly and composes local transitions at test time.
Second, we derive a Rademacher-complexity bound for the multi-step setting. A naive analysis that treats each reasoning step independently would yield a linear dependence on . In contrast, because CoT applies the same predictor across all steps, we can analyze the combined step-level sample set and obtain a sublinear generalization-gap term scaling as , where is the number of training samples per atomic step distribution.
Third, we specialize the analysis to the NTP setting of autoregressive LLMs. We directly analyze the final target tokens of each atomic sequence and take the complete sequences as the sampling units. The resulting final-task risk bound keeps the best in-class step-level risk explicit and adds an estimation term of order . Appendix B.10 shows that the dependence cannot be improved for the sub-task empirical risk minimizer: a construction with , in which the per-step errors are coupled through the XOR accumulated over the chain, makes this minimizer incur an excess of when , and carries that excess through to the final task.
We further validate our theory through controlled experiments. We introduce Atom-Task, a symbolic compositional benchmark involving multi-step sequence operations, to isolate the effect of CoT on OOD compositional generalization. Experiments show that CoT-trained models generalize from shorter or constrained training chains to longer unseen compositions, whereas models trained without intermediate reasoning fail to capture the underlying compositional structure. Ablation results further show that explicitly tracking the current reasoning state is crucial, matching our theoretical requirement that each state contains sufficient information for the next atomic transition. Additional experiments on GSM8K, a benchmark of grade-school math word problems, support the same conclusion in real-world mathematical reasoning.
Under the CoT paradigm, the model does not predict the final answer directly via , but generates a chain of reasoning steps. We write for model-generated quantities and reserve the unhatted symbol for the ground truth. At step , the incremental output is , and the state updates by appending these tokens while discarding the first (sliding window):
thus maintaining the sequence length for all intermediate states, with ; the true state follows the same recursion with in place of , i.e., .
For a given complex task, any instance with and satisfies . There exists a ground-truth mapping (not necessarily within ) such that for all , implying generates the CoT sequence from to yield the target output .
Define the state transition as , representing the input state for the next step (note uses hard predictions for transitions). To distinguish from , let denote the composite CoT mapping , which encapsulates the -step reasoning process (note applies to the final state, outputting soft predictions for loss computation). Our learning goal is to minimize the population risk:
where is the probability measure associated with and is the sequence-level loss function that compares the model's soft predictions (in ) with the ground-truth output (converted from discrete tokens to one-hot vectors in ); the formal definition is provided in Section 3. This aims to identify a approximating , thereby generating the CoT sequence from to yield .
Notations denotes the -fold composition ( times in total). The final prediction is extracted via . For a sequence , denotes the subsequence from index to (inclusive), and denotes its -th component (or token). The operator denotes the concatenation of two sequences. Other key notations are summarized in Table 4 in Appendix B.
3 Theoretical Analysis: Task Decomposition for OOD Tasks
We analyze the generalization error of CoT reasoning by decomposing the risk of the complex OOD task into per-step risks (Section 3.1) and then bounding the generalization gap (Section 3.2).
Assumption 1 (Bounded and Lipschitz Loss Function). For a single token represented as a probability vector in , the token-level loss function is defined as the -clipped cross-entropy loss with a fixed clipping threshold , i.e., , where denotes the predicted probability vector and the ground-truth token. It is upper-bounded by , i.e., , and is -Lipschitz continuous with respect to the -norm of the predicted probability vector, i.e., for all probability vectors and ground-truth token . Without loss of generality, assume .
Remark 1. Assumption 1 is standard in learning theory [19–22]. Both requirements follow directly from clipping, which lower-bounds the probability assigned to the true token by ; both conditions are therefore satisfied by construction.
Definition 1 (Sequence Loss). For a predicted probability distribution and a ground-truth token sequence (represented as one-hot vectors in ), the sequence loss is defined as the average of the token-wise loss over these generated tokens, where denotes the probability vector at output position (the -th column of ) [23]:
3.1 Generalization Error Decomposition via CoT
For , let denote the joint distribution over the reasoning sequence , and let denote the marginal law of under (a state on the ground-truth trajectory is called an oracle state). Lemma 7 in Appendix B.2 shows that the step-level loss of an erroneous hard-decoded block is at least , a floor that is independent of the reasoning depth .
Theorem 1 (Generalization Error Decomposition). Under Assumption 1, we have:
where is the local error floor of Lemma 7.
Remark 2 (Implications of Theorem 1). Theorem 1 reveals the fundamental principle underlying CoT's OOD generalization: the generalization risk of a complex OOD task is dominated by the sum of per-step in-distribution risks, scaled by an coefficient that is independent of . This is qualitatively different from direct OOD learning, where one would attempt to bound the risk of the composite mapping directly—without decomposition, not only is the mapping inherently more complex, but more critically, we lack the direct samples , so the composite risk cannot be estimated from target data alone.
Theorem 1 bounds the target risk by the summed step-level risks, and the additive dependence on those risks is unavoidable in general. A step-level error can propagate along the chain through the state update rather than being averaged out, so the per-step risks accumulate in the final answer.
Remark 3 (Tightness of Theorem 1). Appendix B.9 constructs, for , a binary sliding-window task with a shared single-step predictor and a bounded sequence loss, for which
Consequently, the additive form of Theorem 1 is tight up to its depth-independent coefficient: when every step-level error reaches the final answer, the linear growth in of the summed risk is attained, and no argument that charges only per-step risks can remove it.
3.2 Bounds via Rademacher Complexity
Let be independent atomic pairs drawn from , with . All atomic examples are mutually independent, with the examples in drawn from ; each comes from some source realizing the same step-level skill distribution and need not lie on a common trajectory. Define and . To bound the generalization gap we use Rademacher complexity, writing and for the associated population and empirical risks (Appendix B.4). Applying Rademacher bounds to the steps separately makes the resulting gap grow linearly in . Since the same learner processes samples from all distributions, analyzing the combined set under a uniform capacity control makes both the deviation term and the complexity term (from to ) improve from to —analogous to multi-task learning, where sharing a hypothesis across related tasks improves generalization [24]. Extending the classical symmetrization lemma [19] to multiple distributions (Lemma 8 in Appendix B.4) gives:
Theorem 2 (Rademacher Complexity Bound). For any , with probability at least , uniformly over , we have:
where denotes the empirical Rademacher complexity on , is the induced bounded loss class, and is the bound of the sequence loss according to Assumption 1.
Remark 4. Sharing a single learner across all reasoning steps, under a uniform capacity control on the shared class, is what permits treating the step-level datasets as one combined sample of size : the same predictor is fitted to all steps, so the estimation dependence improves from to .
The following corollary records the resulting guarantee, first for a fixed predictor and then, after the ERM comparison, for the empirical risk minimizer; both proofs are in Appendix B.5.
Corollary 3 (Generalization Bound for Complex OOD Tasks). Under Assumption 1, with probability at least , for every ,
and for the sub-task , with ,
Remark 5 (Tightness of Corollary 3). The estimation term of Theorem 2 is order-tight, and its rate is inherited by Corollary 3: Appendix B.10 constructs a binary compositional task and a two-element class for which the sub-task ERM of Corollary 3 satisfies
i.e., its atomic excess, the gap between its summed step-level risk and the best in-class value of that sum, is of that order; and in that instance the atomic excess coincides with the excess on the final task, so the same bound holds for . In particular it is when . Two features of the construction are responsible: the per-step separation is amplified by a factor of at the final token, and the best-in-class per-step risk is , which makes the excess the identifiable quantity.
The preceding analysis addresses compositional OOD generalization: the target task is out of distribution, whereas the step-level distributions are not. When the step-level data are themselves drawn from shifted distributions , the decomposition carries over with one additional per-step term.
Corollary 4 (Atomic Distribution Shift). Let be the training distribution at step , let be the corresponding target oracle-state marginal, and let . Define
Then, with probability at least , for every ,
and for the sub-task , with ,
The proof is given in Appendix B.6. The corollary thus controls shifts between training and target step distributions; the drift of the model's own generated trajectory (its rollout) is handled only through the hard-decoding reduction and is not itself a distributional guarantee.
4 Specific Analysis: Results in the Next-Token Prediction Setting
In the preceding analysis the OOD generalization error of complex compositional tasks is upper-bounded by a sum of per-step in-distribution risks, with the gap governed by the Rademacher complexity of the shared hypothesis class. We now specialize this decomposition to the Next-Token Prediction (NTP) pretraining paradigm [23]—the standard training regime for LLMs—and derive a target-token bound with explicit depth, sample-size, and decoder-capacity dependence. Relative to the general analysis of Section 3.2 the additional ingredients are (i) a reduction from the final-task risk of free-running generation, in which the model conditions on its own outputs, to target-token risks under teacher forcing, in which every prefix is taken from the ground truth (Lemma 10, Appendix B.7) and (ii) an explicit evaluation of the complexity term for the decoder (Appendix A.2); the ERM comparison is the one already used in Corollary 3.
4.1 Problem Formulation
The model is a composition (representation learner and token predictor ). Here, the abstract single-step mapping is instantiated by the block predictor induced by successive next-token predictions via , and denotes the resulting -step final predictor. For step , let , where each is a complete sequence. We denote the teacher-forced context from before token by and set . Here and in Appendix A, denotes the complete-record length: an -token state followed by target tokens. Thus the general setup of Section 2 is instantiated with state length . Before each block, both oracle and generated histories retain their most recent tokens; within the block, the corresponding true or generated prefixes are appended autoregressively. The oracle record is therefore , and also denotes its induced distribution. This length convention leaves the general risk bounds unchanged.
For a complete sequence and its prefix , define the target-token loss, with g applied to the hidden state at the last position of its argument:
and let , where are the classes of the token predictor and of the representation learner. For , define
The complete sequences are the independent sampling units; tokens and prefixes within each sequence may be dependent. We abbreviate and .
Remark 6 (Teacher-Forced NTP and Free-Running Generation). The target-token loss in Eq. (1) is teacher-forced: it uses the true within-step prefixes, whereas runs freely and conditions on its own generated tokens. These block losses need not coincide. Lemma 10 in Appendix B.7 extends the first-error argument of Theorem 1 to individual tokens and gives with the same coefficient .
In this setting we write for the minimizer of and for the minimizer of , with and ; the resulting target-token excess is the NTP analogue of the atomic excess of Section 3.2.
4.2 Main Theoretical Results
Let denote the empirical Rademacher complexity of the target-token class on the combined sample of records, i.e., the quantity of Appendix B.1 with replaced by and one independent sign per record. Applying Theorem 2 to the target-token class yields the following deviation bound, uniform over the class.
Theorem 5 (Target-Token Risk Bound). Under Assumption 1, with probability at least , uniformly over and ,
The next corollary is the target-token counterpart of the ERM form of Corollary 3: for the empirical risk minimizer the empirical risks in the bound are replaced by the best-in-class population risks, at the price of paying the deviation twice.
Corollary 6 (ERM Final-Task Risk). Let and be defined as above. With probability at least ,
Under Assumption 2, the target-token complexity obeys the following bound. Deriving it (Appendix A.2) requires two ingredients beyond the general analysis of Section 3.2: the layerwise matrix-covering argument of [23], which we instantiate for our decoder block and then restrict to the final output rows, and a sequence-level loss-covering step of our own that charges one Rademacher sign per complete sequence rather than per generated token; the latter is what produces the normalization with .
where counts trainable parameters, are the layer count, head count and model dimension, and is the decoder-capacity factor (Appendix A.2); below we write for .
The resulting final-task bound is, for constants depending only on the fixed norm and normalization bounds of Assumption 2,
Since , for fixed model dimensions, norm bounds and clipping threshold the sample-dependent atomic excess contributes to the bound, where suppresses the logarithmic factors of and of the confidence term.
4.3 Discussion of the Final Bound
Depth and sample size. The target-token analysis treats the complete sequences as the independent observations while allowing arbitrary dependence among tokens within each sequence. Pooling these observations through one shared predictor under a uniform capacity control on the class yields an atomic excess of order —a accumulation across the composed steps, sublinear in place of the naive linear , times the statistical cost of a single atomic step—rather than the dependence obtained by analyzing the steps separately. We state this with the per-step sample size held fixed, so that the depth dependence is ; if the total budget is held fixed instead, then shrinks and the per-step sampling factor alone grows like , giving —linear behavior that comes from the shrinking per-step budget, not from any loss of the pooling gain. Equation (3) retains the best-in-class step-level risk in the complete final-task risk bound; after the depth-independent factor , the sample-dependent atomic excess contributes to the bound.
Context length and decoder capacity. We analyze the final-k-token loss directly, which permits dependence among tokens within a sequence; concentration is taken over the independent complete sequences. In the parameterized bound of Eq. (5), context length enters through evaluated at and also through if the trainable positional-embedding parameter count grows with .
Theoretical context Unlike prior work that restricts compositional analysis to 2-step cases without explicit parameter-dependent bounds [25], focuses on sub-task identification sample complexity rather than OOD error decomposition [26], proves that CoT reduces learning difficulty without generalization bounds [16], or addresses only single-distribution pretraining [23], our framework unites CoT error decomposition with a shared-hypothesis structure and directly controls target-token risk with reasoning-depth and decoder-capacity dependence. Maurer et al. [24] provide a shared-representation perspective for pooled estimation, whereas Li et al. [23] provide decoder covering-number tools for full-sequence NTP. We use the latter only to control the restricted final-k output class; the target-token risk bound itself is derived directly at the sequence level.
5 Experiments
We evaluate compositional generalization on Atom-Task, a task of multi-step operations on sequences; GSM8K experiments, extended setup details, and noise-robustness results are in Appendix C (GSM8K results in Section C.2).
Experimental Setup We introduce Atom-Task to isolate compositional reasoning, requiring sequential execution of atomic operations on symbolic sequences over a six-symbol alphabet (). We define five operations: Reverse, Substitute, Duplicate, Deduplicate, and Rotate.
Models and Datasets For the Atom-Task, we use Qwen3-4B. We design four training datasets: (1) Single-Step: 5k uniformly distributed one-step samples; (2) Three-Step: 1.66k three-step samples; (3) Mixed 3+5: 1,333 samples (833 three-step and 500 five-step; the latter use distinct operations, bridging length and combinatorial generalization); (4) Mixed 1-, 3-, and 5-Step: 4,000 one-step, 600 three-step, and 400 five-step samples (for each operation , a dedicated 5k-sample dataset excludes from all multi-step chains but keeps it in single-step data). For dataset-size accounting, an -step trajectory contributes step-level samples; this convention is used only to control the training-data budget. All models are evaluated on held-out 3-, 5-, 7-, and 9-step test sets (500 samples each). Full implementation details are given in Appendix C.
Table 1: Accuracy (%) by training data and test steps. All entries are means over 3 seeds (42, 2026, 12345); standard deviations are shown as subscripts.
| (a) CoT Setting | (b) No-CoT Setting | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Data | 3-step | 5-step | 7-step | 9-step | Data | 3-step | 5-step | 7-step | 9-step |
| 1-step | 91.80±2.24 | 63.13±4.15 | 36.27±7.87 | 22.27±3.67 | 1-step | 10.93±0.84 | 7.00±0.00 | 2.73±0.25 | 0.67±0.34 |
| 3-step | 99.33±0.25 | 95.73±0.68 | 88.87±1.54 | 79.27±3.03 | 3-step | 75.87±0.84 | 30.20±0.65 | 11.00±0.85 | 5.13±0.09 |
| Mix3+5 | 100.00±0.00 | 97.87±0.68 | 94.00±0.59 | 90.40±1.57 | Mix3+5 | 51.00±0.75 | 26.60±1.40 | 12.20±0.75 | 5.73±0.09 |
5.1 Main Results and Analysis
Short-to-Long Generalization & CoT vs. No-CoT. Table 1 compares CoT and No-CoT settings. While CoT with single-step data shows some compositionality, its degradation at longer test steps indicates the benefit of short-chain training data. Crucially, models trained on short chains (3-step/3+5 mixed) perform well on longer tasks; since the 5-step chains limit operation types, this implies models generalize stepwise decomposition patterns. In contrast, No-CoT degradation indicates a failure to capture compositional structures without intermediate steps, causing overfitting to spurious correlations.
Generalization to Unseen Combinations. Table 2(a) shows performance when specific operations are excluded from multi-step samples. Even with 9-step test sequences, all experimental groups maintain high accuracy, indicating that models can effectively compose and generalize operations encountered only in single-step data to multi-step tasks, thereby achieving compositional generalization. Table 2(b) again confirms the necessity of CoT: without it, performance remains consistently poor regardless of the excluded operation.
Table 2: Atom-Task: Accuracy (%) when an operation is excluded from multi-step samples. Entries are means over 3 seeds (42, 2026, 12345); standard deviations are shown as subscripts. Rev: Reverse, Dedup: Deduplicate, Sub: Substitute, Dup: Duplicate, Rot: Rotate.
| (a) CoT Setting | (b) No-CoT Setting | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Op | 3-step | 5-step | 7-step | 9-step | Op | 3-step | 5-step | 7-step | 9-step |
| Rev | 99.53±0.34 | 97.13±0.25 | 92.67±1.60 | 87.13±0.84 | Rev | 53.73±0.50 | 30.33±0.74 | 16.00±1.18 | 5.53±0.47 |
| Dedup | 97.87±0.47 | 93.27±1.11 | 86.20±1.82 | 76.73±0.66 | Dedup | 40.40±0.65 | 16.93±0.66 | 6.80±0.43 | 1.53±0.09 |
| Sub | 96.80±0.43 | 90.73±0.41 | 84.33±0.38 | 70.67±0.81 | Sub | 42.87±0.81 | 21.40±0.65 | 11.20±0.33 | 5.07±0.50 |
| Dup | 93.60±0.59 | 84.80±0.99 | 76.73±1.75 | 66.73±1.25 | Dup | 38.87±1.23 | 17.20±0.75 | 11.07±1.09 | 3.40±0.57 |
| Rot | 96.53±0.66 | 91.93±0.66 | 86.93±0.34 | 80.13±0.41 | Rot | 55.47±0.41 | 35.60±1.84 | 22.67±1.09 | 9.73±0.93 |
| CoT with Full State | CoT without Full State |
|---|---|
| Step 1: Task_Chain: [Dup, Rev, Sub] | Input: [xxx] | → Output: [xxx] | Task_Chain: [Rev, Sub]Step 2: Task_Chain: [Rev, Sub] | Input: [xxx] | → Output: [xxx] | Task_Chain: [Sub]Step 3: Task_Chain: [Sub] | Input: [xxx] | → Output: [xxx] | Task_Chain: []Final Answer: [xxx] | Step 1: [Dup] Task_Chain: [..., ..., ...] | Input: [...] | → Output: [xxx] | Task_Chain: [..., ...]Step 2: [Rev] Task_Chain: [..., ...] | Input: [...] | → Output: [xxx] | Task_Chain: [...]Step 3: [Sub] Task_Chain: [...] | Input: [...] | → Output: [xxx] | Task_Chain: []Final Answer: [xxx] |
Figure 2: Comparison of complete vs. incomplete CoT state recordings.
Effect of State Tracking in CoT. We ablate the CoT format by removing explicit state tracking (remaining tasks and input context) from the intermediate outputs (shown in Figure 2), such that the intermediate state can no longer carry complete information. Table 3 shows this ablation causes a consistent performance degradation (see the drop in average accuracy on the 7-step test set). This demonstrates that when fails to preserve the full state, multi-step decomposition is impaired. This validates our theoretical requirement that must carry complete state information.
Table 3: Format ablation: Accuracy (%) with vs. without explicit state tracking. Abl.: means over 3 seeds (42, 2026, 12345); Orig.: means over 3 seeds from Table 2.
| Step | Reverse | Rotate | Duplicate | Deduplicate | Substitute | Avg. (Abl.) | Avg. (Orig.) |
|---|---|---|---|---|---|---|---|
| 3-step | 98.47±1.05 | 95.53±2.08 | 92.33±4.97 | 96.93±1.43 | 94.53±4.20 | 95.56±1.41 | 96.87±0.23 |
| 5-step | 95.80±2.69 | 88.13±5.12 | 83.20±6.95 | 91.73±5.49 | 87.40±7.08 | 89.25±2.55 | 91.57±0.34 |
| 7-step | 79.40±10.16 | 67.80±2.61 | 67.47±6.13 | 62.47±4.43 | 60.67±20.02 | 67.56±4.77 | 85.37±0.61 |
Scaling Trends of Compositional Generalization We study performance as a function of reasoning depth, training sample size, and the number of inference-time examples, as summarized in Figure 3. For depth scaling (Figure 3a), error increases with , with diminishing increments for single-step training. Theorem 2 gives sublinear-in- control of the estimation term at fixed . For sample scaling (Figure 3b), increasing the sample size consistently reduces the test error rate, particularly for longer reasoning chains, which is qualitatively consistent with a smaller estimation error at larger sample sizes. Figure 3c varies the number of in-context examples at inference time rather than the theoretical sliding-window length . Detailed data for these scaling experiments are provided in Appendix C.1.3.
6 Further Related Work
CoT Prompting and Training Chain-of-Thought (CoT) enhances complex problem-solving by generating intermediate reasoning steps [1], improving performance on math benchmarks [27]. This led to extensions such as Tree of Thoughts [28], Graph of Thoughts [29], and Program of Thoughts [30], alongside robustness improvements via self-consistency [31], self-refinement [32], and retrieval-augmented generation [33]. Decomposition methods like Least-to-Most prompting [34] and Automatic CoT [35] further automate this process. However, most work focuses on inference-stage prompts, with limited discussion of CoT's intrinsic training mechanisms [18]. Training LLMs with CoT via supervised fine-tuning or reinforcement learning, on the other hand, enhances capability [3, 5, 36] and improves compositional generalization [25].



Figure 3: Each entry is a mean over 3 seeds (42, 2026, 12345). Atom-Task results when varying (a) test depth, (b) training sample size, and (c) inference-time examples; in (b) the horizontal axis is , where n is the sample size in units of the full budget (10%, 20%, 50%, 100%).
CoT Theoretical Analysis Theoretically, CoT increases Transformers' effective depth for serial problems [14, 15], and linear next-token predictors on CoT data can approximate Turing-computable functions [13]. Further analyses cover sample/time complexity [37], task decomposition [16], in-context learning bounds [17], and expressive power on arithmetic or gradient descent [38], with structural analysis showing reasoning internalized as combinatorial circuits [39, 40]. However, these studies are often qualitative or limited to localized tasks [11, 18]. More specifically, Joshi et al. [37] and Hanneke et al. [41] analyze the PAC (probably approximately correct) error of the final symbol under complete-trajectory supervision and realizability, whereas our setting supervises individual atomic steps through a target-token objective and provides explicit depth-dependent bounds. The analysis of [25] considers out-of-distribution generalization but is restricted to two-step tasks and lacks LLM-specific analysis. Maurer et al. [24] provide a shared-representation perspective for pooled estimation, whereas Li et al. [23] provide the decoder covering-number tool used for our restricted final-k output class.
7 Conclusion and Future Work
In this work we asked where the out-of-distribution capability of CoT comes from, and located it in the reuse of one transition model along the chain. The analysis separates a multiplicative price for inference errors, of order , set by the block length rather than by the number of steps, from a statistical cost that grows only as , since a single predictor serves all sub-tasks and can be assessed on a combined sample. In the token-by-token prediction regime this gives an end-to-end bound that is times the best-in-class summed step-level risk, plus an estimation term of order ; a matched construction for the sub-task ERM shows that the dependence is not an artefact of the analysis. The decomposition further indicates how learning reusable transitions can support compositional transfer—consistent with our experiments, where explicit state tracking proves essential. Taken together, the analysis sharpens our picture of how compositional OOD generalization arises under CoT, and that picture is not tied to autoregressive token-by-token output: it may also inform future analyses of agents that maintain and update an external memory.
Limitations & Future Work Our theory studies explicit CoT under supervised NTP-style training, where intermediate states and step-level transitions are observable; it excludes adaptive paradigms such as reinforcement fine-tuning and test-time search [11, 42–45], where trajectories may be selected, refined, or rewarded. Extending our decomposition framework to these settings is a natural future direction, and does not affect the mechanism identified here.
Acknowledgments and Disclosure of Funding
This work was supported by the Special Fund for Key Program of Science and Technology of Jiangsu Province (No. BG2024042); the Gusu Leading Talents Program for Innovation and Entrepreneurship (No. ZXL2025323); the Fundamental and Interdisciplinary Disciplines Breakthrough Plan of the Ministry of Education of China (No. JYB2025XDXM118); and the “111 Center” (No. B26023). This work was also partially supported by the Lee Kong Chian Fellowship awarded to Pan Zhou by Singapore Management University. We thank the NeurIPS reviewers for their valuable feedback and suggestions.
References
[1] Jason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma, Fei Xia, Ed Chi, Quoc V Le, Denny Zhou, et al. Chain-of-thought prompting elicits reasoning in large language models. Advances in neural information processing systems, 35:24824–24837, 2022.
[2] Xiang Yue, Xingwei Qu, Ge Zhang, Yao Fu, Wenhao Huang, Huan Sun, Yu Su, and Wenhu Chen. Mammoth: Building math generalist models through hybrid instruction tuning. In The Twelfth International Conference on Learning Representations, 2024.
[3] Longhui Yu, Weisen Jiang, Han Shi, Jincheng YU, Zhengying Liu, Yu Zhang, James Kwok, Zhenguo Li, Adrian Weller, and Weiyang Liu. Metamath: Bootstrap your own mathematical questions for large language models. In The Twelfth International Conference on Learning Representations, 2024.
[4] Peiyi Wang, Lei Li, Zhihong Shao, Runxin Xu, Damai Dai, Yifei Li, Deli Chen, Yu Wu, and Zhifang Sui. Math-shepherd: Verify and reinforce llms step-by-step without human annotations. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 9426–9439, 2024.
[5] Zhihong Shao, Peiyi Wang, Qihao Zhu, Runxin Xu, Junxiao Song, Xiao Bi, Haowei Zhang, Mingchuan Zhang, YK Li, Yang Wu, et al. Deepseekmath: Pushing the limits of mathematical reasoning in open language models. arXiv preprint arXiv:2402.03300, 2024.
[6] Fangxu Yu. Flow of reasoning: Efficient training of llm policy with divergent thinking. arXiv (Cornell University), 2024.
[7] Namgyu Ho, Laura Schmid, and Se-Young Yun. Large language models are reasoning teachers. In Proceedings of the 61st annual meeting of the association for computational linguistics (volume 1: long papers), pages 14852–14882, 2023.
[8] Seungone Kim, Se Joo, Doyoung Kim, Joel Jang, Seonghyeon Ye, Jamin Shin, and Minjoon Seo. The cot collection: Improving zero-shot and few-shot learning of language models via chain-of-thought fine-tuning. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pages 12685–12708, 2023.
[9] Team OpenAI. Learning to reason with llms. OpenAI Blog, 2024.
[10] Daya Guo, Dejian Yang, Haowei Zhang, Junxiao Song, Peiyi Wang, Qihao Zhu, Runxin Xu, Ruoyu Zhang, Shirong Ma, Xiao Bi, et al. Deepseek-r1: Incentivizing reasoning capability in llms via reinforcement learning. arXiv preprint arXiv:2501.12948, 2025.
[11] Kanishk Gandhi, Ayush K Chakravarthy, Anikait Singh, Nathan Lile, and Noah Goodman. Cognitive behaviors that enable self-improving reasoners, or, four habits of highly effective stars. In Second Conference on Language Modeling, 2025.
[12] Akshara Prabhakar, Thomas L Griffiths, and R Thomas McCoy. Deciphering the factors influencing the efficacy of chain-of-thought: Probability, memorization, and noisy reasoning. In Findings of the Association for Computational Linguistics: EMNLP 2024, pages 3710–3724, 2024.
[13] Guhao Feng, Bohang Zhang, Yuntian Gu, Haotian Ye, Di He, and Liwei Wang. Towards revealing the mystery behind chain of thought: a theoretical perspective. Advances in Neural Information Processing Systems, 36:70757–70798, 2023.
[14] William Merrill and Ashish Sabharwal. The expressive power of transformers with chain of thought. In The Twelfth International Conference on Learning Representations, 2024.
[15] Zhiyuan Li, Hong Liu, Denny Zhou, and Tengyu Ma. Chain of thought empowers transformers to solve inherently serial problems. In The Twelfth International Conference on Learning Representations, 2024.
[16] Chenxiao Yang, Zhiyuan Li, and David Wipf. Chain-of-thought provably enables learning the (otherwise) unlearnable. In The Thirteenth International Conference on Learning Representations, 2025.
[17] Alireza Amiri Bavandpour, Xinting Huang, Mark Rofin, and Michael Hahn. Lower bounds for chain-of-thought reasoning in hard-attention transformers. In International Conference on Machine Learning, pages 3274–3306. PMLR, 2025.
[18] Ben Prystawski, Michael Li, and Noah Goodman. Why think step by step? reasoning emerges from the locality of experience. Advances in Neural Information Processing Systems, 36:70926–70947, 2023.
[19] Shai Shalev-Shwartz and Shai Ben-David. Understanding machine learning: From theory to algorithms. Cambridge university press, 2014.
[20] Liyuan Liu, Biqin Song, Zhibin Pan, Chuanwu Yang, Chi Xiao, and Weifu Li. Gradient learning under tilted empirical risk minimization. Entropy, 24(7):956, 2022.
[21] Yuyang Deng, Junyuan Hong, Jiayu Zhou, and Mehrdad Mahdavi. On the generalization ability of unsupervised pretraining. In International Conference on Artificial Intelligence and Statistics, pages 4519–4527. PMLR, 2024.
[22] Liyuan Liu, Hong Chen, Chi Xiao, and Weifu Li. The consistency analysis of gradient learning under independent covariate shift. Neurocomputing, 635:129883, 2025.
[23] Zhihao Li, Xue Jiang, Liyuan Liu, Xuelin Zhang, Hong Chen, and Feng Zheng. On the generalization ability of next-token-prediction pretraining. In Forty-second International Conference on Machine Learning, 2025.
[24] Andreas Maurer, Massimiliano Pontil, and Bernardino Romera-Paredes. The benefit of multitask representation learning. Journal of Machine Learning Research, 17(81):1–32, 2016.
[25] Xinhao Yao, Ruifeng Ren, Yun Liao, Lizhong Ding, and Yong Liu. Compositional generalization from learned skills via cot training: A theoretical and structural analysis for reasoning. In The Fourteenth International Conference on Learning Representations, 2026.
[26] Amirhesam Abedsoltan, Huaqing Zhang, Kaiyue Wen, Hongzhou Lin, Jingzhao Zhang, and Mikhail Belkin. Task generalization with autoregressive compositional structure: Can learning from d tasks generalize to tasks? arXiv preprint arXiv:2502.08991, 2025.
[27] Karl Cobbe, Vineet Kosaraju, Mohammad Bavarian, Mark Chen, Heewoo Jun, Lukasz Kaiser, Matthias Plappert, Jerry Tworek, Jacob Hilton, Reiichiro Nakano, et al. Training verifiers to solve math word problems. arXiv preprint arXiv:2110.14168, 2021.
[28] Shunyu Yao, Dian Yu, Jeffrey Zhao, Izhak Shafran, Tom Griffiths, Yuan Cao, and Karthik Narasimhan. Tree of thoughts: Deliberate problem solving with large language models. Advances in neural information processing systems, 36:11809–11822, 2023.
[29] Maciej Besta, Nils Blach, Ales Kubicek, Robert Gerstenberger, Michal Podstawski, Lukas Gianinazzi, Joanna Gajda, Tomasz Lehmann, Hubert Niewiadomski, Piotr Nyczyk, et al. Graph of thoughts: Solving elaborate problems with large language models. In Proceedings of the AAAI conference on artificial intelligence, volume 38, pages 17682–17690, 2024.
[30] Wenhu Chen, Xueguang Ma, Xinyi Wang, and William W Cohen. Program of thoughts prompting: Disentangling computation from reasoning for numerical reasoning tasks. Transactions on Machine Learning Research, 2023.
[31] Xuezhi Wang, Jason Wei, Dale Schuurmans, Quoc V Le, Ed H Chi, Sharan Narang, Aakanksha Chowdhery, and Denny Zhou. Self-consistency improves chain of thought reasoning in language models. In The Eleventh International Conference on Learning Representations, 2023.
[32] Aman Madaan, Niket Tandon, Prakhar Gupta, Skyler Hallinan, Luyu Gao, Sarah Wiegreffe, Uri Alon, Nouha Dziri, Shrimai Prabhumoye, Yiming Yang, et al. Self-refine: Iterative refinement with self-feedback. Advances in neural information processing systems, 36:46534–46594, 2023.
[33] Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, et al. Retrieval-augmented generation for knowledge-intensive nlp tasks. Advances in neural information processing systems, 33:9459–9474, 2020.
[34] Denny Zhou, Nathanael Schärli, Le Hou, Jason Wei, Nathan Scales, Xuezhi Wang, Dale Schuurmans, Claire Cui, Olivier Bousquet, Quoc V Le, et al. Least-to-most prompting enables complex reasoning in large language models. In The Eleventh International Conference on Learning Representations, 2023.
[35] Zhuosheng Zhang, Aston Zhang, Mu Li, and Alex Smola. Automatic chain of thought prompting in large language models. In The Eleventh International Conference on Learning Representations, 2023.
[36] Eric Zelikman, Yuhuai Wu, Jesse Mu, and Noah Goodman. Star: Bootstrapping reasoning with reasoning. Advances in Neural Information Processing Systems, 35:15476–15488, 2022.
[37] Nirmit Joshi, Gal Vardi, Adam Block, Surbhi Goel, Zhiyuan Li, Theodor Misiakiewicz, and Nathan Srebro. A theory of learning with autoregressive chain of thought. In The Thirty Eighth Annual Conference on Learning Theory, pages 3161–3212. PMLR, 2025.
[38] Jianhao Huang, Zixuan Wang, and Jason D Lee. Transformers learn to implement multi-step gradient descent with chain of thought. In The Thirteenth International Conference on Learning Representations, 2025.
[39] Boshi Wang, Xiang Yue, Yu Su, and Huan Sun. Grokking of implicit reasoning in transformers: A mechanistic journey to the edge of generalization. Advances in Neural Information Processing Systems, 37:95238–95265, 2024.
[40] Eden Biran, Daniela Gottesman, Sohee Yang, Mor Geva, and Amir Globerson. Hopping too late: Exploring the limitations of large language models on multi-hop queries. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing, pages 14113–14130, 2024.
[41] Steve Hanneke, Idan Mehalel, and Shay Moran. Sample complexity of autoregressive reasoning: Chain-of-thought vs. end-to-end. arXiv preprint arXiv:2604.12013, 2026.
[42] Gokul Swamy, Sanjiban Choudhury, Wen Sun, Zhiwei Steven Wu, and J Andrew Bagnell. All roads lead to likelihood: The value of reinforcement learning in fine-tuning. arXiv preprint arXiv:2503.01067, 2025.
[43] Amrith Setlur, Nived Rajaraman, Sergey Levine, and Aviral Kumar. Scaling test-time compute without verification or rl is suboptimal. In International Conference on Machine Learning, pages 54058–54094. PMLR, 2025.
[44] Yang Yue, Zhiqi Chen, Rui Lu, Andrew Zhao, Zhaokai Wang, Shiji Song, and Gao Huang. Does reinforcement learning really incentivize reasoning capacity in llms beyond the base model? In The Thirty-ninth Annual Conference on Neural Information Processing Systems, 2025.
[45] Darsh J Shah, Peter Rushton, Somanshu Singla, Mohit Parmar, Kurt Smith, Yash Vanjani, Ashish Vaswani, Adarsh Chaluvaraju, Andrew Hojel, Andrew Ma, et al. Rethinking reflection in pre-training. arXiv preprint arXiv:2504.04022, 2025.
A Supplementary Details on NTP Setting
This section supplements Section 4 by defining the decoder architecture and the sampling units used in the target-token analysis. We use the convention of Section 4.1: denotes the complete-record length (and the maximum sequence length used by the decoder), the block-boundary state has length , and denotes the vocabulary.
A.1 Decoder-only Model Architecture
Contemporary Large Language Models (LLMs) predominantly utilize a decoder-only Transformer architecture. As described in Section 4.1, the composite model LM = goh consists of a representation learner and a token predictor . We formalize the representation learner as an -layer Transformer decoder, following the block description of [23, Eq. (4)], mapping an input token sequence to a hidden representation . The decoder applies to any prefix with , and the prediction head reads its last hidden state.
The process begins with an Embedding Layer, which converts discrete tokens into continuous vectors via:
where is the one-hot encoding of the tokens, is the token embedding matrix, and is the position embedding matrix. The core of the architecture consists of stacked Transformer-decoder blocks. For layer , the output is computed from via masked self-attention and feed-forward networks (FFN). Specifically, let be the number of attention heads and . The masked self-attention head is defined as:
Here, is a causal mask matrix where if and 0 otherwise. This mask ensures that the hidden state at position attends only to tokens at positions , so that the token at position is predicted from the state at position , thereby implementing the autoregressive property essential for Next-Token Prediction (NTP). The final output of the layer is given by:
where denote Layer Normalization and FFN() = is a two-layer feed-forward network with hidden width . The representation learner thus serializes the input into a deep representation .
The token predictor applies a linear projection to the hidden state at the last position, with and , mapping it to a probability distribution over the vocabulary .
A.2 Explicit Parameterization and Derivation of the Dimension-Dependent Bound
To quantify the Rademacher term in Corollary 6, we use the matrix-covering tools recorded in [23, Lemma C.3]. The statistical argument below is carried out directly for sequence-level losses.
Assumption 2 (Capacity and Regularity Constraints). For the -layer, -head decoder-only Transformer defined in Appendix A.1 (following [23, Eq. (4) and Assumption 4.14]), we assume:
-
The Layer Normalization operators (the operators and of Appendix A.1) are -Lipschitz continuous with respect to the 2-norm.
-
For all layers and attention heads , the scaled attention scores satisfy
- Each attention and feed-forward parameter matrix in layer has Frobenius norm at most .
The embedding matrices and output head also have bounded Frobenius norms. Let be a common upper bound for these norms and the . For the capacity estimate, normalization is a fixed rowwise operator whose output rows have norm at most , with fixed ; the feed-forward activation is 1-Lipschitz and vanishes at zero, as does ReLU. These are the usual bounded-row normalization and feed-forward conditions. The constants are fixed independently of the sample size and model dimensions. Let count all trainable scalar parameters, including token and positional embeddings whenever they are trained, and the output head.
The norm and Lipschitz upper bounds may be enlarged so that . Let and , and set
Here collects the per-layer amplification factors that a parameter perturbation of size accumulates over the blocks, and is the logarithm of the resulting covering-number bound; the individual factors are derived in the propagation estimate below.
For fixed norm, attention-score, and normalization bounds, . Below, constants in may depend on the fixed bounds , but not on .
Derivation of Eq. (4). We first record a coarse output cover, including every trainable matrix. A Frobenius ball of radius in has an -net, i.e., a set of points whose -neighbourhood covers the ball, of cardinality at most , by vectorization and [23, Lemma C.3]. Taking the product of these nets gives at most parameter representatives. Rather than composing the layerwise coverings of [23, Lemma 4.15 and Proposition 4.17], we propagate the approximation errors through the actual block of Appendix A.1, which keeps our normalization placement unchanged.
For completeness, write for block . A normalized row has norm at most , and the bounded feed-forward weights and residual therefore give a block-output row norm at most a constant times . Embedding rows satisfy the same type of bound. The causal softmax has Euclidean Lipschitz constant at most 1, and its attention matrix has operator norm at most . For two such admissible inputs, if every matrix in the two blocks differs by at most , multiplication of the query, key, value, and output matrices, followed by the residual and feed-forward operations, gives
where depends only on . Indeed, the query-key input perturbation is bounded by a constant times , its parameter perturbation by a constant times , and the remaining projections contribute at most a constant times ; the displayed bounds all these factors. The embedding approximation error is at most . Induction over the blocks and inclusion of the output head thus give, for the concatenated probability outputs on records,
This argument covers trainable embeddings as part of the parameter vector; fixed embeddings require no net. Covering representatives can be taken in the norm balls, and recentering in the original function class, if necessary, only changes numerical constants.
Let select the final prediction rows, aligned with the target labels as in Eq. (1). Every such row is computed from its teacher-forced prefix. Since
a full-output cover also covers the selected rows. For one record, write for its target-token loss with the labels fixed. The loss Lipschitz condition and Cauchy–Schwarz give
Hence the concatenated -dimensional loss vectors are approximated within (aggregating the records in ). Choosing , and setting , yields the covering-number bound
where denotes the covering number, i.e., the smallest cardinality of such a net in the norm, and is the restriction of to the sample . Center the loss vectors at any fixed member of . This leaves their empirical Rademacher complexity unchanged. The probability simplex has diameter , so each centered loss vector has norm at most . Dudley's entropy integral with the sequence-level normalization gives
The last step uses for . Since , the logarithmic factor is at most a constant times . On the other hand, and give and , hence
which dominates this factor. We have therefore obtained
Because , this also proves the coarser form used in the main text,
Here already counts the head and any trainable embeddings, so the first term alone is valid and the second is redundant; the displayed bound is a looser consequence of the preceding estimate. The proof uses one Rademacher sign per sequence and introduces one factor ; it never replaces these signs by independent signs for individual tokens.
Finally, gives
Substituting this in Eq. (3) gives Eq. (5). The coefficients and in the ERM bound are unchanged, and the reduction factor is applied once. Context length enters through and also through when the number of trainable positional-embedding parameters grows with .
A.3 Sampling Units
For each step , the dataset contains independently sampled complete sequences from the corresponding step-level skill distribution . These sequences need not be extracted from a shared trajectory; each is drawn independently from some real-world instance of the same skill. Dependence among tokens and prefixes within a complete sequence is unrestricted. This independent-record view is the idealization underlying the bounds. The Atom-Task experiments use the one-step and short-chain datasets specified in Section 5, including three- and five-step chains; the -step accounting serves only as a budget convention, not an independence assumption for transitions within a chain.
Table 4: Summary of Main Notations
| Symbol | Meaning |
|---|---|
| Vocabulary of size . | |
| hard() | Operator converting probability distributions to discrete tokens via argmax. |
| Target problem distribution, and data distribution for the -th reasoning step. | |
| Hypothesis class for single-step functions, learned single-step function, and ground-truth mapping (not necessarily within ). | |
| State transition mapping, , representing the input state for the next step. | |
| Hypothesis classes and functions for the token predictor and representation learner. | |
| Block predictor of successive next-token predictions by , and the resulting final -step predictor. | |
| Token-level loss (-clipped cross-entropy of Assumption 1) and sequence-level loss (average over the generated tokens). | |
| Clipping threshold of (), Lipschitz constant of w.r.t. the 2-norm, and bound of (hence of the sequence-level loss ). | |
| Sequence-loss class with . | |
| Total number of reasoning steps, state length in Section 2 (complete-record length in Section 4), number of generated tokens per step, number of samples per step. | |
| Final-task population risk, . | |
| is the law of input-answer pairs () with measure , and the joint law of the reasoning trajectory (). | |
| Target-token population and empirical risks of the block predictor at the -th reasoning step. | |
| Number of complete sequence samples, target-token loss, and its function class. | |
| Atomic training distribution and train-target discrepancy. | |
| Target-token atomic excess risk of the learned block predictor, where . | |
| Number of model parameters, number of layers, model dimension, number of attention heads, vocabulary size. | |
| Final- row selector and decoder-capacity factor. |
B Technical appendices and supplementary material
B.1 Technical Preliminaries
We provide the formal definitions for the theoretical frameworks used in our analysis.
PAC Learning We conduct analysis within the Probably Approximately Correct (PAC) framework, deriving explicit upper bounds for the generalization error that hold with probability at least .
Rademacher Complexity Rademacher complexity measures the richness of a function class . For a fixed sample , the empirical Rademacher complexity and expected Rademacher complexity are defined as
where are independent Rademacher random variables taking values with equal probability.
Total Variation Distance For two probability distributions and over the same measurable space , the total variation distance is defined as
Since , this distance bounds the discrepancy of Corollary 4: .
B.2 Local Error Floor of a Hard-Decoding Error
To derive the generalization error decomposition, we first record the loss incurred by a hard-decoding error at a single step.
Lemma 7 (Local Error Floor of a Hard-Decoding Error). For the autoregressive predictor , every state s and every ground-truth block satisfy
where is a lower bound on the sequence-level loss whenever the hard decoding differs from the ground truth.
Proof. Fix a state and a ground-truth block , and consider a token whose ground-truth index is and whose argmax index is . Then , and since probabilities are non-negative and sum to at most 1:
Since whenever and , the token-level clipped cross-entropy of every mispredicted token satisfies . A block is hard-decoding-erroneous only if at least one of its tokens is mispredicted, so averaging over the tokens yields , which is the claim.
Remark 7. The bound uses deterministic hard predictions: if the hard predictions at a step match the ground truth then no error is recorded, and otherwise the deviation is charged through the lower bound on the local loss. This is the fact used by the risk decomposition of Theorem 1.
B.3 Proof of Theorem 1 (Generalization Error Decomposition)
Proof. We aim to bound the generalization error . Let and let denote its density. Recall that the oracle state is written , whereas the free-running (FR) state generated by the model is written with a hat, and , so that
We first record a fact that will be used repeatedly: the FR and oracle trajectories coincide exactly up to the first hard-decoding error. Formally, let
with if no error occurs. Then on the event the two states agree, . Indeed, , and if while , then
so that
The claim follows by induction. We stress that this is a consequence of hard decoding alone—before the first error the two trajectories are identical rather than merely close—and that no Lipschitz or stability property of is used.
Next, we split the final-step risk at the first error. On the observation above gives , so the integrand is exactly the step- oracle loss; on it is bounded by . Pointwise,
and integrating against yields
where the last step uses that the events are disjoint.
It remains to charge each first-error probability to the corresponding atomic risk. Fix . Since , and since on the observation above gives , the event coincides with
Dropping the event , which can only increase the probability, and using that has law , we obtain
Finally, applying the error floor of Lemma 7 pointwise and taking the expectation over gives
Summing over thus gives
Finally, we combine the two estimates. Since for all , we may take ; then and imply
the single term is dominated by , and hence
Because each intermediate state is deterministically constructed from the prefix , the joint law of induced by is exactly the sub-task distribution ; marginalizing out the remaining variables, the bound becomes
which is the desired decomposition. The coefficient is thus depth-independent, with the local error floor of Lemma 7.
B.4 Proof of Theorem 2 (Rademacher Complexity Bound)
We first present the multi-distribution symmetrization lemma used in Section 3.2.
Lemma 8. Define the population risk and empirical risk . We have:
where , , and is the empirical Rademacher complexity of on .
We now prove Lemma 8.
Proof. Let be another set of i.i.d. samples, where and
Clearly, for all , the population risk is the expectation of the empirical risk over the ghost sample:
Therefore, for every , we have
Taking the supremum over on both sides, and using the fact that the supremum of an expectation is upper bounded by the expectation of the supremum (Jensen's inequality), we obtain
Taking expectation over on both sides yields
Next, we note that for each and , and are i.i.d. variables. Therefore, we can replace them without affecting the expectation. For any specific pair , let the summation over the remaining indices be denoted by . We have:
Let be a random variable such that . Combining the two equalities above, we obtain:
The inner expectation over splits the right-hand side into the two half-terms carrying signs + and -; the swap symmetry of the i.i.d. pair used in the preceding display shows that these two half-terms are equal, so the identity holds after averaging over . Repeating this process for all and , we have
Finally, applying the triangle inequality to the supremum:
The joint distribution of the Rademacher signs is invariant under sign reversal. Taking expectations in the preceding inequality and using this symmetry for the second term, we get
Substituting this result into the previous equation involving the 1/n factor, we obtain the final bound:
□
Lemma 9 (McDiarmid's Inequality[19]). Let be a domain, and let be a function of variables satisfying for some , for all and all :
Let be independent random variables taking values in . Then with probability at least :
Now we give the proof of Theorem 2.
Theorem 2 (Rademacher Complexity Bound). 1. Under the preceding conditions (where the step-level loss is bounded by ), with probability at least :
- Under the preceding conditions (where the step-level loss is bounded by ), with probability at least :
Proof. We first prove the first inequality. Since satisfies the conditions of Lemma 9 with variables and constant , applying Lemma 9 and then Lemma 8 yields that with probability at least :
For the second inequality, based on the first one, since also satisfies the conditions of Lemma 9 (with variables, constant ), with probability at least we have:
The reverse deviation follows by the same sign-symmetry argument. Using in place of converts the event and the factors above into the event and the factors of part 2, without changing the coefficients.
B.5 Proof of Corollary 3
Proof. Let , so that Theorem 2 bounds by uniformly over , on an event of probability at least .
First display. Theorem 1 gives ; replacing the population risks by their empirical counterparts costs at most U, and multiplying by gives the first display.
Second display. Let be the sub-task ERM and a population minimizer. Empirical optimality gives , so the atomic excess of obeys
Substituting into the bound of Theorem 1 gives the second display.
B.6 Proof of Corollary 4
Proof. By the oracle-prefix reduction of Theorem 1 the final-task risk is bounded by ; transferring each term via and applying Theorem 2 to the proves the first display. The second follows from the same comparison with the deviation paid once for each of and , and the transfer from to likewise paid twice.
B.7 Teacher-Forced NTP Reduction
Lemma 10 (Teacher-Forced NTP Reduction). Under Assumption 1, consider the NTP setting of Section 4.1, with deterministic argmax decoding and the same context-window rule for teacher-forced and free-running prefixes. Then
The risks on the right are the teacher-forced target-token risks defined in Eq. (1), whereas the risk on the left is evaluated on the free-running final prediction.
Proof. We follow the first-error argument of Theorem 1, now locating the first erroneous token within the first erroneous block. Fix , and let be the block predictor given by successive free-running next-token predictions via . As in Appendix B.3, let with joint law , and write
For , let be the oracle context before token , formed from and the true within-step prefix . Let be its free-running counterpart, formed from and . Both contexts use the same context-window rule, including truncation. For each oracle block, abbreviate its teacher-forced target-token loss by
This is Eq. (1) evaluated on the oracle record for step ; consequently, .
Define, as in the proof of Theorem 1,
with if no error occurs. The same induction gives on . On , let be the first position in block with . Then
Thus the erroneous hard prediction at this position is the argmax of the same probability vector that appears in the teacher-forced loss. The probability assigned to the true token is therefore at most 1/2. By the clipped cross-entropy calculation in Lemma 7,
This argument includes , so it also accounts for errors within the final output block.
Next, split the final-step loss according to whether any hard error occurs. On , all generated tokens agree with their oracle counterparts, including every prefix inside the final block, and hence
On , boundedness gives . Since and the events form a partition, pointwise we obtain
Finally, integrating against and using the oracle step marginals yields
which proves the claim. The argument uses equality of the two prefixes only before the first hard error; it does not identify the teacher-forced and free-running block losses after that error.
B.8 Proof of Theorem 5
Proof. Apply Theorem 2 to the bounded sequence-level class and the samples . Uniformly over and ,
which is Eq. (2).
For the ERM comparison, the three-term decomposition of the proof of Corollary 3 (Appendix B.5) applies verbatim with replaced by and by : writing for the target-token atomic excess and , empirical optimality and the two directions of the same uniform event give . Lemma 10 then gives
which is Eq. (3) after substituting . The projection and loss-cover argument in Appendix A.2 gives Eq. (4).
B.9 Tightness of the Additive Reduction
Proposition 11 (Tightness of the Additive Reduction). For every and every there is a task with the following complete description. Let , , , and draw
i.i.d. Bernoulli(p). The oracle trajectory is with for every , so that the oracle state before step is , whose first token is and whose last token is 0, and the step marginal is the law of induced by . The shared single-step predictor is the deterministic rule hard , with putting probability 1 on that token, so that the clipped cross-entropy of Assumption 1 charges 0 when the output is correct and otherwise. Writing and for the error flag ( is logical OR, and a local error puts the state in an absorbing error mode), this task satisfies
Proof. Verify the construction of the statement. On an oracle state the last token is 0, so the hard output equals and the error event is ; hence . Once an error occurs, its output 1 becomes the last token of every later state and the rule keeps emitting 1, so the final output is wrong exactly when , which gives
The union bound gives , and for , . Consequently
hence , which proves the order-tightness of the additive reduction.
What the construction shows. The witness combines two features: the local error events are independent across steps, and the state carries an absorbing error flag, so that the final output is wrong exactly when at least one local error has occurred. That event has probability for , of the same order as the sum of the step risks, while the per-step risk itself is . The additive form of Theorem 1 is therefore tight up to its depth-independent coefficient, and the linear-in-T growth of the bound—here the genuine linear growth of the target risk—cannot be removed by any refinement of the argument.
B.10 Tightness of the Atomic Excess
Proposition 12 (Tightness of the Atomic Excess). Fix with , , a sign , and ; the sign only selects which of the two hypotheses is favoured, and the constants below do not depend on it. Let , , , and let be the law on that assigns weight to each vector , , whose support is the cyclic block of consecutive coordinates (indices modulo ), and weight to , the same block with its leading coordinate flipped, so that has ones exactly on ; these weights sum to one. For , and , where denotes bitwise XOR in this construction (not sequence concatenation). The oracle trajectory is with and , , so that the state before step exposes as its first token and as its last token, and is the law of the -th oracle state and update. The two-element class is , with putting probability on token and on the other token, so that a correct output costs and a wrong one (clipping is inactive since ). With i.i.d. draws from each , the sub-task ERM satisfies, for with a universal constant ,
In this construction the atomic excess coincides with the final-task excess, so the same bound holds for , and it is when .
Proof. Verify the construction of the statement. The weights of are nonnegative and sum to one; each has odd parity and each even parity, and each coordinate lies in exactly of the and of the , so that for every coordinate
The oracle performs serial XOR, so the final target is . At atomic step , incurs loss when and otherwise; hence
Writing , Eq. (6) gives
The learned rollout uses the same at every step. Since is odd, its final hard output is , so the final loss is when and otherwise, and
Equations (7) and (8) show that the atomic excess equals the final excess exactly.
For training, step uses only the -th coordinate of its own draws, written , so the coordinates used are independent. The sub-task ERM therefore chooses
a majority test on independent Bernoulli variables with mean . The choice of guarantees , and standard binomial anti-concentration gives a universal such that . Whenever the wrong hypothesis is selected, Eq. (7) gives atomic excess . Therefore
By Eq. (8) the atomic excess equals the final-task excess here, so the same bound holds for it is when .
What the lower bound certifies. The quantity bounded below is exactly the sample-dependent atomic excess of the upper bound—the sub-task ERM's excess over the best in-class value—and it coincides with the final-task excess. Since the per-step best-in-class loss is ( ), the excess is identifiable in this instance. Hence the rate is not an artifact of estimation: it concerns the estimation component only and says nothing about the approximation term.
C Full Experiments
In this section, we provide the extended experimental details and additional results that complement the main text.
C.1 Atom-Task Experiments
C.1.1 Experimental Setup
Atom-Task Benchmark. To validate compositional reasoning capability, we introduce Atom-Task. This task requires the model to sequentially execute a series of atomic operations on a symbolic sequence multiple times, necessitating multi-step reasoning capabilities.
Symbol System and Atomic Operations. The input consists of sequences formed by 6 Greek letters . We define five basic operations (mapped to IDs t1–t5):
-
Reverse (t1): Reverses the order of the sequence.
-
Substitute (t2): Swaps symbols in pairs ().
-
Duplicate (t3): Duplicates each symbol consecutively.
-
Deduplicate (t4): Removes consecutive duplicates.
-
Rotate (t5): Moves the first element to the end.
Dataset Design and Distribution. A core challenge in compositional generalization is the distribution shift between training and testing. We design specific training datasets to investigate these effects.
Design Principles. Our training sets adhere to two core principles:
-
Dominance of atomic primitives: In Mixed 1-, 3-, and 5-Step, single-step samples constitute 80% of the training trajectories, supporting the acquisition of basic operations.
-
Controlled exposure to composition: Three- and five-step training chains provide structural patterns for compositional decomposition; in Mixed 3+5, the five-step chains use distinct operations, as specified in Section 5.
Training Datasets. To evaluate OOD generalization, we design four training datasets:
-
Single-Step: 5k uniformly distributed one-step samples.
-
Three-Step: 1.66k three-step samples.
-
Mixed 3+5: 1,333 samples (833 three-step and 500 five-step; the five-step chains use at most two distinct operations, bridging length and combinatorial generalization).
-
Mixed 1-, 3-, and 5-Step: For each operation , a dedicated 5k-sample dataset excludes from all multi-step chains but keeps it in single-step data. Specifically, it contains 4,000 one-step, 600 three-step, and 400 five-step samples (5,000 training trajectories, or 7,800 atomic transitions in total; see Table 5).
Balanced Supervision: While the sample sizes vary across settings, the number of atomic transitions is held roughly constant: the single-step, three-step and mixed 3+5 datasets each contain about 5,000 transitions (, and ), while the operation-exclusion dataset contains 7,800 and is compared across excluded operations under that same budget, which controls for confounding variables.
Test Sets. We evaluate on four test sets with increasing chain lengths: 3-step, 5-step, 7-step, and 9-step. Each set contains 500 unseen samples, requiring the model to perform compositional reasoning not explicitly memorized from training.
Table 5: Sample distribution in Ablation Datasets. Each dataset excludes a specific operation from multi-step chains. The 5,000 trajectories comprise 7,800 atomic transitions.
| Data | Total | Single-step | 3-step | 5-step |
|---|---|---|---|---|
| Ablation_no_* | 5,000 | 4,000 | 600 | 400 |
C.1.2 Implementation Details
For the Atom-Task, we use Qwen3-4B as the base model. Fine-tuning is performed using low-rank adaptation (LoRA; rank 16, alpha 32) for 3 epochs with a learning rate of . The maximum generation length (max_new_tokens) is set to 2048 to accommodate longer reasoning chains. All experiments are conducted on a single NVIDIA RTX 4090 GPU.
Parameter Efficiency: We employ LoRA with the following configuration:
-
Rank for a balance between expressiveness and parameter efficiency.
-
LoRA modules are applied to all linear layers within the attention and MLP blocks.
We employ a Chain-of-Thought training format, where the model is trained to explicitly predict the intermediate output after each atomic operation. For the “No-CoT” baseline, the model is trained to predict only the final output without intermediate states.
Reproducibility: For the main results (Table 1), both CoT and No-CoT entries are means across 3 random seeds (42, 2026, 12345), and the same 3 seeds are used for the operation-exclusion study, the format ablation, the noise tests, and the scaling points. For the format ablation (Table 3), the ablated CoT entries are means over 3 seeds and the original entries average the three-seed means of Table 2. Standard deviations are reported as subscripts and the seed setting is stated in each caption; differences of a few points between entries sharing a seed set should be read as indicative rather than as significance statements.
C.1.3 Details on Scaling Laws
To complement Figure 3, we provide the detailed accuracy numbers for training-sample scaling and inference-example scaling in Tables 6 and 7, respectively. All scaling experiments are conducted using the “Three-Step” training dataset and evaluated on held-out test sets, each reported point being a mean over 3 seeds (42, 2026, 12345).
Table 6: Accuracy (%) for Sample Size Scaling (). Each entry is a mean over 3 seeds (42, 2026, 12345).
| Prop. | 3-step | 5-step | 7-step |
|---|---|---|---|
| 10% | |||
| 20% | |||
| 50% | |||
| 100% |
Table 7: Accuracy (%) versus Number of Inference-Time Examples. Each entry is a mean over 3 seeds (42, 2026, 12345).
| Shots | 3-step | 5-step | 7-step |
|---|---|---|---|
| 0-shot | |||
| 1-shot | |||
| 2-shot | |||
| 3-shot |
C.1.4 Extended Results and Analysis
Robustness to Noise in Reasoning Steps. To evaluate the robustness of CoT training to data quality, we conduct a noise interference experiment on the Qwen3-4B model. We test: Multi-step (Pure 3-step), Multi-step (Mixed 3+5), and the w/o Substitute ablation setting. (Note: These earlier noise robustness experiments used max_new_tokens=1024, but the conclusions remain consistent).
Noise Injection Strategy. We define the basic unit of noise injection as a single inference step. We select a proportion of the total reasoning steps in the training set for interference. A standard reasoning step contains four discrete elements: the operation, the input state, the output state, and the remaining tasks. For each selected step, we randomly choose two of these four elements and perform either Tampering (replacing content with random symbols) or Deletion (emptying the content).
Table 8: Each entry is a mean over 3 seeds (42, 2026, 12345). Robustness to training noise (Qwen3-4B). Accuracy (%) under varying noise ratios. Each cell shows the result for the 3-step / 5-step / 7-step test sets.
| Noise Ratio | Multi-step (Pure 3-step) | Multi-step (Mix₃₊₅) | w/o Substitute |
|---|---|---|---|
Table 8 presents accuracy for 3-step / 5-step / 7-step test sets respectively. The results indicate strong robustness to noise in reasoning steps. Across all training configurations, increasing the noise ratio does not lead to significant performance degradation; accuracy remains largely consistent with the clean baselines reported in previous tables. In some cases, minor variations are observed but without a clear negative trend, suggesting that the learned compositional reasoning patterns are resilient to localized inconsistencies in the training data.
Table 9: GSM8K baseline and comparative results. Each entry is a mean over 3 seeds (42, 2026, 12345).
| Model | Experiment | Acc(%) |
|---|---|---|
| Llama2-7B | Untrained | 2.50 |
| CoT Training | 39.14±0.99 | |
| No-CoT Training | 8.16±2.50 | |
| Qwen2.5-3B | Untrained | 64.44 |
| CoT Training | 79.23±0.25 | |
| No-CoT Training | 19.41±1.17 |
Table 10: GSM8K accuracy under distribution shifts. Each entry is a mean over 3 seeds (42, 2026, 12345).
| Model | Shift Type | Acc(%) |
|---|---|---|
| Llama2-7B | Scale Shift | 38.74±0.70 |
| Complexity Shift | 36.57±0.17 | |
| Topic Shift | 37.51±2.14 | |
| Qwen2.5-3B | Topic Shift | 78.60±0.55 |
| Complexity Shift | 79.53±0.45 | |
| Answer Scale Shift | 79.10±0.25 |
C.2 GSM8K Experiments
To validate our findings on real-world, complex reasoning scenarios, we conduct experiments on the GSM8K benchmark using Llama2-7B and Qwen2.5-3B fine-tuned on MetaMathQA, a math instruction-tuning dataset (395K samples in total). This protocol evaluates a controlled within-family distribution shift from MetaMathQA to GSM8K rather than source-disjoint transfer. Due to computational constraints, we use 30,000 training samples for each experiment. For standard experiments (baseline and noise), we randomly sample these 30,000 instances from the full dataset; for distribution shift experiments, we select 30,000 samples according to specific shift criteria.
C.2.1 Experimental Setup
Models and Training. We employ Llama2-7B and Qwen2.5-3B as base models. Models are fine-tuned using LoRA (rank=16, alpha=16) for 1 epoch with a learning rate of and a maximum sequence length of 512. Training data is drawn from the MetaMathQA dataset. For baseline and noise experiments, we randomly sample 30,000 instances; for distribution shift experiments, we construct 30,000-sample subsets by filtering according to three shift indicators (Topic, Complexity, Answer Scale). All experiments are conducted on a single NVIDIA RTX 4090 GPU, and each experiment is run with three random seeds (42, 2026, 12345); the training data is identical across seeds, so reported standard deviations reflect model-side randomness.
Evaluation. All models are evaluated on the standard GSM8K test set. We report accuracy as the primary metric.
C.2.2 CoT vs. No-CoT & OOD Generalization
Baseline Comparison. As shown in Table 9, CoT training significantly boosts accuracy over untrained baselines, while No-CoT training yields only marginal improvements or even degradation.
Distribution Shift Experiments. In contrast to the random sampling used for baseline and noise studies, here we deliberately create distribution gaps by filtering 30,000 samples from MetaMathQA based on the following criteria:
-
Topic Shift (ood_domain): , where is the keyword set of the sample and the top-20 keyword set of GSM8K; this asymmetric keyword-novelty score measures the fraction of sample keywords absent from GSM8K's set, normalized by the union size.
-
Complexity Shift (ood_complexity): (absolute Z-score of the sample's step count relative to GSM8K's mean and standard deviation).
-
Answer Scale Shift (ood_magnitude): (one minus the GSM8K probability of the sample's answer magnitude bin).
The results in Table 10 show that performance remains robust across all shifts, with only mild fluctuations. This stability suggests that the compositional patterns learned via CoT can generalize to practical domains like mathematical reasoning.
Robustness to Reasoning Noise. We further test resilience to imperfect supervision by training on 30,000 randomly sampled CoT instances from MetaMathQA, injected with noise via a controlled strategy: (1) Sample-level probability: Each sample has a probability of being selected; (2) Single-step injection: For selected samples, noise is injected into a single randomly chosen reasoning step; (3) Noise type: ‘delete’ (removing the step content) or ‘wrong_number’ (modifying the numerical result), applied with equal probability (50%). This assesses the model’s ability to handle corrupted intermediate reasoning.
Table 11: Each entry is a mean over 3 seeds (42, 2026, 12345). GSM8K accuracy under training with different proportions () of reasoning noise. All models trained on 30,000 samples.
| Model | (Baseline) | ||||
|---|---|---|---|---|---|
| Llama2-7B | 39.14±0.99 | 39.20±0.56 | 39.73±1.02 | 37.63±0.88 | 37.66±0.89 |
| Qwen2.5-3B | 79.23±0.25 | 79.27±0.25 | 78.57±0.37 | 77.20±0.60 | 75.69±0.56 |
Both models exhibit strong resistance to noise (Table 11). Even with up to 50% of samples corrupted, accuracy fluctuates within a narrow band and never collapses. This suggests that the model is relatively insensitive to localized noise in intermediate steps and can still absorb the correct logical patterns.
C.2.3 Summary of Findings
The GSM8K experiments reveal three main patterns: (1) CoT training substantially improves accuracy over untrained and No-CoT baselines, highlighting the benefit of intermediate step supervision; (2) models are robust to significant reasoning noise, maintaining stable performance even when training data contains deleted or incorrect steps, indicating that supervision remains effective even when individual steps are corrupted; (3) models generalize effectively across distribution shifts in topic, complexity, and answer scale, with only mild accuracy fluctuations, indicating that the reasoning patterns acquired via CoT transfer robustly to real-world mathematical domains.