{"about":{"site":"https://codewithpapers.app","non_affiliation":"Code with Papers and Syntology are not affiliated with, endorsed by, or sponsored by Papers with Code, Meta, or the pwc-archive mirror.","licence":"CC BY-SA 4.0","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","attribution":"https://codewithpapers.app/attribution","modified":"archive material modified by Syntology; see the attribution page"},"url":"/paper/codet5-identifier-aware-unified-pre-trained","title":"CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generation","arxiv_id":"2109.00859","date":"2021-09-02","proceeding":"EMNLP 2021 11","authors":["Yue Wang","Weishi Wang","Shafiq Joty","Steven C. H. Hoi"],"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. 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 .","url_abs":"https://arxiv.org/abs/2109.00859v1","url_pdf":"https://arxiv.org/pdf/2109.00859v1.pdf","source":{"archive":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","licence_url":"https://creativecommons.org/licenses/by-sa/4.0/legalcode","row_kind":"abstracts"},"code_links":[{"paper_slug":"codet5-identifier-aware-unified-pre-trained","repo_url":"https://github.com/salesforce/codet5","is_official":1,"mentioned_in_paper":1,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"codet5-identifier-aware-unified-pre-trained","repo_url":"https://github.com/awsm-research/vulrepair","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"MIT"}},{"paper_slug":"codet5-identifier-aware-unified-pre-trained","repo_url":"https://github.com/fewshotcdcs/cdcs","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":{"status":"ok"}},{"paper_slug":"codet5-identifier-aware-unified-pre-trained","repo_url":"https://github.com/jetbrains-research/commit_message_generation","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"pytorch","reach":null},{"paper_slug":"codet5-identifier-aware-unified-pre-trained","repo_url":"https://github.com/salesforce/coderl","is_official":0,"mentioned_in_paper":0,"mentioned_in_github":1,"framework":"jax","reach":{"status":"ok","spdx":"BSD-3-Clause"}}],"tasks":[{"task_slug":"clone-detection","task_name":"Clone Detection"},{"task_slug":"code-generation","task_name":"Code Generation"},{"task_slug":"code-summarization-1","task_name":"Code Summarization"},{"task_slug":"code-translation","task_name":"Code Translation"},{"task_slug":"decoder","task_name":"Decoder"},{"task_slug":"defect-detection","task_name":"Defect Detection"},{"task_slug":"multi-task-learning","task_name":"Multi-Task Learning"},{"task_slug":"text-to-code-generation","task_name":"Text-to-Code Generation"}],"methods":[{"method_slug":"absolute-position-encodings","method_name":"Absolute Position Encodings"},{"method_slug":"adafactor","method_name":"Adafactor"},{"method_slug":"adam","method_name":"Adam"},{"method_slug":"attention","method_name":"Attention"},{"method_slug":"attention-dropout","method_name":"Attention Dropout"},{"method_slug":"bert","method_name":"BERT"},{"method_slug":"bpe","method_name":"BPE"},{"method_slug":"codet5","method_name":"CodeT5"},{"method_slug":"cosine-annealing","method_name":"Cosine Annealing"},{"method_slug":"dense-connections","method_name":"Dense Connections"},{"method_slug":"discriminative-fine-tuning","method_name":"Discriminative Fine-Tuning"},{"method_slug":"dropout","method_name":"Dropout"},{"method_slug":"gpt","method_name":"GPT"},{"method_slug":"glu","method_name":"Gated Linear Unit"},{"method_slug":"inverse-square-root-schedule","method_name":"Inverse Square Root Schedule"},{"method_slug":"label-smoothing","method_name":"Label Smoothing"},{"method_slug":"layer-normalization","method_name":"Layer Normalization"},{"method_slug":"linear-layer","method_name":"Linear Layer"},{"method_slug":"linear-warmup-with-cosine-annealing","method_name":"Linear Warmup With Cosine Annealing"},{"method_slug":"linear-warmup-with-linear-decay","method_name":"Linear Warmup With Linear Decay"},{"method_slug":"multi-head-attention","method_name":"Multi-Head Attention"},{"method_slug":"position-wise-feed-forward-layer","method_name":"Position-Wise Feed-Forward Layer"},{"method_slug":"residual-connection","method_name":"Residual Connection"},{"method_slug":"sentencepiece","method_name":"SentencePiece"},{"method_slug":"softmax","method_name":"Softmax"},{"method_slug":"t5","method_name":"T5"},{"method_slug":"transformer","method_name":"Transformer"},{"method_slug":"weight-decay","method_name":"Weight Decay"},{"method_slug":"wordpiece","method_name":"WordPiece"}],"datasets_introduced":[],"methods_introduced":[{"slug":"codet5","name":"CodeT5","full_name":"CodeT5"}],"results":[{"leaderboard":"/sota/code-generation-on-concode","task":"Code Generation","dataset":"CONCODE","model":"CodeT5","rank_in_archive_order":2,"of":2,"metrics":{"BLEU":"41.48","CodeBLEU":"44.10","Exact Match":"22.70"},"uses_additional_data":false},{"leaderboard":"/sota/code-translation-on-codexglue-codetrans","task":"Code Translation","dataset":"CodeXGLUE - CodeTrans","model":"CodeT5","rank_in_archive_order":1,"of":2,"metrics":{"Accuracy (C#→Java)":"66.90","Accuracy (Java→C#)":"65.90","BLEU (C#→Java)":"79.87","BLEU (Java→C#)":"84.03"},"uses_additional_data":false},{"leaderboard":"/sota/text-to-code-generation-on-codexglue-concode","task":"Text-to-Code Generation","dataset":"CodeXGLUE - CONCODE","model":"CodeT5","rank_in_archive_order":1,"of":2,"metrics":{"BLEU":"41.48","CodeBLEU":"44.10","EM":"22.70"},"uses_additional_data":false}],"syntology":{"atlas_url":"https://app.syntology.ai/?focus=2109.00859","mcp":{"get_harvested_code_for_paper":{"arxiv_id":"2109.00859"}},"developers":"https://syntology.ai/developers","read_at":"2026-09-24T18:15:14+00:00","read_at_is":"when the build read Syntology's graph, not when any sample ran","claim":"Per-sample execution status on synthesized fixtures; not a correctness claim about the paper. Samples come from repositories linked to the paper, official or community; repo_kind says which.","repos":[{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/awsm-research/vulrepair","reach":{"status":"ok","spdx":"MIT"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/salesforce/codet5","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/jetbrains-research/commit_message_generation","reach":null},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/salesforce/coderl","reach":{"status":"ok","spdx":"BSD-3-Clause"}},{"provenance":"external:paperswithcode_snapshot_2025-07-28","url":"https://github.com/fewshotcdcs/cdcs","reach":{"status":"ok"}},{"provenance":"deterministic:regex_extraction","url":"https://github.com/salesforce/CodeT5","reach":null}],"summary":{"ran":1,"unverified":10},"by_repo_kind":{"official":{"samples":1,"ran":0,"repositories":1},"listed":{"samples":10,"ran":1,"repositories":2}},"repo_kind_vocabulary":{"official":"The archive marks this repository official for the paper","named_in_paper":"The archive records that the paper mentions this repository; it is not marked official","listed":"In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper","found_in_text":"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"},"n_pointer_only_for_licence":0,"samples":[{"code_sha256_prefix":"2b0bcde4b9bbfad6","entry":"remove_layers_from_model","repo":"jetbrains-research/commit_message_generation","repo_kind":"listed","path":"src/model/configurations/encoder_decoder_wrapper.py","file_url":"https://github.com/jetbrains-research/commit_message_generation/blob/HEAD/src/model/configurations/encoder_decoder_wrapper.py","link_basis":"first_harvest_node","language":"python","status":"ran","verification_level":1,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"2b0bcde4b9bbfad6"}},{"code_sha256_prefix":"69bd5c80d76febfd","entry":"BaseModel","repo":"jetbrains-research/commit_message_generation","repo_kind":"listed","path":"src/model/configurations/encoder_decoder_wrapper.py","file_url":"https://github.com/jetbrains-research/commit_message_generation/blob/HEAD/src/model/configurations/encoder_decoder_wrapper.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"69bd5c80d76febfd"}},{"code_sha256_prefix":"71f1a07d4d450ff9","entry":"Batch","repo":"jetbrains-research/commit_message_generation","repo_kind":"listed","path":"src/model/configurations/encoder_decoder_wrapper.py","file_url":"https://github.com/jetbrains-research/commit_message_generation/blob/HEAD/src/model/configurations/encoder_decoder_wrapper.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"71f1a07d4d450ff9"}},{"code_sha256_prefix":"a268843ac76f4d5f","entry":"BatchTest","repo":"jetbrains-research/commit_message_generation","repo_kind":"listed","path":"src/model/configurations/encoder_decoder_wrapper.py","file_url":"https://github.com/jetbrains-research/commit_message_generation/blob/HEAD/src/model/configurations/encoder_decoder_wrapper.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"a268843ac76f4d5f"}},{"code_sha256_prefix":"682362de430d8871","entry":"EncoderDecoderWrapper","repo":"jetbrains-research/commit_message_generation","repo_kind":"listed","path":"src/model/configurations/encoder_decoder_wrapper.py","file_url":"https://github.com/jetbrains-research/commit_message_generation/blob/HEAD/src/model/configurations/encoder_decoder_wrapper.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"682362de430d8871"}},{"code_sha256_prefix":"fde59ee6f478c51c","entry":"Seq2Seq","repo":"salesforce/CodeT5","repo_kind":"official","path":"CodeT5/models.py","file_url":"https://github.com/salesforce/CodeT5/blob/HEAD/CodeT5/models.py","link_basis":"first_harvest_node","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"BSD-3-Clause","inline_ok":true,"mcp_get_code":{"code_sha256":"fde59ee6f478c51c"}},{"code_sha256_prefix":"843ffc9d31ab0578","entry":"clean_tokens","repo":"awsm-research/vulrepair","repo_kind":"listed","path":"M1_VulRepair_PL-NL/vulrepair_main.py","file_url":"https://github.com/awsm-research/vulrepair/blob/HEAD/M1_VulRepair_PL-NL/vulrepair_main.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"843ffc9d31ab0578"}},{"code_sha256_prefix":"4e56b8b8e19724a4","entry":"clean_tokens","repo":"awsm-research/vulrepair","repo_kind":"listed","path":"M10_T5_no_pretrain_word_level/t5_no_pretraining_wordlevel_main.py","file_url":"https://github.com/awsm-research/vulrepair/blob/HEAD/M10_T5_no_pretrain_word_level/t5_no_pretraining_wordlevel_main.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"4e56b8b8e19724a4"}},{"code_sha256_prefix":"f4b7f3287895271c","entry":"convert_examples_to_features","repo":"awsm-research/vulrepair","repo_kind":"listed","path":"M1_VulRepair_PL-NL/vulrepair_main.py","file_url":"https://github.com/awsm-research/vulrepair/blob/HEAD/M1_VulRepair_PL-NL/vulrepair_main.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"f4b7f3287895271c"}},{"code_sha256_prefix":"ba2859de69445f88","entry":"convert_examples_to_features","repo":"awsm-research/vulrepair","repo_kind":"listed","path":"M10_T5_no_pretrain_word_level/t5_no_pretraining_wordlevel_main.py","file_url":"https://github.com/awsm-research/vulrepair/blob/HEAD/M10_T5_no_pretrain_word_level/t5_no_pretraining_wordlevel_main.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"ba2859de69445f88"}},{"code_sha256_prefix":"0b0dc8f9dc8cb6b8","entry":"evaluate","repo":"awsm-research/vulrepair","repo_kind":"listed","path":"M1_VulRepair_PL-NL/vulrepair_main.py","file_url":"https://github.com/awsm-research/vulrepair/blob/HEAD/M1_VulRepair_PL-NL/vulrepair_main.py","link_basis":"harvester_set","language":"python","status":"unverified","verification_level":0,"contract_check":null,"metamorphic_tier":null,"behaviour_fingerprint":false,"licence":"MIT","inline_ok":true,"mcp_get_code":{"code_sha256":"0b0dc8f9dc8cb6b8"}}]},"arxiv_metadata":null,"syntology_extracted_results":null}