paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation

基于部分依赖图的有效且高效上下文检索用于仓库级代码生成
ASE Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering2026匹配度 4/10 · 论文处在 LLM 与程序分析交叉的相邻领域:它用 LLM 按需构建部分依赖图来做检索增强的代码生成,但目标是提升仓库级代码生成质量,而非用户关注的“将静态分析应用于 ML/Agentic 程序”或“用 LLM 改进静态分析/形式化验证”。其“按需部分依赖图 vs 静态全局图”的思路与程序分析的可扩展性讨论有一定方法论共鸣,但不落在核心研究问题上。引用 1 inbox
Zhongxin Liu, Zhonghao Jiang, Zhifan Ye, Haoye Wang, Jiakun Liu, Xiaoxue Ren
crossref: 2026-10-09

AI 速览

一句话:提出 DyRetriever,用 LLM 按需构建部分依赖图并多跳推理检索上下文,提升仓库级代码生成。

仓库级代码生成要求 LLM 理解复杂依赖,但上下文窗口有限,常依赖 RAG 检索相关代码。相似度检索难找到目标函数真正依赖的代码,已有图检索又依赖手工规则和静态全图,维护成本高。受人类开发者按需沿依赖图检查的启发,本文提出 DyRetriever:由 LLM 选择入口函数,沿代码依赖图多跳推理,并用语义理解验证候选函数是否有助生成,按需构建部分依赖图、用后丢弃;再与相似度检索结合为 DyCoder。在 CoderEval 与 DevEval 上,DyCoder 相比现有 RAG 方法 Pass@1 相对提升 25.63% 和 59.73%,且比静态依赖图基线快 7.4 倍。

问题
仓库级代码生成中,LLM 难以在有限上下文内获取目标函数真正依赖的代码,现有相似度检索和静态依赖图检索效果与成本受限。
方法
DyRetriever 让 LLM 选择入口函数,沿代码依赖图进行多跳推理并语义验证候选函数,按需构建部分依赖图并在用后丢弃;与相似度检索结合为 DyCoder。
评估
在 CoderEval 和 DevEval 上,DyCoder 的 Pass@1 相对现有 RAG 方法提升 25.63% 和 59.73%,并比静态依赖图构建基线快 7.4 倍。
原文摘要(Abstract)

LLM-based repository-level code generation aims to generate code according to the available context within a software repository, requiring LLMs to understand and reason over complex code dependencies. Due to limited context windows and insufficient understanding of repository-specific code, LLMs typically rely on retrieval-augmented generation (RAG) to incorporate relevant contextual code. Early RAG approaches primarily employ similarity-based retrieval, which often fails to retrieve code snippets that the target function actually depends on. Recent work introduces graph-based retrieval to model such dependencies, but typically relies on manually designed rules and static global graphs, leading to limited flexibility and high construction and maintenance costs. In contrast, human developers typically collect helpful context by implicitly constructing a partial dependency graph and iteratively inspecting along it. Inspired by human behavior, we propose DyRetriever, an effective and efficient context retrieval method via partial dependency graphs. DyRetriever leverages an LLM to simulate how human developers collect helpful context by first selecting a set of entry-point functions and then performing multi-hop reasoning along the code dependency graph. During multi-hop reasoning, DyRetriever leverages the LLM’s semantic understanding to explicitly validate whether a function can help to generate the target function, thereby eliminating reliance on manually designed rules and enabling flexibility across application scenarios. Instead of statically constructing a global dependency graph, DyRetriever builds a partial graph on demand and discards it after use, reducing construction overhead and avoiding maintenance costs. We integrate DyRetriever with a similarity-based code retriever to build a new code generation approach, DyCoder, and evaluate it on two widely used repository-level code generation benchmarks, CoderEval and DevEval. Experimental results show that DyCoder achieves relative Pass@1 improvements of 25.63% and 59.73% on CoderEval and DevEval, respectively, compared with existing RAG-based methods, while being 7.4× faster than baselines based on static dependency graph construction.

链接与引用

DOI 原文 · arXiv ·

BibTeX
@inproceedings{paperbot12352,
  title = {Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation},
  author = {Zhongxin Liu and Zhonghao Jiang and Zhifan Ye and Haoye Wang and Jiakun Liu and Xiaoxue Ren},
  booktitle = {ASE},
  year = {2026},
  doi = {10.1145/3832783.3834350}
}