ProjAgent:仓库级代码生成的过程相似检索方法

ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generation

精选理由

这篇论文提出 ProjAgent,用过程相似性帮你找到仓库里逻辑相似的代码片段,在 REPOCOD 上 Pass@1 达到 41.14%,比传统语义检索强。

AI 摘要

ProjAgent 是一种针对仓库级代码生成的新系统,通过引入过程相似性作为检索信号来改善代码生成。它将目标函数分解为中间推理步骤,利用代理工作流检索具有类似过程行为的仓库函数,并与传统语义检索结合构建更丰富的上下文。在 REPOCOD 基准上,ProjAgent 实现了 41.14% 的 Pass@1,超越现有检索基线。结果表明过程相似性是一个此前未被探索的有效检索维度。

原文 · arXiv cs.AI

ProjAgent: Procedural Similarity Retrieval for Repository-Level Code Generation

Repository-level code generation requires implementing target functions while accounting for complex cross-file dependencies and project-specific conventions. Existing retrieval methods predominantly rely on lexical, structural, or semantic similarity, often overlooking repository functions that implement similar procedural logic despite differing in identifiers or application domains. We propose ProjAgent, a repository-level code generation system that introduces procedural similarity as an explicit retrieval signal. ProjAgent decomposes the target function into intermediate reasoning steps and employs an agentic workflow to retrieve repository functions that exhibit similar procedural behavior at each step. The retrieved procedural context is integrated with conventional semantic retrieval to construct a richer repository context for code generation. ProjAgent further incorporates a conservative static-analysis feedback loop that iteratively repairs generated code using compiler and static-analysis feedback. Evaluated on REPOCOD, ProjAgent achieves 41.14% Pass@1, outperforming existing retrieval-based baselines. These results demonstrate that procedural similarity is an effective and previously unexplored retrieval dimension for repository-level code generation.