arXiv:2509.16112cs.CLcs.IR2025-09EMNLP被引 17

CodeRAG提升代码补全精准度,自动找对相关代码片段

CodeRAG: Finding Relevant and Necessary Knowledge for Retrieval-Augmented Repository-Level Code Completion

  • 用概率引导构建查询,精准定位代码库中的相关片段
  • 支持多路径检索,避免遗漏关键代码,准确率提升12.3%
  • 通过偏好对齐重排序,让生成代码更符合上下文逻辑

仓库级代码补全基于整个代码库的上下文自动预测未完成的代码。近年来,代码大模型的发展推动了仓库级代码补全方法的进步,取得了显著成效。然而,现有方法仍存在查询构造不当、单路径代码检索以及代码检索器与代码大模型之间不匹配等问题。为此,我们提出 CodeRAG 框架,旨在为增强型仓库级代码补全识别出相关且必要的知识。其核心组件包括基于对数概率的查询构建、多路径代码检索和偏好对齐的 BestFit 重排序。在 ReccEval 与 CCEval 基准上的大量实验表明,CodeRAG 显著且一致地优于现有最先进方法。CodeRAG 的实现已公开于 https://github.com/KDEGroup/CodeRAG。

原文摘要 · Abstract (English)

Repository-level code completion automatically predicts the unfinished code based on the broader information from the repository. Recent strides in Code Large Language Models (code LLMs) have spurred the development of repository-level code completion methods, yielding promising results. Nevertheless, they suffer from issues such as inappropriate query construction, single-path code retrieval, and misalignment between code retriever and code LLM. To address these problems, we introduce CodeRAG, a framework tailored to identify relevant and necessary knowledge for retrieval-augmented repository-level code completion. Its core components include log probability guided query construction, multi-path code retrieval, and preference-aligned BestFit reranking. Extensive experiments on benchmarks ReccEval and CCEval demonstrate that CodeRAG significantly and consistently outperforms state-of-the-art methods. The implementation of CodeRAG is available at https://github.com/KDEGroup/CodeRAG.

代码补全检索增强大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。