CodeRetriever:用于代码搜索的单峰和双峰对比学习
CodeRetriever: Unimodal and Bimodal Contrastive Learning for Code Search
摘要:
在本文中,我们提出了CodeRetriever模型,它通过大规模的代码-文本对比预训练来学习函数级代码语义表示。在CodeRetriever中采用了两种对比学习方案:单峰对比学习和双峰对比学习。对于单峰对比学习,我们设计了一种无监督学习方法,根据文档和函数名构建语义相关的代码对。对于双模态对比学习,我们利用代码的文档和行内注释来构建代码-文本对。这两个对比目标都可以充分利用大规模代码语料库进行预训练。大量的实验结果表明,CodeRetriever实现了新的国家的最先进的显着改善现有的代码预训练模型,在11个领域/语言特定的代码搜索任务,6种程序设计语言在不同的代码粒度(函数级,片段级和语句级)。这些结果证明了CodeRetriever的有效性和鲁棒性。
英文摘要:
In this paper, we propose the CodeRetriever model, which learns the function-level code semantic representations through large-scale code-text contrastive pre-training. We adopt two contrastive learning schemes in CodeRetriever: unimodal contrastive learning and bimodal contrastive learning. For unimodal contrastive learning, we design an unsupervised learning approach to build semantic-related code pairs based on the documentation and function name. For bimodal contrastive learning, we leverage the documentation and in-line comments of code to build code-text pairs. Both contrastive objectives can fully leverage large-scale code corpus for pre-training. Extensive experimental results show that CodeRetriever achieves new state-of-the-art with significant improvement over existing code pre-trained models, on eleven domain/language-specific code search tasks with six programming languages in different code granularity (function-level, snippet-level and statement-level). These results demonstrate the effectiveness and robustness of CodeRetriever.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。