arXiv:2605.21180cs.LGcs.SE2026-05

用强化学习让代码大模型更准、更安全、更懂领域约束。

Domain-Adaptable Reinforcement Learning for Code Generation with Dense Rewards

  • 用近端策略优化微调大模型,奖励函数涵盖语法、功能、安全等多维度。
  • 在MBPP上功能正确率提升19%,在RoboEval上执行失败减少51%。
  • 适合需要高可靠性代码生成的机器人、金融等专业领域使用。

大型语言模型在自动化代码生成方面展现出强大潜力,但缺乏对正确性、质量、安全性及领域特定约束的保障。例如在机器人领域,代码生成越来越多地用于规划与执行动作,对环境和物理约束的认知至关重要。为促进代码生成大模型适应多样化需求(包括领域特定需求),我们提出一种基于近端策略优化的强化学习框架,用于微调预训练大模型。该框架采用可定制的执行感知奖励公式,同时优化语法、功能性正确性、代码风格、安全性及仿真器可执行性。通过令牌级奖励映射机制,实现从执行结果到生成令牌的有效信用分配。在通用代码生成(MBPP/MBPP+)和机器人程序合成(RoboEval)任务上进行了评估,结果显示功能正确性和仿真器可执行性显著提升,其中在MBPP上pass@1绝对提升19%,在RoboEval上执行失败率降低51%。这些发现表明,结构化的强化学习能有效引导语言模型生成符合正确性和领域要求的程序。

原文摘要 · Abstract (English)

Large language models show strong potential for automated code generation, but lack guarantees for correctness, quality, safety, and domain-specific constraints. For instance in robotics, where code generation is increasingly being used for planning and executing actions, awareness of the environment and physical constraints is critical. To facilitate the adaption of code-generating LLMs to diverse requirements, including domain-specific ones, we present a reinforcement learning framework that fine-tunes pre-trained LLMs using proximal policy optimization. Our customizable execution-aware reward formula captures and optimizes syntax, functional correctness, code style, security, and simulator executability. A token-level reward mapping mechanism enables effective credit assignment from execution outcomes to generated tokens. The framework is evaluated on general-purpose code generation (MBPP/MBPP+) and robotic program synthesis (RoboEval). The results show substantial improvements in functional correctness and simulator executability, including an absolute pass@1 increase of 19% on MBPP and a reduction in execution failures by 51% on RoboEval. These findings demonstrate that structured reinforcement learning can effectively align language models to correct program generation and domain-specific requirements.

代码生成强化学习大模型机器人

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