CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation

Yue Wang, Weishi Wang, Shafiq Joty, Steven C. H. Hoi
9/2/2021
2,640 citations
cs.CLcs.PL

Official code: salesforce/CodeT5 (3,087 stars, Python, BSD-3-Clause, last commit 2024-01-20).

Abstract

Pre-trained models for Natural Languages (NL) like BERT and GPT have been recently shown to transfer well to Programming Languages (PL) and largely benefit a broad set of code-related tasks. Despite their success, most current methods either rely on an encoder-only (or decoder-only) pre-training that is suboptimal for generation (resp. understanding) tasks or process the code snippet in the same way as NL, neglecting the special characteristics of PL such as token types.

Show full abstract

We present CodeT5, a unified pre-trained encoder-decoder Transformer model that better leverages the code semantics conveyed from the developer-assigned identifiers. Our model employs a unified framework to seamlessly support both code understanding and generation tasks and allows for multi-task learning. Besides, we propose a novel identifier-aware pre-training task that enables the model to distinguish which code tokens are identifiers and to recover them when they are masked. Furthermore, we propose to exploit the user-written code comments with a bimodal dual generation task for better NL-PL alignment. Comprehensive experiments show that CodeT5 significantly outperforms prior methods on understanding tasks such as code defect detection and clone detection, and generation tasks across various directions including PL-NL, NL-PL, and PL-PL. Further analysis reveals that our model can better capture semantic information from code. Our code and pre-trained models are released at https: //github.com/salesforce/CodeT5 .

View on arXivView PDF

Code Implementations(1)

salesforce/CodeT5Official100%
BSD-3-Clause

Home of CodeT5: Open Code LLMs for Code Understanding and Generation

3,087484Python, ShellAug 16, 20212 years agoBSD-3-Clause
code-generationcode-intelligencecode-understandinglanguage-modellarge-language-models

Similar Papers

Cite this paper

@article{wang2021codet,
  title  = {CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation},
  author = {Yue Wang and Weishi Wang and Shafiq Joty and Steven C. H. Hoi},
  year   = {2021},
  eprint = {2109.00859},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2109.00859}
}

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

Discussion