arXiv:2611.06438cs.LGNov 2026

Manuscript Offprint

arXiv:2611.06438

Understanding the Out-of-Distribution Generalization of Chain-of-Thought Reasoning in LLMs

Nuo-Jing Liang, Xiao-Tong Yuan, Pan Zhou

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 TT denote the number of reasoning steps in the target task, nn the number of training samples per sub-task, and kk 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 O(k)\mathcal{O}(k) that is independent of TT, although the summed risk itself may still grow with TT. A Rademacher-complexity analysis further shows that the estimation term is of order O(T/n)\mathcal{O}(\sqrt{T/n}), rather than linear in TT, 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 O(k)\mathcal{O}(k), plus an estimation term of order O~(kT/n)\tilde{\mathcal{O}}(k\sqrt{T/n}). 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 Ω(T/n)\Omega(\sqrt{T/n}) when T≤nT \leq n. 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

Figure 1: CoT as compositional OOD generalization. Left: without CoT, the model must learn a direct mapping from input z0z_0 to final answer ΔzT\Delta z_T, whose target distribution may be unavailable during training. With CoT, the same predictor is repeatedly applied to in-distribution step distributions, mapping each state zi−1z_{i-1} to update Δzi\Delta z_i. 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 z0z_0 to a final answer ΔzT\Delta z_T, while neither complete reasoning trajectories (z0,Δz1,…,ΔzT−1,ΔzTz_0, \Delta z_1, \dots, \Delta z_{T-1}, \Delta z_T) nor direct input-output pairs (z0,ΔzTz_0, \Delta z_T) 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 (zi−1,Δziz_{i-1}, \Delta z_i), where zi−1z_{i-1} is the reasoning state before step ii and Δzi\Delta z_i is the next incremental output. Here, TT denotes the total number of generation steps: the first T−1T-1 are intermediate reasoning updates, and ΔzT\Delta z_T 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 zi−1z_{i-1}, generates Δzi\Delta z_i containing kk new tokens, and updates the state by appending these tokens while keeping a fixed context length mm. 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 TT?

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 O(k)\mathcal{O}(k) that is independent of TT. The coefficient results from deterministic argmax decoding together with the bounded sequence loss and the local error floor (log⁡2)/k(\log 2)/k 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 TT. 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 O(T/n)\mathcal{O}(\sqrt{T/n}), where nn 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 kk target tokens of each atomic sequence and take the N=nTN = nT 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 O~(kT/n)\widetilde{\mathcal{O}}(k\sqrt{T/n}). Appendix B.10 shows that the T/n\sqrt{T/n} dependence cannot be improved for the sub-task empirical risk minimizer: a construction with k=1k=1, in which the per-step errors are coupled through the XOR accumulated over the chain, makes this minimizer incur an excess of Ω(T/n)\Omega(\sqrt{T/n}) when T≤nT \leq n, 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 zi−1z_{i-1} 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.

References (42)