利用提交历史提升代码仓库级搜索准确率,助力开发者快速定位问题文件。
Repository-level Code Search with Neural Retrieval Methods
- 结合提交信息与源码,用CodeBERT对BM25结果进行多阶段重排序
- 在7个主流仓库上实验,平均精度等指标最高提升80%
- 适合需要高效查错的开发人员和大模型代码助手使用
本文提出一种面向代码仓库级搜索的多阶段重排序系统,利用大型开源仓库中丰富的提交历史辅助缺陷修复。该任务定义为:从代码仓库当前状态中检索出与用户提问或错误最相关的文件集合。方法结合基于BM25的提交信息检索与CodeBERT驱动的神经重排序,通过学习多个仓库及其提交历史中的模式,精准定位相关文件。系统同时利用提交消息与源码进行相关性匹配,在正常与理想设定下均进行了评估。在由7个流行开源仓库构建的新数据集上,针对多样查询,系统在MAP、MRR和P@1指标上相较BM25基线最高提升80%,验证了其有效性。我们希望该工作能作为大语言模型代理的工具,提升代码搜索与理解能力。代码与结果已公开。
原文摘要 · Abstract (English)
This paper presents a multi-stage reranking system for repository-level code search, which leverages the vastly available commit histories of large open-source repositories to aid in bug fixing. We define the task of repository-level code search as retrieving the set of files from the current state of a code repository that are most relevant to addressing a user's question or bug. The proposed approach combines BM25-based retrieval over commit messages with neural reranking using CodeBERT to identify the most pertinent files. By learning patterns from diverse repositories and their commit histories, the system can surface relevant files for the task at hand. The system leverages both commit messages and source code for relevance matching, and is evaluated in both normal and oracle settings. Experiments on a new dataset created from 7 popular open-source repositories demonstrate substantial improvements of up to 80% in MAP, MRR and P@1 over the BM25 baseline, across a diverse set of queries, demonstrating the effectiveness this approach. We hope this work aids LLM agents as a tool for better code search and understanding. Our code and results obtained are publicly available.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。