CodeBERT: A Pre-Trained Model for Programming and Natural Languages

Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng +6 more
2/19/2020
4,603 citations
cs.CLcs.PL

Official code: microsoft/CodeBERT (2,797 stars, Python, MIT, last commit 2023-07-09).

Abstract

We present CodeBERT, a bimodal pre-trained model for programming language (PL) and nat-ural language (NL). CodeBERT learns general-purpose representations that support downstream NL-PL applications such as natural language codesearch, code documentation generation, etc.

Show full abstract

We develop CodeBERT with Transformer-based neural architecture, and train it with a hybrid objective function that incorporates the pre-training task of replaced token detection, which is to detect plausible alternatives sampled from generators. This enables us to utilize both bimodal data of NL-PL pairs and unimodal data, where the former provides input tokens for model training while the latter helps to learn better generators. We evaluate CodeBERT on two NL-PL applications by fine-tuning model parameters. Results show that CodeBERT achieves state-of-the-art performance on both natural language code search and code documentation generation tasks. Furthermore, to investigate what type of knowledge is learned in CodeBERT, we construct a dataset for NL-PL probing, and evaluate in a zero-shot setting where parameters of pre-trained models are fixed. Results show that CodeBERT performs better than previous pre-trained models on NL-PL probing.

View on arXivView PDF

Code Implementations(1)

microsoft/CodeBERTOfficial100%
MIT

CodeBERT

2,797499Python, ShellJun 17, 20203 years agoMIT

Similar Papers

Cite this paper

@article{feng2020codebert,
  title  = {CodeBERT: A Pre-Trained Model for Programming and Natural Languages},
  author = {Zhangyin Feng and Daya Guo and Duyu Tang and Nan Duan and Xiaocheng Feng and Ming Gong and Linjun Shou and Bing Qin and Ting Liu and Daxin Jiang and Ming Zhou},
  year   = {2020},
  eprint = {2002.08155},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2002.08155}
}

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/2002.08155.svg)](https://codeofpaper.com/paper/2002.08155)

Discussion