arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.07067cs.IR
收藏

基于神经检索方法的仓库级代码搜索

Repository-level Code Search with Neural Retrieval Methods

Siddharth Gandhi, Luyu Gao, Jamie Callan

AI总结:

针对仓库级代码搜索任务,提出结合BM25提交消息检索与CodeBERT神经重排序的多阶段系统,利用提交历史辅助漏洞修复,在7个开源仓库数据集上较BM25基线的MAP、MRR和P@1提升达80%,助力LLM智能体代码理解。

摘要:

本文提出了一个用于仓库级代码搜索的多阶段重排序系统,该系统利用大型开源仓库中大量可用的提交历史来辅助漏洞修复。我们将仓库级代码搜索任务定义为从代码仓库的当前状态中检索与解决用户问题或漏洞最相关的文件集。所提出的方法结合了基于BM25的提交消息检索和使用CodeBERT的神经重排序,以识别最相关的文件。通过从不同仓库及其提交历史中学习模式,该系统可以为当前任务找出相关文件。该系统利用提交消息和源代码进行相关性匹配,并在常规和Oracle设置下进行评估。在从7个流行开源仓库创建的新数据集上的实验表明,在各种查询中,MAP、MRR和P@1指标相较于BM25基线有高达80%的显著提升,证明了该方法的有效性。我们希望这项工作能作为工具帮助LLM智能体更好地进行代码搜索和理解。我们的代码和获得的结果已公开。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑