[论文解读] RepoBench: Benchmarking Repository-Level Code Auto-Completion Systems
RepoBench 引入一个面向代码自动完成的仓库级基准,包含三项任务——检索、代码补全和管线(Pipeline)——在 Python 和 Java 上对多种模型和检索策略进行评估。
Large Language Models (LLMs) have greatly advanced code auto-completion systems, with a potential for substantial productivity enhancements for developers. However, current benchmarks mainly focus on single-file tasks, leaving an assessment gap for more complex, real-world, multi-file programming scenarios. To fill this gap, we introduce RepoBench, a new benchmark specifically designed for evaluating repository-level code auto-completion systems. RepoBench supports both Python and Java and consists of three interconnected evaluation tasks: RepoBench-R (Retrieval), RepoBench-C (Code Completion), and RepoBench-P (Pipeline). Each task respectively measures the system's ability to retrieve the most relevant code snippets from other files as cross-file context, predict the next line of code with cross-file and in-file context, and handle complex tasks that require a combination of both retrieval and next-line prediction. RepoBench aims to facilitate a more complete comparison of performance and encouraging continuous improvement in auto-completion systems. RepoBench is publicly available at https://github.com/Leolty/repobench.
研究动机与目标
- 弥补在对多文件、仓库级代码补全系统进行评估方面的空白,超越单文件基准。
- 提供一个包含三个互相关联任务(检索、代码补全、管线)的基准,以评估端到端工作流。
- 揭示模型在真实仓库中的跨文件和长上下文代码处理能力。
- 促进公平比较并推动仓库级代码智能的改进。
提出的方法
- 从 GitHub 代码(训练集)和新抓取的 GitHub 仓库(测试集)构建数据集,聚焦 Python 和 Java。
- 通过 tree-sitter 解析跨文件依赖,识别跨文件行及相应的定义。
- 定义三项任务:RepoBench-R(检索)、RepoBench-C(代码补全)、RepoBench-P(管线)。
- 通过将跨文件上下文(来自导入)与文件内上下文(前面的行)相结合来创建提示,对于 RepoBench-C 设置 30 行上限。
- 使用 acc@k 进行检索评估,对补全和管线使用 Exact Match(EM)和 Edit Similarity(ES)评估。
- 测试一系列基线方法,包括词法检索、语义检索(CodeBERT、UniXcoder)以及大型语言模型(Codex、CodeGen、StarCoder)在 Python/Java 变体上的表现。
实验结果
研究问题
- RQ1检索策略在多大程度上能够识别相关的跨文件片段以支持下一个代码行的预测?
- RQ2在不同上下文长度(XF-F、XF-R、IF)下,模型使用跨文件与文件内上下文预测下一行代码的有效性如何?
- RQ3将检索与补全结合在管线中时的端到端性能如何,以及跨文件上下文的放置如何影响结果?
- RQ4仓库级基准是否揭示在检索和补全性能上的语言特定差异(Python 与 Java)?
主要发现
- UniXcoder 在 RepoBench-R 中始终优于其他检索方法,表明对跨文件片段具有很强的语义理解。
- 词汇检索(Jaccard)通常在跨文件片段相关性方面优于编辑相似度。
- 在各方法中,Python 检索任务的准确性通常高于 Java。
- 在 RepoBench-P 中,结合跨文件上下文在各设置下提升性能,且有效的检索(例如 UniXcoder)提升检索和补全结果。
- 检索到的片段的顺序/放置会影响代码补全效果,离目标行越近越有利。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。