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

CoRNStack:用于更好代码检索与重排序的高质量对比数据

CoRNStack: High-Quality Contrastive Data for Better Code Retrieval and Reranking

University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校);Lapis Labs(拉皮斯实验室);Nomic AI(诺米克人工智能公司)

Tarun Suresh, Revanth Gangi Reddy, Yifei Xu, Zach Nussbaum, Andriy Mulyar, Brandon Duderstadt, Heng Ji

AI总结:

提出高质量对比训练数据集CoRNStack,通过一致性过滤和挖掘困难负样本提升模型训练效果,在多种代码检索任务上达到SOTA,并显著改进代码重排序及GitHub issue函数定位。

摘要:

有效的代码检索在推进代码生成、错误修复和软件维护方面发挥着关键作用,特别是随着软件系统复杂性的增加。尽管当前的代码嵌入模型在为小规模、定义明确的任务检索代码片段方面展现出了潜力,但它们在更具挑战性的实际应用中(如 GitHub 仓库内的错误定位)往往表现不佳。我们假设一个关键问题是它们依赖嘈杂且不一致的数据集进行训练,这阻碍了它们泛化到更复杂检索场景的能力。为了解决这些局限性,我们引入了 CoRNStack,这是一个大规模、高质量的代码对比训练数据集,涵盖多种编程语言。该数据集使用一致性过滤来消除嘈杂的正样本,并进一步通过挖掘困难负样本进行丰富,从而促进更有效的学习。我们证明,使用 CoRNStack 对嵌入模型进行对比训练,可以在各种代码检索任务中实现最先进的性能。此外,该数据集还可用于训练代码重排序模型,与文本重排序相比,这是一个很大程度上未被探索的领域。我们微调后的代码重排序模型显著提升了检索结果的排序质量。最后,通过将我们的代码检索器和重排序器结合使用,我们展示了在 GitHub issue 的函数定位方面的显著改进,这是实际软件开发的重要组成部分。

英文摘要:

Effective code retrieval plays a crucial role in advancing code generation, bug fixing, and software maintenance, particularly as software systems increase in complexity. While current code embedding models have demonstrated promise in retrieving code snippets for small-scale, well-defined tasks, they often underperform in more demanding real-world applications such as bug localization within GitHub repositories. We hypothesize that a key issue is their reliance on noisy and inconsistent datasets for training, which impedes their ability to generalize to more complex retrieval scenarios. To address these limitations, we introduce CoRNStack, a large-scale, high-quality contrastive training dataset for code that spans multiple programming languages. This dataset is curated using consistency filtering to eliminate noisy positives and is further enriched with mined hard negatives, thereby facilitating more effective learning. We demonstrate that contrastive training of embedding models using CoRNStack leads to state-of-the-art performance across a variety of code retrieval tasks. Furthermore, the dataset can be leveraged for training code reranking models, a largely underexplored area compared to text reranking. Our finetuned code reranking model significantly improves the ranking quality over the retrieved results. Finally, by employing our code retriever and reranker together, we demonstrate significant improvements in function localization for GitHub issues, an important component of real-world software development.

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

↑