ToRL: Scaling Tool-Integrated RL

Xuefeng Li, Haoyang Zou, Pengfei LiuarXiv 2025 · DOI

Introduction

While Chain-of-Thought (CoT) reasoning has significantly enhanced the capabilities of Large Language Models (LLMs), these models often falter when faced with tasks requiring high-precision calculations or complex algorithmic execution. Tool-Integrated Reasoning (TIR)—where models generate and execute code to solve problems—has emerged as a powerful solution. However, traditional TIR approaches typically rely on a Supervised Fine-Tuning (SFT) phase, which can constrain the model to human-designed, potentially sub-optimal tool-use patterns.

ToRL (Tool-Integrated Reinforcement Learning) introduces a paradigm shift by demonstrating that base models can autonomously learn to utilize computational tools like Python interpreters through pure reinforcement learning (RL). By bypassing the SFT stage, ToRL allows models to explore a broader strategy space, leading to superior reasoning performance and emergent metacognitive behaviors.

The ToRL Framework

The ToRL framework integrates a Python interpreter directly into the RL optimization loop. Unlike standard training pipelines, the process begins directly from Qwen2.5-Math base models, forcing the model to "discover" the utility of code through trial-and-error.

Technical Components

  • Algorithm: The system utilizes Group Relative Policy Optimization (GRPO), an efficient RL algorithm designed for reasoning tasks.
  • Sandbox Fusion: During rollout, the generation process is paused when the model produces specific output tags. The preceding code block is executed in a secure sandbox, and the results are immediately fed back into the model's context.
  • Reward Mechanism: A rule-based system provides positive reinforcement (+1) for correct answers and negative reinforcement (-1) for incorrect ones. Notably, the researchers found that penalizing unexecutable code was counterproductive, as it discouraged the model from attempting complex algorithmic solutions.
Example of Tool-Integrated Reasoning (TIR) where the model generates and executes Python code.

Experimental Setup

The models were trained on a curated dataset of 28,740 questions from NuminaMATH, MATH, and DeepScaleR, balanced for difficulty using the LIMR technique. Evaluation was conducted across elite-level benchmarks, including AIME24, AIME25, and MATH500.

Key Results and Scaling

ToRL demonstrates significant performance gains over traditional RL and SFT-based baselines. The ToRL-7B model achieved a 43.3% accuracy on AIME24, representing a 14% improvement over standard RL and outperforming many 32B-parameter models trained with conventional methods.

AIME24 Accuracy scaling for ToRL 1.5B and 7B models compared to baselines.

As training progressed, the models exhibited a clear preference for tool use; the "Code Ratio" (the frequency of choosing to use code) rose from 40% to 80%. Simultaneously, the "Pass Ratio" of the generated code improved, indicating that the model was learning to write more reliable and executable scripts.

Emergent Metacognition and Insights

A primary finding of the ToRL research is the emergence of "metacognitive" behaviors. Without explicit instruction, models learned to:

  1. Self-Correct: Identify discrepancies between natural language reasoning and code output.
  2. Cross-Validate: Use code to verify a hypothesis generated through text.
  3. Self-Regulate: Abandon ineffective code patterns in favor of more robust logic.

This "SFT-free" advantage suggests that allowing models to explore the environment without the bias of human demonstrations leads to more efficient and creative problem-solving strategies.

Conclusion and Future Work

ToRL proves that RL-from-base is a viable and powerful path for teaching LLMs to use tools. While the current implementation faces challenges regarding inference latency and tool-call limits, the success in the mathematical domain provides a blueprint for scaling autonomous tool integration to broader tasks like API interaction and web browsing. Future research will focus on reducing the computational overhead of the iterative "think-code-execute" loop and exploring the limits of multi-turn tool interaction.

Summary updated

BibTeX
@misc{li2025torl,
  author = {Xuefeng Li and Haoyang Zou and Pengfei Liu},
  title = {{ToRL: Scaling Tool-Integrated RL}},
  year = {2025},
  eprint = {2503.23383},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.23383},
}
Figure