Introduction
Large Language Models (LLMs) have demonstrated impressive capabilities in specialized domains like mathematics and programming. However, achieving "general reasoning"—the ability to apply logical rigor across diverse and unseen problem spaces—remains a significant challenge. Current training paradigms often rely on massive amounts of structured data for math and code, but data for other reasoning domains like logical deduction or scientific inference is sparse. Furthermore, simply pre-training on raw code often fails to capture the underlying logic, as it is frequently obscured by syntax. CodeI/O addresses this "fundamental paradox" by transforming raw code into a structured "reasoning gym," decoupling logical flow from code-specific syntax.
The CodeI/O Framework
The core of CodeI/O is a pipeline that converts raw code into natural language input-output prediction tasks. This process involves several key stages:
- Transformation to Unified Format: Raw Python files are standardized into a structure with a main entry function, clear input/output descriptions, and a rule-based input generator.
- I/O Generation and Execution: For each function, multiple valid inputs are sampled and executed to obtain ground-truth outputs.
- Predictive Task Design: Models are trained on two primary challenges: predicting the output given code and input, and finding a feasible input given code and output.
- Chain-of-Thought (CoT) Rationales: Models are encouraged to generate natural language rationales explaining the execution process, synthesized using a teacher model (DeepSeek-V2.5).
A sophisticated variant, CODEI/O++, incorporates multi-turn revision. By leveraging the verifiability of code execution, the system provides feedback when a model's prediction is incorrect, allowing the model to refine its reasoning based on actual execution results.
Experimental Setup
The researchers curated a massive training set of 3.5 million samples derived from approximately 454,900 unique code files, sourced from CodeMix, PyEdu-R, and reputable algorithm repositories. Evaluation was conducted across 14 diverse benchmarks, including GSM8K/MATH (mathematics), BBH (logic), GPQA (science), and new benchmarks like LeetCode-O and BBH-ZH.
Results and Key Insights
CodeI/O demonstrates that code can serve as a powerful "reasoning primitive." By forcing models to internalize patterns like recursive decomposition and state-space searching through natural language explanation, the framework yields several key benefits:
- Universal Performance Gains: CODEI/O++ consistently outperformed base models (Qwen 2.5 Coder, LLaMA 3.1, Gemma 2) and those trained on other high-quality datasets. For instance, the Qwen 2.5 Coder 7B model's average score rose from 54.8 to 57.7.
- Logic and Symbolic Mastery: Significant improvements were observed in non-coding logic tasks (e.g., BBH), suggesting that code-based training generalizes effectively.
- Balanced Improvement: Unlike many fine-tuning methods that optimize for one domain at the expense of others, CodeI/O showed balanced gains across nearly all tested areas.
- The Power of Verification: The executable nature of code allows for a perfect feedback loop, which is central to the success of the multi-turn revision process in CODEI/O++.
Conclusion and Future Work
While CodeI/O shows great promise, it faces limitations regarding the complexity of executable tasks (e.g., constraints on data size and execution time) and diminishing returns in multi-turn revisions beyond the first turn. Future research will explore optimal data mixing strategies and extending the framework to more complex, long-horizon reasoning patterns. Ultimately, CodeI/O highlights that teaching LLMs to "show their work" through structured logic execution is a highly effective path toward general reasoning.
Summary updated