paperbot · PL 论文追踪

全部论文 待读 收藏

P2 GraphCoder: Enhancing Repository-Level Code Completion via Coarse-to-fine Retrieval Based on Code Context Graph

GraphCoder:基于代码上下文图的粗到细检索增强仓库级代码补全
ASE Proceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering2024匹配度 3/10 · 论文聚焦于用代码上下文图和检索增强 LLM 的仓库级代码补全,属于 LLM for code 而非用户关注的在静态分析/Agentic 程序/形式化验证中应用 PL,或利用 LLM 改进静态分析。虽涉及控制流与数据依赖等程序分析概念,但研究目标是提升代码补全能力,与画像核心方向交集有限。引用 57 inbox
Wei Liu, Ailun Yu, Daoguang Zan, Bo Shen, Wei Zhang, Haiyan Zhao, Zhi Jin, Qianxiang Wang
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出 GraphCoder,用代码上下文图与粗到细检索增强 LLM 的仓库级代码补全。

仓库级代码补全需要同时利用通用代码知识与仓库特定知识,但现有代码大模型往往缺乏后者。本文提出 GraphCoder,一个检索增强的代码补全框架:它用代码上下文图(CCG)刻画补全目标及其周围语句间的控制流、数据依赖和控制依赖,从而比序列式上下文更准确地表示目标上下文;基于 CCG,GraphCoder 采用粗到细检索,从当前仓库中定位上下文相似的代码片段,并交给 LLM 生成补全。实验表明,与检索增强基线相比,GraphCoder 的平均 exact match 更高,代码匹配提升 +6.06,标识符匹配提升 +6.23,且耗时和空间开销更低。

问题
仓库级代码补全中,代码大模型虽具备通用代码知识,却因缺少仓库特定知识而表现不佳;如何有效检索并利用仓库上下文是关键问题。
方法
GraphCoder 通过代码上下文图(CCG)结构化表示补全目标上下文,并基于 CCG 进行粗到细检索,从当前仓库中找出上下文相似的代码片段,再结合 LLM 完成生成。
评估
在仓库级代码补全任务上与检索增强基线比较 exact match,报告代码匹配和标识符匹配分别提升 +6.06、+6.23,同时使用更少时间和空间。
原文摘要(Abstract)

The performance of repository-level code completion depends upon the effective leverage of both general and repository-specific knowledge. Despite the impressive capability of code LLMs in general code completion tasks, they often exhibit less satisfactory performance on repository-level completion due to the lack of repository-specific knowledge in these LLMs. To address this problem, we propose GraphCoder, a retrieval-augmented code completion framework that leverages LLMs’ general code knowledge and the repository-specific knowledge via a graph-based retrieval-generation process. In particular, GraphCoder captures the context of completion target more accurately through code context graph (CCG) that consists of control-flow, data- and control-dependence between code statements, a more structured way to capture the completion target context than the sequence-based context used in existing retrieval-augmented approaches; based on CCG, GraphCoder further employs a coarse-to-fine retrieval process to locate context-similar code snippets with the completion target from the current repository. Experimental results demonstrate both the effectiveness and efficiency of GraphCoder: Compared to baseline retrieval-augmented methods, GraphCoder achieves higher exact match (EM) on average, with increases of +6.06 in code match and +6.23 in identifier match, while using less time and space.CCS Concepts• Software and its engineering → Search-based software engineering; • Information systems → Language models; Query representation; • Mathematics of computing → Graph algorithms.

链接与引用

DOI 原文 · DBLP

BibTeX
@inproceedings{LiuYZS00JW24,
  title = {GraphCoder: Enhancing Repository-Level Code Completion via Coarse-to-fine Retrieval Based on Code Context Graph},
  author = {Wei Liu and Ailun Yu and Daoguang Zan and Bo Shen and Wei Zhang and Haiyan Zhao and Zhi Jin and Qianxiang Wang},
  booktitle = {ASE},
  year = {2024},
  doi = {10.1145/3691620.3695054}
}