Table of Contents
Fetching ...

Outcome-Based RL Provably Leads Transformers to Reason, but Only With the Right Data

Yuval Ran-Milo, Yotam Alexander, Shahar Mendel, Nadav Cohen

TL;DR

This work analyzes how sparse terminal rewards in outcome-based RL guide gradient flow to induce multi-step reasoning in transformers, focusing on a synthetic chain-identification task. The authors develop a gradient-flow framework for single-layer transformers, proving that reasoning is necessary and sufficient for solving the task, and showing that the data distribution—specifically, nonzero mass on easy examples—is critical for efficiently learning a chain-traversal strategy and generalizing to longer chains. Experiments on synthetic data and fine-tuning an LLM on mathematical tasks validate the theory: models trained with simple examples learn efficient, interpretable reasoning and generalize to harder instances, while excluding simple examples prevents CoT emergence. The results illuminate how data composition and sparse rewards shape the emergence of chain-of-thought behavior, with practical implications for curriculum design and post-training data strategies that bootstrap complex reasoning in real-world models.

Abstract

Transformers trained via Reinforcement Learning (RL) with outcome-based supervision can spontaneously develop the ability to generate intermediate reasoning steps (Chain-of-Thought). Yet the mechanism by which sparse rewards drive gradient descent to discover such systematic reasoning remains poorly understood. We address this by analyzing the gradient flow dynamics of single-layer Transformers on a synthetic graph traversal task that cannot be solved without Chain-of-Thought (CoT) but admits a simple iterative solution. We prove that despite training solely on final-answer correctness, gradient flow drives the model to converge to a structured, interpretable algorithm that iteratively traverses the graph vertex-by-vertex. We characterize the distributional properties required for this emergence, identifying the critical role of "simple examples": instances requiring fewer reasoning steps. When the training distribution places sufficient mass on these simpler instances, the model learns a generalizable traversal strategy that extrapolates to longer chains; when this mass vanishes, gradient-based learning becomes infeasible. We corroborate our theoretical results through experiments on synthetic data and with real-world language models on mathematical reasoning tasks, validating that our theoretical findings carry over to practical settings.

Outcome-Based RL Provably Leads Transformers to Reason, but Only With the Right Data

TL;DR

This work analyzes how sparse terminal rewards in outcome-based RL guide gradient flow to induce multi-step reasoning in transformers, focusing on a synthetic chain-identification task. The authors develop a gradient-flow framework for single-layer transformers, proving that reasoning is necessary and sufficient for solving the task, and showing that the data distribution—specifically, nonzero mass on easy examples—is critical for efficiently learning a chain-traversal strategy and generalizing to longer chains. Experiments on synthetic data and fine-tuning an LLM on mathematical tasks validate the theory: models trained with simple examples learn efficient, interpretable reasoning and generalize to harder instances, while excluding simple examples prevents CoT emergence. The results illuminate how data composition and sparse rewards shape the emergence of chain-of-thought behavior, with practical implications for curriculum design and post-training data strategies that bootstrap complex reasoning in real-world models.

Abstract

Transformers trained via Reinforcement Learning (RL) with outcome-based supervision can spontaneously develop the ability to generate intermediate reasoning steps (Chain-of-Thought). Yet the mechanism by which sparse rewards drive gradient descent to discover such systematic reasoning remains poorly understood. We address this by analyzing the gradient flow dynamics of single-layer Transformers on a synthetic graph traversal task that cannot be solved without Chain-of-Thought (CoT) but admits a simple iterative solution. We prove that despite training solely on final-answer correctness, gradient flow drives the model to converge to a structured, interpretable algorithm that iteratively traverses the graph vertex-by-vertex. We characterize the distributional properties required for this emergence, identifying the critical role of "simple examples": instances requiring fewer reasoning steps. When the training distribution places sufficient mass on these simpler instances, the model learns a generalizable traversal strategy that extrapolates to longer chains; when this mass vanishes, gradient-based learning becomes infeasible. We corroborate our theoretical results through experiments on synthetic data and with real-world language models on mathematical reasoning tasks, validating that our theoretical findings carry over to practical settings.
Paper Structure (64 sections, 78 theorems, 580 equations, 4 figures, 3 tables)

This paper contains 64 sections, 78 theorems, 580 equations, 4 figures, 3 tables.

Key Result

Theorem 1

Under standard complexity-theoretic assumptions (see app:complexity_assumption), for any fixed depth $d \in {\mathbb N}$, there exist $n \in {\mathbb N}$, a distribution ${\mathcal{Q}}$ over $[n-1]$, and $c \in {\mathbb R}_{> 0}$ such that for all parameters $\theta = \{(A_i, V_i)\}_{i=1}^D$:

Figures (4)

  • Figure 1: Illustration of the chain identification task. The input contains edges forming two disjoint chains $\mathcal{C}_a = (a_1, \ldots, a_n)$ and $\mathcal{C}_b = (b_1, \ldots, b_n)$, and a starting vertex $v_{\text{start}}$ (here $a_k$). The task is to identify the terminal vertex of the chain containing $v_{\text{start}}$ (here $a_n$).
  • Figure 2: Training curves for models with chain size $m = 5$, where starting vertices are sampled uniformly from the first $i$ vertices. All models are evaluated on instances starting from the first vertex (requiring full chain traversal). Excluding simpler examples from training (smaller $i$) drastically impairs learning performance.
  • Figure 3: Test accuracy on 15-Hard, as a function of training steps. The model trained on $15$-Uniform successfully learns the task, while the model trained on $15$-Hard fails to learn, with accuracy remaining near zero. This corroborates the necessity of simple examples for learning complex reasoning tasks.
  • Figure 4: Randomly generated examples from the test set showing input-completion pairs for the mathematical reasoning task. The input contains a shuffled list of affine equations with one constant assignment (shown in blue) and asks for the value of a target variable (shown in red). The model generates its reasoning process within <thinking> tags, identifying the dependency chain and performing step-by-step calculations, then outputs the final answer within <answer> tags.

Theorems & Definitions (168)

  • Theorem 1
  • proof : Proof sketch (full proof in \ref{['app:no_single_step']})
  • Proposition 1
  • proof : Proof sketch (full proof in \ref{['app:traverse_chain']})
  • Proposition 2
  • proof : Proof sketch (full proof in \ref{['app:inefficient_solution']})
  • Definition 1
  • Theorem 2
  • proof : Proof sketch (full proof in \ref{['app:dyn_learn']})
  • Theorem 3
  • ...and 158 more