arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.12570cs.CLcs.AIcs.PLcs.SE
收藏

RepoCoder:通过迭代检索与生成实现仓库级代码补全

RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generation

City University of Hong Kong(香港城市大学);Microsoft Corporation(微软公司);Wuhan University(武汉大学)

Fengji Zhang, Bei Chen, Yue Zhang, Jacky Keung, Jin Liu, Daoguang Zan, Yi Mao, Jian-Guang Lou, Weizhu Chen

AI总结:

针对仓库级代码补全难以利用跨文件信息的问题,提出RepoCoder框架,通过结合相似性检索器与预训练代码语言模型的迭代检索-生成管道,有效利用仓库信息生成多粒度代码,并发布RepoEval基准,实验证明其性能显著优于基线方法。

摘要:

仓库级代码补全的任务是根据仓库的更广泛上下文继续编写未完成的代码。然而对于自动代码补全工具而言,很难利用分散在不同文件中的有用信息。我们提出了RepoCoder,一个简单、通用且有效的框架来解决这一挑战。它通过在迭代检索-生成管道中结合基于相似性的检索器和预训练代码语言模型,简化了仓库级代码补全过程。RepoCoder有效地利用仓库级信息进行代码补全,并能够生成不同粒度级别的代码。此外,我们提出了一个新的基准RepoEval,由最新且高质量的真实世界仓库组成,涵盖行、API调用和函数体补全场景。实验结果表明,RepoCoder在所有设置中将文件内补全基线提高了10%以上,并始终优于普通的检索增强代码补全方法。此外,我们通过综合分析验证了RepoCoder的有效性,为未来研究提供了有价值的见解。我们的源代码和基准已公开:https://github.com/microsoft/CodeT/tree/main/RepoCoder

英文摘要:

The task of repository-level code completion is to continue writing the unfinished code based on a broader context of the repository. While for automated code completion tools, it is difficult to utilize the useful information scattered in different files. We propose RepoCoder, a simple, generic, and effective framework to address the challenge. It streamlines the repository-level code completion process by incorporating a similarity-based retriever and a pre-trained code language model in an iterative retrieval-generation pipeline. RepoCoder makes effective utilization of repository-level information for code completion and has the ability to generate code at various levels of granularity. Moreover, we propose a new benchmark RepoEval, which consists of the latest and high-quality real-world repositories covering line, API invocation, and function body completion scenarios. Experimental results indicate that RepoCoder significantly improves the In-File completion baseline by over 10% in all settings and consistently outperforms the vanilla retrieval-augmented code completion approach. Furthermore, we validate the effectiveness of RepoCoder through comprehensive analysis, providing valuable insights for future research. Our source code and benchmark are publicly available: https://github.com/microsoft/CodeT/tree/main/RepoCoder

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

↑