Transformers Provably Solve Parity Efficiently with Chain of Thought
Juno Kim, Taiji Suzuki
TL;DR
The paper analyzes how transformers can be trained to solve parity by recursively generating intermediate states, i.e., chain-of-thought reasoning. It proves that parity is hard for any finite-sample gradient-based method without intermediate supervision, and shows that teacher forcing enables parity to be learned in a single gradient update. It further demonstrates that end-to-end CoT with data augmentation and self-consistency checks can achieve efficient learning in a logarithmic number of steps, even without teacher forcing. Numerical experiments support the theory, revealing a phased, hierarchical learning process and the value of process supervision for complex multi-step tasks. Overall, the work provides a theoretical blueprint for enabling task decomposition and robust multi-step reasoning in transformers through CoT training.
Abstract
This work provides the first theoretical analysis of training transformers to solve complex problems by recursively generating intermediate states, analogous to fine-tuning for chain-of-thought (CoT) reasoning. We consider training a one-layer transformer to solve the fundamental $k$-parity problem, extending the work on RNNs by Wies et al. (2023). We establish three key results: (1) any finite-precision gradient-based algorithm, without intermediate supervision, requires substantial iterations to solve parity with finite samples. (2) In contrast, when intermediate parities are incorporated into the loss function, our model can learn parity in one gradient update when aided by \emph{teacher forcing}, where ground-truth labels of the reasoning chain are provided at each generation step. (3) Even without teacher forcing, where the model must generate CoT chains end-to-end, parity can be learned efficiently if augmented data is employed to internally verify the soundness of intermediate steps. Our findings, supported by numerical experiments, show that task decomposition and stepwise reasoning naturally arise from optimizing transformers with CoT; moreover, self-consistency checking can improve multi-step reasoning ability, aligning with empirical studies of CoT.
