论文精选

RL优化LLM代码生成提示词:PPO代理提升Pass@1至85.5%

Prompt Optimization for LLM Code Generation via Reinforcement Learning

精选理由

做LLM代码生成或提示词工程的开发者,这个框架直接解决了提示词敏感性问题——用RL自动优化提示词,比手动调参高效得多,建议关注其混合动作空间和奖励设计。

AI 摘要

研究人员提出一个基于强化学习的框架,将提示词优化建模为序列决策问题。PPO代理通过混合动作空间(直接生成、遗传变异、语义重写)迭代改进提示词,并利用单元测试反馈的奖励信号驱动优化。在MBPP+、HumanEval+和APPS基准上,使用CodeT5+、CodeLLaMA和DeepSeek-Coder作为冻结代码生成器,PPO代理在MBPP+的500任务测试集上分别达到57.58%、64.80%和85.50%的严格Pass@1,优于EPiC、Reflexion和随机混合方法。软Pass@1分别达到67.90%、73.10%和88.20%。结果表明,带形状奖励的强化学习能显著提升LLM代码生成的功能正确性。

原文 · arXiv: DeepSeek

Prompt Optimization for LLM Code Generation via Reinforcement Learning

Large Language Models (LLMs) can generate code from natural language, but their performance is highly sensitive to prompt formulation. We propose a reinforcement-learning-based framework that models prompt refinement as a sequential decision-making problem. A Proximal Policy Optimization (PPO) agent iteratively improves prompts using a hybrid action space that combines direct generation, genetic lexical mutation and semantic rewriting, guided by shaped rewards derived from unit-test feedback. We evaluate the framework on MBPP+, HumanEval+, and APPS using CodeT5+, CodeLLaMA, and DeepSeek-Coder as frozen code generators. On the 500-task MBPP+ test set, the PPO agent achieves strict Pass@1 scores of 57.58%, 64.80%, and 85.50%, respectively, outperforming EPiC, Reflexion, and Random-Hybrid. Soft-Pass@1 reaches 67.90%, 73.10%, and 88.20%, respectively. Similar improvements are observed on HumanEval+ and APPS across all backbone models. The results demonstrate that reinforcement learning with shaped test-driven rewards improves functional correctness in LLM-based code generation.