A Theory for Length Generalization in Learning to Reason
Changnan Xiao, Bing Liu
TL;DR
This work addresses length generalization (LG) in reasoning tasks by modeling reasoning steps as directed acyclic graphs (DAGs). It introduces the maximal input distance $R$ and the stronger notion of $(n,r)$-consistency to characterize when LG is achievable, showing LG is possible if $R<\infty$ or, in the harder $R=\infty$ case, if the problem is $(n,r)$-consistent. The theory is validated with experiments in a vanilla Transformer across parity, addition, and multiplication tasks, demonstrating LG under the proposed conditions and highlighting how CoT formulations influence learnability. The results provide a theoretical foundation connecting CoT-based reasoning with generalization across problem lengths, with implications for designing representations and training regimes that achieve robust long-horizon reasoning.
Abstract
Length generalization (LG) is a challenging problem in learning to reason. It refers to the phenomenon that when trained on reasoning problems of smaller lengths or sizes, the resulting model struggles with problems of larger sizes or lengths. Although LG has been studied by many researchers, the challenge remains. This paper proposes a theoretical study of LG for problems whose reasoning processes can be modeled as DAGs (directed acyclic graphs). The paper first identifies and proves the conditions under which LG can be achieved in learning to reason. It then designs problem representations based on the theory to learn to solve challenging reasoning problems like parity, addition, and multiplication, using a Transformer to achieve perfect LG.
