CodeRetriever: Unimodal and Bimodal Contrastive Learning for Code Search

Xiaonan Li, Yeyun Gong, Yelong Shen, Xipeng Qiu, Hang Zhang +5 more
1/26/2022
cs.CLcs.SE
contrastive-ssl

Official code: microsoft/AR2 (72 stars, Python, MIT, last commit 2022-06-16).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

microsoft/AR2Official100%
MIT
7210PythonDec 3, 20214 years agoMIT

Similar Papers

Cite this paper

@article{li2022coderetriever,
  title  = {CodeRetriever: Unimodal and Bimodal Contrastive Learning for Code Search},
  author = {Xiaonan Li and Yeyun Gong and Yelong Shen and Xipeng Qiu and Hang Zhang and Bolun Yao and Weizhen Qi and Daxin Jiang and Weizhu Chen and Nan Duan},
  year   = {2022},
  eprint = {2201.10866},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2201.10866}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2201.10866.svg)](https://codeofpaper.com/paper/2201.10866)

Discussion