paperbot · PL 论文追踪

全部论文 待读 收藏

P2 RLCoder: Reinforcement Learning for Repository-Level Code Completion

RLCoder:面向仓库级代码补全的强化学习
ICSE 2025 IEEE/ACM 47th International Conference on Software Engineering (ICSE)2025匹配度 3/10 · 论文研究仓库级代码补全的检索增强与强化学习,属于PL+AI交叉,但未涉及用户核心关注的静态分析、形式化验证、浮点程序分析或贝叶斯程序分析,也未将LLM/Agent用于程序分析任务。引用 20 inbox
Yanlin Wang, Yanli Wang, Daya Guo, Jiachi Chen, Ruikai Zhang, Yuchi Ma, Zibin Zheng
crossref: 2026-09-12

AI 速览

一句话:提出RLCoder,用强化学习让检索器无需标注数据即可为仓库级代码补全检索有用上下文。

仓库级代码补全需在指定仓库上下文中为未完成片段生成代码,但输入长度有限,现有方法依赖检索增强生成。BM25 等词法检索难以捕捉代码语义,基于模型的检索又缺少标注数据。为此,本文提出强化学习框架 RLCoder,无需标注数据即可训练检索器:以加入检索内容后目标代码的困惑度迭代评估检索内容是否有用,并反馈更新检索器参数;同时引入停止信号机制,使检索器自主决定何时检索及保留哪些候选。在 CrossCodeEval 和 RepoEval 上,RLCoder 持续优于已有最好方法,EM 提升 12.2%,并可跨语言泛化、增强 RepoCoder 等先前方法。

问题
仓库级代码补全受输入长度限制,难以有效利用仓库上下文;传统词法检索缺乏语义,基于模型的检索又缺少标注数据训练。
方法
提出强化学习框架 RLCoder,以补全困惑度作为奖励信号迭代更新检索器,并引入停止信号机制让检索器自主决定何时检索与保留哪些候选。
评估
在 CrossCodeEval 与 RepoEval 上评测,EM 较此前最好方法提升 12.2%,并验证了跨编程语言泛化及对 RepoCoder 等方法的增强。
原文摘要(Abstract)

Repository-level code completion aims to generate code for unfinished code snippets within the context of a specified repository. Existing approaches mainly rely on retrievalaugmented generation strategies due to limitations in input sequence length. However, traditional lexical-based retrieval methods like BM25 struggle to capture code semantics, while model-based retrieval methods face challenges due to the lack of labeled data for training. Therefore, we propose RLCoder, a novel reinforcement learning framework, which can enable the retriever to learn to retrieve useful content for code completion without the need for labeled data. Specifically, we iteratively evaluate the usefulness of retrieved content based on the perplexity of the target code when provided with the retrieved content as additional context, and provide feedback to update the retriever parameters. This iterative process enables the retriever to learn from its successes and failures, gradually improving its ability to retrieve relevant and high-quality content. Considering that not all situations require information beyond code files and not all retrieved context is helpful for generation, we also introduce a stop signal mechanism, allowing the retriever to decide when to retrieve and which candidates to retain autonomously. Extensive experimental results demonstrate that RLCoder consistently outperforms state-of-the-art methods on CrossCodeEval and RepoEval, achieving 12.2% EM improvement over previous methods. Moreover, experiments show that our framework can generalize across different programming languages and further improve previous methods like RepoCoder. We provide the code and data at https://github.com/DeepSoftwareAnalytics/RLCoder.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot8739,
  title = {RLCoder: Reinforcement Learning for Repository-Level Code Completion},
  author = {Yanlin Wang and Yanli Wang and Daya Guo and Jiachi Chen and Ruikai Zhang and Yuchi Ma and Zibin Zheng},
  booktitle = {ICSE},
  year = {2025},
  doi = {10.1109/icse55347.2025.00014}
}