2025-02-12 · 专家 · 自然语言处理 · 机器学习

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

这篇论文提出了一种名为CODEI/O的新方法,通过将代码转换为代码输入输出预测格式,系统地压缩了代码中固有的各种推理模式,从而提高了大型语言模型在多种推理任务上的性能。

更新于 2025-02-12。作者:Junlong Li、Daya Guo、Dejian Yang、Runxin Xu、Yu Wu、Junxian He。

中文摘要

推理是大语言模型的基本能力。虽然以往的研究主要集中在提升狭窄技能,如数学或代码生成,但由于训练数据稀疏且碎片化,在许多其他推理任务上的性能提升仍然具有挑战性。为了解决这个问题,我们提出了CodeI/O,这是一种新颖的方法,它系统地浓缩了嵌入在上下文相关代码中的各种推理模式,通过将原始代码转换为代码输入输出预测格式来实现。通过训练模型预测给定代码和测试用例的输入/输出,完全以自然语言作为思维链(CoT)的推理过程,我们使它们接触到通用的推理原语——如逻辑流程规划、状态空间搜索、决策树遍历和模块分解——同时将结构化推理与代码特定的语法解耦,并保持程序严谨性。实验结果表明,CodeI/O在符号推理、科学推理、逻辑推理、数学与数值推理以及常识推理任务上均取得了持续的改进。通过匹配现有的真实输出或重新执行代码并使用预测的输入,我们可以验证每个预测,并通过多轮修订进一步优化思维链,从而实现CodeI/O++并达到更高的性能。我们的数据和模型可在https://github.com/hkust-nlp/CodeIO获取。

英文摘要

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.

解读

一句话总结

这篇论文提出了一种名为CODEI/O的新方法,通过将代码转换为代码输入输出预测格式,系统地压缩了代码中固有的各种推理模式,从而提高了大型语言模型在多种推理任务上的性能。

问题1:这篇论文想要解决什么具体问题?

问题2:论文的核心创新点是什么?

问题3:实验结果如何验证了方法的有效性?

问题4:这个研究的实际应用价值是什么?

来源