arXiv:2502.07316cs.CLcs.AI2025-02ICML被引 59

用代码输入输出预测法提炼通用推理模式,提升大模型多领域推理能力

CodeI/O: Condensing Reasoning Patterns via Code Input-Output Prediction

  • 将代码转为自然语言输入输出预测任务,提取通用推理逻辑
  • 在符号、科学、数学等5类推理任务上均实现稳定提升
  • 支持多轮修正生成更优推理链,适合需要强推理的AI研究者

推理是大语言模型的核心能力。现有研究多聚焦于数学或代码生成等特定技能,但多数推理任务因训练数据稀疏且碎片化而难以提升。为此,我们提出CodeI/O,一种通过将原始代码转换为代码输入输出预测格式,系统提炼上下文相关代码中蕴含的多样化推理模式的新方法。模型在仅用自然语言作为思维链(CoT)的情况下,学习根据代码和测试用例预测输入/输出,从而暴露于通用推理原语——如逻辑流程规划、状态空间搜索、决策树遍历与模块化分解,同时将结构化推理与代码语法解耦,并保持程序严谨性。实验表明,CodeI/O在符号、科学、逻辑、数学与数值、常识推理任务上均带来一致性能提升。通过匹配真实输出或使用预测输入重新执行代码,可验证每条预测并进行多轮修订,形成CodeI/O++,进一步提升表现。数据与模型已开源:https://github.com/hkust-nlp/CodeIO。

原文摘要 · Abstract (English)

Reasoning is a fundamental capability of Large Language Models. While prior research predominantly focuses on enhancing narrow skills like math or code generation, improving performance on many other reasoning tasks remains challenging due to sparse and fragmented training data. To address this issue, we propose CodeI/O, a novel approach that systematically condenses diverse reasoning patterns inherently embedded in contextually-grounded codes, through transforming the original code into a code input-output prediction format. By training models to predict inputs/outputs given code and test cases entirely in natural language as Chain-of-Thought (CoT) rationales, we expose them to universal reasoning primitives -- like logic flow planning, state-space searching, decision tree traversal, and modular decomposition -- while decoupling structured reasoning from code-specific syntax and preserving procedural rigor. Experimental results demonstrate CodeI/O leads to consistent improvements across symbolic, scientific, logic, math & numerical, and commonsense reasoning tasks. By matching the existing ground-truth outputs or re-executing the code with predicted inputs, we can verify each prediction and further enhance the CoTs through multi-turn revision, resulting in CodeI/O++ and achieving higher performance. Our data and models are available at https://github.com/hkust-nlp/CodeIO.

推理增强代码理解思维链大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。