Large Language Models (LLMs) can generate plausible code, but in settings that require exact stdin/stdout behavior they frequently produce programs that compile yet fail tests, and in some cases they introduce security-sensitive patterns. This paper presents SecureCodeRL, a reinforcement learning (RL) pipeline for security-aware code generation that optimizes a combined reward R = αRfunc + \b{eta}Rsec. The key idea is a partial-credit functional reward that assigns intermediate scores for syntactic validity, successful execution, and producing output, reducing reward sparsity that otherwise stalls learning on competitive programming style tasks. I evaluate supervised fine-tuning (SFT) and PPO variants on a small held-out prompt set from APPS+ and observe that PPO with partial credit (using a continued-training variant) improves syntax validity from 45% (SFT) to 60% and achieves the only non-zero test success signal in this pilot evaluation (5% at-least-one-test-pass), while remaining 100% clean under Bandit static analysis. Although Bandit findings were absent in this small evaluation, the security term is integrated into training to discourage insecure shortcuts when they appear.


翻译:大型语言模型(LLM)能够生成看似合理的代码,但在需要精确标准输入/输出行为的场景中,其生成的程序虽可编译却常无法通过测试,有时甚至引入安全敏感模式。本文提出SecureCodeRL——一种用于安全感知代码生成的强化学习(RL)流程,其优化目标为组合奖励 R = αRfunc + βRsec。核心创新在于引入部分信用功能奖励机制,该机制为语法有效性、成功执行及产生输出分配中间分数,从而缓解竞争性编程任务中因奖励稀疏导致的学习停滞问题。通过在APPS+的小型保留提示集上评估监督微调(SFT)与PPO变体,发现采用部分信用机制的PPO(使用持续训练变体)将语法有效性从45%(SFT)提升至60%,并在此试点评估中实现了唯一的非零测试通过信号(至少通过一项测试的比例达5%),同时在Bandit静态分析下保持100%无漏洞状态。尽管本次小规模评估未发现Bandit漏洞,安全奖励项已整合至训练过程中,以在出现不安全捷径时予以抑制。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
ICLR'21 | GNN联邦学习的新基准
图与推荐
12+阅读 · 2021年11月15日
Kaggle知识点:伪标签Pseudo Label
AINLP
40+阅读 · 2020年8月9日
【NeurIPS2019】图变换网络:Graph Transformer Network
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
8+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
相关资讯
ICLR'21 | GNN联邦学习的新基准
图与推荐
12+阅读 · 2021年11月15日
Kaggle知识点:伪标签Pseudo Label
AINLP
40+阅读 · 2020年8月9日
【NeurIPS2019】图变换网络:Graph Transformer Network
相关基金
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
5+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
8+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员