EMNLP 2022main41 citations

CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code Search

Xiaonan Li, Yeyun Gong, Yelong Shen, Xipeng Qiu, Hang Zhang, Bolun Yao, Weizhen Qi, Daxin Jiang

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. 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.The codes and resources are available at https://github.com/microsoft/AR2/tree/main/CodeRetriever.

BibTeX
@inproceedings{li-etal-2022-coderetriever,
    title = "{C}ode{R}etriever: A Large Scale Contrastive Pre-Training Method for Code Search",
    author = "Li, Xiaonan  and
      Gong, Yeyun  and
      Shen, Yelong  and
      Qiu, Xipeng  and
      Zhang, Hang  and
      Yao, Bolun  and
      Qi, Weizhen  and
      Jiang, Daxin  and
      Chen, Weizhu  and
      Duan, Nan",
    editor = "Goldberg, Yoav  and
      Kozareva, Zornitsa  and
      Zhang, Yue",
    booktitle = "Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing",
    month = dec,
    year = "2022",
    address = "Abu Dhabi, United Arab Emirates",
    publisher = "Association for Computational Linguistics",
    url = "https://aclanthology.org/2022.emnlp-main.187/",
    doi = "10.18653/v1/2022.emnlp-main.187",
    pages = "2898--2910"
}
CodeRetriever: A Large Scale Contrastive Pre-Training Method for Code Search · EMNLP 2022