Skip to main content
QUICK REVIEW

[论文解读] RepoBench: Benchmarking Repository-Level Code Auto-Completion Systems

Tianyang Liu, Canwen Xu|arXiv (Cornell University)|Jun 5, 2023
Software Engineering Research被引用 11
一句话总结

RepoBench 引入一个面向代码自动完成的仓库级基准,包含三项任务——检索、代码补全和管线(Pipeline)——在 Python 和 Java 上对多种模型和检索策略进行评估。

ABSTRACT

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)?

主要发现

检索方法XF-F EMXF-F ESXF-R EMXF-R ESIF EMIF ESAll EMAll ES
Gold-Only * (Python)30.5970.4340.6574.4541.1078.3235.7973.59
Gold-Filled-Head * (Python)31.0770.4839.7774.4241.8778.5636.0773.68
Gold-Filled-Tail * (Python)31.3570.7340.5674.3741.2178.5036.1873.77
UniXcoder-H2L (Python)30.9970.6840.7174.7443.1979.1836.6174.02
UniXcoder-L2H (Python)32.1271.3640.5974.4843.0779.2237.1174.32
Random (Python)28.0668.9538.7573.8141.1678.3434.1572.72
Baseline (Python)26.7568.1637.6073.3040.7978.2633.1572.20
Gold-Only * (Java)32.4870.3943.5176.4955.9181.6541.6274.95
Gold-Filled-Head * (Java)32.4870.2943.4476.3655.8481.6841.5974.88
Gold-Filled-Tail * (Java)32.3770.3043.4876.6355.6681.5541.4974.91
UniXcoder-H2L (Java)32.4670.1642.7976.1456.7181.8641.7074.83
UniXcoder-L2H (Java)32.6970.3343.0876.2156.5781.8941.8374.93
Random (Java)31.3469.8142.0875.7355.9481.6740.7774.51
Baseline (Java)30.7369.4841.4475.4256.1881.7040.4074.29
  • UniXcoder 在 RepoBench-R 中始终优于其他检索方法,表明对跨文件片段具有很强的语义理解。
  • 词汇检索(Jaccard)通常在跨文件片段相关性方面优于编辑相似度。
  • 在各方法中,Python 检索任务的准确性通常高于 Java。
  • 在 RepoBench-P 中,结合跨文件上下文在各设置下提升性能,且有效的检索(例如 UniXcoder)提升检索和补全结果。
  • 检索到的片段的顺序/放置会影响代码补全效果,离目标行越近越有利。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。