arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.00433cs.SEcs.AI
收藏

通过需求感知的课程强化学习改进LLM代码生成

Improving LLM Code Generation via Requirement-Aware Curriculum Reinforcement Learning

Tianjin University(天津大学);Dalian Maritime University(大连海事大学)

Shouyu Yin, Zhao Tian, Junjie Chen, Shikai Guo

AI总结:

本文提出RECRL框架,通过自动感知需求难度、优化挑战性需求和自适应课程采样策略,提升LLM代码生成性能,实验显示在多个基准上表现显著。

摘要:

代码生成旨在从给定的编程需求自动生成源代码,有潜力显著提高软件开发效率。随着大语言模型(LLMs)的快速发展,基于LLM的代码生成受到学术界和工业界广泛关注。然而,随着编程需求日益复杂,现有LLMs仍存在明显性能局限。为解决这一挑战,最近的研究提出了基于训练的课程强化学习(CRL)策略来提升LLM代码生成性能。尽管这些方法有效,但现有CRL方法存在几个限制,包括需求难度感知不一致、缺乏需求难度优化以及次优的课程采样策略。在基于CRL的代码生成中,编程需求是模型的唯一输入,其质量和难度对训练效果至关重要。受软件需求工程的启发,我们提出RECRL,一种新的需求感知课程强化学习框架,用于增强基于LLM的代码生成。RECRL自动感知模型特定的需求难度,优化具有挑战性的需求以提高训练数据利用率,并采用自适应课程采样策略来构建难度逐渐变化的训练批次。在五个最先进的LLMs上,通过与五个最先进的基线进行比较,在五个广泛使用的代码生成基准上进行了广泛的实验,证明了RECRL的显著有效性。例如,RECRL在所有最先进的基线上实现了平均Pass@1提升1.23%-5.62%。

英文摘要:

Code generation, which aims to automatically generate source code from given programming requirements, has the potential to substantially improve software development efficiency. With the rapid advancement of large language models (LLMs), LLM-based code generation has attracted widespread attention from both academia and industry. However, as programming requirements become increasingly complex, existing LLMs still exhibit notable performance limitations. To address this challenge, recent studies have proposed training-based curriculum reinforcement learning (CRL) strategies to improve LLM code generation performance. Despite their effectiveness, existing CRL approaches suffer from several limitations, including misaligned requirement difficulty perception, the absence of requirement difficulty optimization, and suboptimal curriculum sampling strategies. In CRL-based code generation, programming requirements serve as the sole input to the model, making their quality and difficulty critical to training effectiveness. Motivated by insights from software requirements engineering, we propose RECRL, a novel requirement-aware curriculum reinforcement learning framework for enhancing LLM-based code generation. RECRL automatically perceives model-specific requirement difficulty, optimizes challenging requirements to improve training data utilization, and employs an adaptive curriculum sampling strategy to construct training batches with smoothly varying difficulty. Extensive experiments on five state-of-the-art LLMs across five widely-used code generation benchmarks by comparing with five state-of-the-art baselines, demonstrate the significant effectiveness of RECRL. For example, RECRL achieves an average Pass@1 improvement of 1.23%-5.62% over all state-of-the-art baselines.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑