TL;DR
Large Language Models (LLMs) struggle with complex math. This paper introduces CoRT, a framework that teaches LLMs to effectively use code interpreters for mathematical reasoning. CoRT significantly improves accuracy and reduces token usage by strategically guiding LLMs with "hints" during training.
What Problem Does This Paper Address?
Large Reasoning Models (LRMs) have shown impressive capabilities in natural language reasoning, but they falter when it comes to complex mathematical operations. While integrating code interpreters (CIs) can help, simply combining them with LLMs is inefficient. The core challenge is teaching LLMs when and how to leverage CIs effectively, bridging the gap between their internal text-based reasoning and the external, deterministic knowledge provided by code execution. This includes overcoming issues like delayed code computation and distrust of CI outputs.
Methods
The paper proposes CoRT (Code-integrated Reasoning within Thinking), a post-training framework to teach LRMs to use CIs. Key components include:
- Hint-Engineering: A novel data synthesis technique. Instead of just prompting the model to use code, CoRT strategically inserts specific "hints" at crucial points in the reasoning process. These hints guide the LLM to understand CI outputs and use them more efficiently, addressing issues like delayed computation and distrust.
- Data Synthesis: To combat data scarcity, CoRT uses "Hint-Engineering" to create high-quality, code-integrated reasoning data. They manually curated 30 samples and also generated data using a "prompt-hint" method.
- Post-training Pipeline: CoRT employs a multi-stage training process:
- Cold Start (Prompt-Hint): An initial method to encourage code usage by adding a general hint.
- Supervised Fine-Tuning (SFT): Training on synthesized data.
- Rejection Fine-Tuning (RFT): Further refining the model by filtering out trajectories with incorrect answers or inefficient code usage.
- Reinforcement Learning (RL): Used for smaller models to further optimize code-integrated reasoning.
Datasets
The paper utilizes and generates data from several sources:
- Training Data:
- Manually created 30 high-quality samples for Hint-Engineering.
- Synthesized data using the "prompt-hint" method from the STILL3 dataset (820 math problems) and R1.
- Data for strong-to-weak distillation from AIME (prior to 2024), MATH (Level 5 training set), and Numina-math.
- Evaluation Datasets:
- AIME24 & AIME25: American Invitational Mathematics Examination problems.
- AMC23: American Mathematics Competition problems.
- MATH500: A subset of the PRM800K dataset.
- OlympiadBench: Problems from elite mathematics competitions.
Key Insights and Ideas
- Hint-Engineering is Crucial: Simply prompting LLMs to use code isn't enough. Strategic hints at the right moments are key to efficient and effective CI integration.
- Data Quality Over Quantity: A small set of high-quality, carefully engineered data (like the 30 samples for Hint-Engineering) can yield significant improvements.
- RL Enhances Reasoning Ceiling: Reinforcement learning, especially after SFT and RFT, substantially boosts performance, particularly for smaller models, by improving their ability to consistently find correct solutions.
- Code Usage Evolves: RL training doesn't just improve performance; it shapes how models use code. Hint-Engineering models evolve towards efficiency (less code, more effective), while Prompt-Hint models evolve towards more integration with improving effectiveness.
- Difficulty Matters More Than Topic: For RL training, query difficulty is a more significant factor than topic distribution for achieving superior final performance.
Key Results
- Accuracy Improvements: Hint-Engineering models achieved 4% absolute improvement on DeepSeek-R1-Distill-Qwen-32B and 8% on DeepSeek-R1-Distill-Qwen-1.5B across five challenging math datasets.
- Token Efficiency: Hint-Engineering models used significantly fewer tokens: ~30% fewer for the 32B model and ~50% fewer for the 1.5B model compared to natural language models. For example, Hint-Engineering-RFT-32B achieved comparable accuracy to QwQ-32B while using 50% fewer tokens.
- Pass@k Performance: RL significantly raised the Pass@k curves for both Prompt-Hint and Hint-Engineering models, indicating improved consistency and fewer attempts needed for correct solutions.
- Lightweight Model Performance: Hint-Engineering-SFT achieved 22.7% accuracy with a 4k token budget on AIME24, nearly double that of the base model and Prompt-Hint-SFT.
Limitations and Future Work
- Computational Requirements: The CoRT framework, especially with larger models like 32B, has significant computational demands for training and inference, which may limit broader accessibility.
- Model Dependence: The current work uses DeepSeek-R1-Distill-Qwen models. Future work could explore CoRT's effectiveness on other LRM architectures.
- Broader Tool Integration: While CoRT focuses on code interpreters, future research could explore synergies with other external tools and language models.
- Responsible Deployment: The authors acknowledge potential misuse of enhanced reasoning capabilities and recommend access controls and transparency about system limitations. They encourage future work on responsible deployment strategies.
Summary updated