Code reasoning refers to the task of predicting the output of a program given its source code and specific inputs. It can measure the reasoning capability of large language models (LLMs) and also benefit downstream tasks such as code generation and mathematical reasoning. Existing work has verified the effectiveness of reinforcement learning on the task. However, these methods design rewards solely based on final outputs or coarse-grained signals, and neglect the inherent consistency of the stepwise reasoning process in the task. Therefore, these methods often result in sparse reward or reward hacking, which limits the full play of enhanced learning capabilities. To alleviate these issues, we propose CodeThinker, a consistency-driven reinforcement learning framework for code reasoning. Specifically, CodeThinker has three key components: (1) a stepwise reasoning-aware model training module, which utilizes a consistency tracing paradigm as a template to synthesize training data that captures the stepwise reasoning process; (2) a dynamic beam sampling strategy, which aims to improve the quality of sampled outputs under a fixed sampling budget; and (3) a consistency reward mechanism that can effectively alleviate reward hacking. Experiments on three popular benchmarks show that CodeThinker achieves state-of-the-art performance across multiple LLMs. For instance, it outperforms the strongest baseline by 4.3% in accuracy when deployed on Qwen2.5-Coder-7B-Instruct. We also validate the effectiveness of CodeThinker on downstream tasks. Results show that, without additional training, CodeThinker obtains average accuracy gains of 5.33 and 3.11 percentage points on mathematical reasoning and code reasoning tasks covering 17 programming languages, respectively.


翻译:代码推理是指根据给定源代码和特定输入预测程序输出的任务。它既能衡量大语言模型的推理能力,也对代码生成和数学推理等下游任务有所裨益。现有研究已验证强化学习在该任务上的有效性,但这些方法仅基于最终输出或粗粒度信号设计奖励,忽视了任务中间推理过程的固有连贯性,常导致奖励稀疏或奖励破解问题,限制了增强学习能力的充分发挥。为缓解这些问题,本文提出CodeThinker——一种面向代码推理的、由一致性驱动的强化学习框架。具体而言,CodeThinker包含三个核心组件:(1) 步进推理感知模型训练模块,该模块以一致性追踪范式为模板,合成了捕捉步进推理过程的训练数据;(2) 动态束采样策略,旨在固定采样预算下提升采样输出的质量;(3) 一致性奖励机制,能够有效缓解奖励破解问题。在三个主流基准上的实验表明,CodeThinker在多个大语言模型上均取得了最优性能。例如,当部署在Qwen2.5-Coder-7B-Instruct上时,其准确率比最强基线方法高出4.3%。我们还验证了CodeThinker在下游任务上的有效性。结果显示,无需额外训练,CodeThinker在覆盖17种编程语言的数学推理和代码推理任务上分别平均提升了5.33和3.11个百分点的准确率。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
大语言模型的智能体化推理
专知会员服务
35+阅读 · 1月21日
面向大型推理模型的强化学习综述
专知会员服务
29+阅读 · 2025年9月11日
强化多模态大语言模型:基于强化学习的推理综述
专知会员服务
37+阅读 · 2025年5月3日
迈向大型推理模型:基于大型语言模型的强化推理综述
专知会员服务
50+阅读 · 2025年1月17日
通过强化学习增强代码生成中的代码大语言模型:综述
专知会员服务
29+阅读 · 2025年1月1日
【大模型对齐】利用对齐使大型语言模型更好地推理
专知会员服务
48+阅读 · 2023年9月8日
基于模型的强化学习综述
专知
42+阅读 · 2022年7月13日
因果推理学习算法资源大列表
专知
27+阅读 · 2019年3月3日
深度强化学习简介
专知
30+阅读 · 2018年12月3日
一文了解强化学习
AI100
15+阅读 · 2018年8月20日
关于强化学习(附代码,练习和解答)
深度学习
38+阅读 · 2018年1月30日
关系推理:基于表示学习和语义要素
计算机研究与发展
19+阅读 · 2017年8月22日
【强化学习】强化学习+深度学习=人工智能
产业智能官
55+阅读 · 2017年8月11日
国家自然科学基金
43+阅读 · 2015年12月31日
国家自然科学基金
40+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
国家自然科学基金
23+阅读 · 2009年12月31日
VIP会员
最新内容
综述 | 世界动作模型:少做梦,多行动
专知会员服务
3+阅读 · 6月23日
美以伊冲突:无人机与人工智能的运用
专知会员服务
5+阅读 · 6月23日
《特种部队在透明战场中的生存力》最新报告
专知会员服务
4+阅读 · 6月23日
综述 | 3D场景图:开放挑战与未来方向
专知会员服务
8+阅读 · 6月22日
21世纪的无人机战争
专知会员服务
4+阅读 · 6月22日
《量子技术的军事任务技术适配与利用》
专知会员服务
5+阅读 · 6月22日
相关VIP内容
相关资讯
基于模型的强化学习综述
专知
42+阅读 · 2022年7月13日
因果推理学习算法资源大列表
专知
27+阅读 · 2019年3月3日
深度强化学习简介
专知
30+阅读 · 2018年12月3日
一文了解强化学习
AI100
15+阅读 · 2018年8月20日
关于强化学习(附代码,练习和解答)
深度学习
38+阅读 · 2018年1月30日
关系推理:基于表示学习和语义要素
计算机研究与发展
19+阅读 · 2017年8月22日
【强化学习】强化学习+深度学习=人工智能
产业智能官
55+阅读 · 2017年8月11日
相关基金
国家自然科学基金
43+阅读 · 2015年12月31日
国家自然科学基金
40+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
12+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
国家自然科学基金
18+阅读 · 2012年12月31日
国家自然科学基金
23+阅读 · 2009年12月31日
Top
微信扫码咨询专知VIP会员