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

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

19 Feb 2020Findings of the Association for Computational Linguistics 2020arXiv:2002.08155archive 2025-07-28

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

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.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2002.08155")

Code

Syntology Ran 2 of 20 code samples harvested from 5 repositories linked to this paper; 18 have no recorded run. Of those that ran: 2 ran with no contract checked.

By repository: official repository: 1 sample from 1 repository, 0 ran; community (archive-listed): 4 samples from 3 repositories, 2 ran; found in paper text by Syntology: 15 samples from 1 repository, 0 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

microsoft/CodeBERT officialmentioned in papermentioned on GitHubpytorch report
JasonZhu-WHU/CoderAssistant mentioned on GitHubMIT report
aminatadjer/test mentioned on GitHubpytorch report
graykode/commit-autosuggestions mentioned on GitHubpytorchNOASSERTION report
sakirinn/llm4cvd mentioned on GitHubpytorch report
salesforce/codet5 mentioned on GitHubpytorch report
zfj1998/CodeBert-Code2Text mentioned on GitHubpytorch report
zhangzwwww/dietcode mentioned on GitHubpytorch report
zhangzwwww/dietcodebert mentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

20 samples harvested; 2 ran; 0 honoured the contract we drafted; 18 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran
18unverified

Licence: 4 of the 20 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 5 repositories linked to this paper, official or community; each sample names its own and says which. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

Seq2Seq microsoft/CodeBERT/CodeBERT/code2nl/model.py official repository unverified MIT (permissive) · 8053f41db1d56bde · report
Model sakirinn/llm4cvd/CodeBERT/model.py community (archive-listed) ran no licence file found · pointer only · 008726528c96e5c5 · report
RobertaClassificationHead zhangzwwww/dietcode/dietCodeBERT/codesearch/model.py community (archive-listed) ran no licence file found · pointer only · 0503ff378bea5dd8 · report
Beam zfj1998/CodeBert-Code2Text/code/model.py community (archive-listed) unverified no licence file found · pointer only · fe20afbd1ed12d33 · report
Seq2Seq zfj1998/CodeBert-Code2Text/code/model.py community (archive-listed) unverified no licence file found · pointer only · 09b02d6c43ccfaa8 · report
build_table peri-source/peri/peri/special.py found in paper text by Syntology unverified MIT (permissive) · ecd29a67eb6f5369 · report
delistify peri-source/peri/peri/util.py found in paper text by Syntology unverified MIT (permissive) · 5a1aedcf3f0c7290 · report
fast_j0 peri-source/peri/peri/special.py found in paper text by Syntology unverified MIT (permissive) · dee538453dd482d2 · report
fast_j1 peri-source/peri/peri/special.py found in paper text by Syntology unverified MIT (permissive) · ed15ecd3ff651e9b · report
listify peri-source/peri/peri/logger.py found in paper text by Syntology unverified MIT (permissive) · f35d31e49f765f57 · report
listify peri-source/peri/peri/util.py found in paper text by Syntology unverified MIT (permissive) · 37d657d7803f8bb4 · report
load_tiff peri-source/peri/peri/initializers.py found in paper text by Syntology unverified MIT (permissive) · 121597dd382c5a02 · report
load_tiff_layer peri-source/peri/peri/initializers.py found in paper text by Syntology unverified MIT (permissive) · 9adb618f6c87b4a4 · report
normalize peri-source/peri/peri/initializers.py found in paper text by Syntology unverified MIT (permissive) · ba4bfc2758a0045e · report
oddify peri-source/peri/peri/util.py found in paper text by Syntology unverified MIT (permissive) · 92d0ace70a4248ed · report
reduce_add peri-source/peri/peri/comp/comp.py found in paper text by Syntology unverified MIT (permissive) · dde61ac910691485 · report
reduce_mul peri-source/peri/peri/comp/comp.py found in paper text by Syntology unverified MIT (permissive) · 16e86d560b446cd7 · report
sample peri-source/peri/peri/states.py found in paper text by Syntology unverified MIT (permissive) · 8ce382543ba7073c · report
sanitize peri-source/peri/peri/logger.py found in paper text by Syntology unverified MIT (permissive) · 2e5dd6eaf5b83724 · report
transform peri-source/peri/peri/conf.py found in paper text by Syntology unverified MIT (permissive) · 38157a1ab1b0b136 · report

Tasks

Code Documentation Generation

Results from the paper archive 2025-07-28

TaskDatasetModelMetricValueRank at snapshotLeaderboardReport
Code Documentation Generation CodeSearchNet CodeBERT (MLM+RTD) Smoothed BLEU-4 15.99 #1 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet CodeBERT (MLM) Smoothed BLEU-4 15.55 #2 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet pre-train w/ code only Smoothed BLEU-4 15.15 #3 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet CodeBERT (RTD) Smoothed BLEU-4 15.03 #4 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet RoBERTa Smoothed BLEU-4 14.52 #5 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet Transformer Smoothed BLEU-4 14.31 #6 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet seq2seq Smoothed BLEU-4 13.36 #7 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Go CodeBERT (MLM) Smoothed BLEU-4 26.79 #1 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Go CodeBERT (MLM+RTD) Smoothed BLEU-4 26.66 #2 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Go pre-train w/ code only Smoothed BLEU-4 26.39 #3 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Go RoBERTa Smoothed BLEU-4 26.09 #4 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Go CodeBERT (RTD) Smoothed BLEU-4 26.02 #5 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Go seq2seq Smoothed BLEU-4 23.48 #6 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Java CodeBERT (MLM+RTD) Smoothed BLEU-4 14.56 #2 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Java CodeBERT (MLM) Smoothed BLEU-4 13.59 #3 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Java RoBERTa Smoothed BLEU-4 13.2 #4 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Java pre-train w/ code only Smoothed BLEU-4 13.07 #5 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Java CodeBERT (RTD) Smoothed BLEU-4 12.72 #6 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Java Transformer Smoothed BLEU-4 12.57 #7 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Java seq2seq Smoothed BLEU-4 11.42 #8 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - JavaScript Transformer Smoothed BLEU-4 25.61 #1 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - JavaScript CodeBERT (MLM+RTD) Smoothed BLEU-4 9.54 #3 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - JavaScript CodeBERT (RTD) Smoothed BLEU-4 8.73 #4 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - JavaScript CodeBERT (MLM) Smoothed BLEU-4 8.51 #5 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - JavaScript pre-train w/ code only Smoothed BLEU-4 8.3 #6 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - JavaScript seq2seq Smoothed BLEU-4 6.88 #7 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - JavaScript RoBERTa Smoothed BLEU-4 5.72 #8 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Php CodeBERT (MLM+RTD) Smoothed BLEU-4 21.32 #2 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Php CodeBERT (MLM) Smoothed BLEU-4 21 #3 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Php pre-train w/ code only Smoothed BLEU-4 20.71 #4 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Php CodeBERT (RTD) Smoothed BLEU-4 20.25 #5 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Php RoBERTa Smoothed BLEU-4 19.9 #6 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Php seq2seq Smoothed BLEU-4 18.4 #7 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Php Transformer Smoothed BLEU-4 18.25 #8 of 8 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Python CodeBERT (MLM) Smoothed BLEU-4 15.48 #2 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Python CodeBERT (MLM+RTD) Smoothed BLEU-4 15.41 #3 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Python pre-train w/ code only Smoothed BLEU-4 15.12 #4 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Python RoBERTa Smoothed BLEU-4 14.92 #5 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Python Transformer Smoothed BLEU-4 13.44 #6 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Python seq2seq Smoothed BLEU-4 13.04 #7 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Ruby CodeBERT (MLM+RTD) Smoothed BLEU-4 8.46 #2 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Ruby CodeBERT (MLM) Smoothed BLEU-4 7.95 #3 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Ruby Transformer Smoothed BLEU-4 7.87 #4 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Ruby pre-train w/ code only Smoothed BLEU-4 7.36 #5 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Ruby RoBERTa Smoothed BLEU-4 7.26 #6 of 7 Archive leaderboard report
Code Documentation Generation CodeSearchNet - Ruby seq2seq Smoothed BLEU-4 6.96 #7 of 7 Archive leaderboard report
Code Search CodeSearchNet CodeBERT Go 69.3 #6 of 6 Archive leaderboard report
Code Search CodeSearchNet CodeBERT JS 74.8 #6 of 6 Archive leaderboard report
Code Search CodeSearchNet CodeBERT Java 86.8 #6 of 6 Archive leaderboard report
Code Search CodeSearchNet CodeBERT Overall 76.0 #6 of 6 Archive leaderboard report
Code Search CodeSearchNet CodeBERT PHP 70.6 #6 of 6 Archive leaderboard report
Code Search CodeSearchNet CodeBERT Python 84.0 #6 of 6 Archive leaderboard report
Code Search CodeSearchNet CodeBERT Ruby 70.6 #6 of 6 Archive leaderboard report
Type prediction ManyTypes4TypeScript CodeBERT Average Accuracy 61.72 #4 of 9 Archive leaderboard report
Type prediction ManyTypes4TypeScript CodeBERT Average F1 59.57 #4 of 9 Archive leaderboard report
Type prediction ManyTypes4TypeScript CodeBERT Average Precision 59.34 #4 of 9 Archive leaderboard report
Type prediction ManyTypes4TypeScript CodeBERT Average Recall 59.80 #4 of 9 Archive leaderboard report

Ranks are positions in the archive's leaderboards as they stood at the 2025-07-28 snapshot. Results published since then are not among these rows, so a rank here is not a current standing.

Methods

CodeBERT

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections