Share your thoughts, 1 month free Claude Pro on usSee more
WorkDL logo mark

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

About

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. 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.

Zhangyin Feng, Daya Guo, Duyu Tang, Nan Duan, Xiaocheng Feng, Ming Gong, Linjun Shou, Bing Qin, Ting Liu, Daxin Jiang, Ming Zhou• 2020

Related benchmarks

TaskDatasetResultRank
Code SummarizationCodeSearchNet-Java (CSN) CodeXGLUE (test)
Smoothed BLEU-418.25
38
Code SummarizationCodeXGLUE
Java Score17.65
38
Vulnerability DetectionPrimeVul (test)
F1 Score16.47
38
Vulnerability DetectionCASTLE 250-sample benchmark 1.0
CASTLE Score-166
29
Natural Language Code SearchCodeSearchNet
Overall Score76
25
Code SearchPython (test)
Recall@145.1
25
Code SearchJava (test)
R@131.9
25
Vulnerability DetectionPrimeVul
F1 Score55.62
24
NL2Code SearchCSN (CodeSearchNet) (test)
Recall (Python)86.85
18
Code RetrievalCodeSearch
MRR27.2
16
Showing 10 of 55 rows

Other info

Code

Follow for update