arXiv:2412.01007cs.CLcs.IR2024-12ICLR被引 41

构建高质量代码对比数据集,提升代码检索与排序效果

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

  • 通过一致性过滤去除噪声正例,加入挖掘的难例负样本
  • 在多语言代码检索任务中达到当前最优性能
  • 可直接用于训练代码重排模型,适合真实开发场景

有效的代码检索对代码生成、缺陷修复和软件维护至关重要,尤其在复杂系统中。现有代码嵌入模型在小规模任务上表现良好,但在实际应用如GitHub仓库中的缺陷定位任务中表现不佳。我们发现其主要瓶颈在于训练数据噪声大、不一致。为此,提出CoRNStack,一个大规模、高质量的跨语言代码对比训练数据集。该数据集通过一致性过滤剔除噪声正例,并引入挖掘的难例负样本,提升模型学习效果。实验表明,使用CoRNStack进行对比训练可显著提升多种代码检索任务的表现。此外,该数据集还可用于训练代码重排模型——这一领域远不如文本重排受关注。我们微调的代码重排模型大幅提升了检索结果的排序质量。结合检索器与重排器,对GitHub问题中的函数定位任务带来显著改进。

原文摘要 · Abstract (English)

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.

代码检索对比学习数据集重排

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