SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2109.00859 · EMNLP · 2021

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

Steven Hoi, Shafiq Joty, Yue Wang, Weishi Wang

arXiv · PDF · Open in the Atlas

Code that ran

6 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 1 failure of our instrument; 5 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2109.00859.json · badge: /api/ran/2109.00859.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
awsm-research/vulrepair community (classifier label)
classifier basis not recorded on the link
5 ran · 0 no recorded run
jetbrains-research/commit_message_generation community
Papers with Code archive
1 ran · 4 no recorded run
salesforce/CodeT5 community
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
clean_tokens Ran
ran on a synthesized input
awsm-research/vulrepair/M1_VulRepair_PL-NL/vulrepair_main.py
code served (permissive licence) · get_code("843ffc9d31ab0578")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function clean_tokens takes a string parameter 'tokens'
# and performs various string replacements and stripping operations
# It expects a string input

ARGS = {
    'tokens': '<pad>Hello<s>World</s><pad>\n'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
clean_tokens Ran
ran on a synthesized input
awsm-research/vulrepair/M10_T5_no_pretrain_word_level/t5_no_pretraining_wordlevel_main.py
code served (permissive licence) · get_code("4e56b8b8e19724a4")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function clean_tokens takes a string 'tokens' as input
# and performs several string operations on it (replace, strip)
# It returns a cleaned string

# Create a sample tokens string with special tokens and whitespace
tokens_input = "  [CLS] hello [PAD] world [SEP] \n"

ARGS = {
    "tokens": tokens_input
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_examples_to_features Ran
ran on a synthesized input
awsm-research/vulrepair/M1_VulRepair_PL-NL/vulrepair_main.py
code served (permissive licence) · get_code("f4b7f3287895271c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned InputFeatures. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class MockTokenizer:
    def encode(self, text, truncation=False, max_length=None, padding=None, return_tensors=None):
        # Return a tensor with shape (1, max_length) when return_tensors='pt'
        if return_tensors == 'pt':
            return torch.randint(0, 100, (1, max_length if max_length else 10))
        return [1, 2, 3]

class MockArgs:
    def __init__(self):
        self.encoder_block_size = 8
        self.decoder_block_size = 6

ARGS = {
    'source': 'This is a source sentence.',
    'label': 'This is a target sentence.',
    'tokenizer': MockTokenizer(),
    'args': MockArgs()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type InputFeatures — a InputFeatures output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a InputFeatures output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
convert_examples_to_features Ran
ran on a synthesized input
awsm-research/vulrepair/M10_T5_no_pretrain_word_level/t5_no_pretraining_wordlevel_main.py
code served (permissive licence) · get_code("ba2859de69445f88")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned InputFeatures. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

class MockTokenizer:
    """Stand-in tokenizer that returns encoded tokens with an .ids attribute"""
    def encode(self, text):
        # Return an object with .ids attribute containing token IDs
        class EncodedTokens:
            def __init__(self, ids):
                self.ids = ids
        
        # Simple mock: convert text length to a few token IDs
        token_ids = [101] + [i % 100 for i in range(len(text))] + [102]
        return EncodedTokens(token_ids)

class MockArgs:
    """Stand-in args object"""
    def __init__(self):
        self.max_source_length = 512
        self.max_target_length = 256

tokenizer = MockTokenizer()
source = "This is a test source text for encoding."
label = "This is a test label for decoding."
args = MockArgs()

ARGS = {
    "source": source,
    "label": label,
    "tokenizer": tokenizer,
    "args": args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type InputFeatures — a InputFeatures output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a InputFeatures output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
evaluate Ran
ran on a synthesized input
awsm-research/vulrepair/M1_VulRepair_PL-NL/vulrepair_main.py
code served (permissive licence) · get_code("0b0dc8f9dc8cb6b8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch.utils.data import Dataset

torch.manual_seed(0)

class SimpleTokenizer:
    pass

class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, input_ids, attention_mask, labels):
        # Return a simple loss
        logits = self.linear(input_ids.float())
        loss = nn.functional.mse_loss(logits, labels.float())
        return type('Output', (), {'loss': loss})()

class SimpleDataset(Dataset):
    def __init__(self, size=2):
        self.size = size
    
    def __len__(self):
        return self.size
    
    def __getitem__(self, idx):
        # Return (input_ids, attention_mask, labels, decoder_input_ids)
        # Each needs to have shape (1, 4) for squeeze(1) to work
        return (
            torch.randint(0, 10, (1, 4)),
            torch.ones((1, 4)),
            torch.randn((1, 2)),
            torch.randint(0, 10, (1, 4))
        )

args = type('Args', (), {
    'eval_batch_size': 2,
    'n_gpu': 1,
    'device': 'cpu'
})()

model = SimpleModel()
tokenizer = SimpleTokenizer()
eval_dataset = SimpleDataset(size=2)

ARGS = {
    'args': args,
    'model': model,
    'tokenizer': tokenizer,
    'eval_dataset': eval_dataset,
    'eval_when_training': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
remove_layers_from_model Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
jetbrains-research/commit_message_generation/src/model/configurations/encoder_decoder_wrapper.py
code served (permissive licence) · get_code("2b0bcde4b9bbfad6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned RobertaForCausalLM. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from transformers import RobertaConfig, RobertaModel, RobertaForCausalLM, GPT2Config, GPT2LMHeadModel

torch.manual_seed(0)

# Create a small RobertaForCausalLM teacher model with 4 layers
roberta_config = RobertaConfig(
    vocab_size=100,
    hidden_size=8,
    num_hidden_layers=4,
    num_attention_heads=2,
    intermediate_size=16,
    max_position_embeddings=128,
    type_vocab_size=2,
)
teacher_roberta_lm = RobertaForCausalLM(config=roberta_config)

# Create a small RobertaModel teacher with 4 layers
teacher_roberta = RobertaModel(config=roberta_config)

# Create a small GPT2LMHeadModel teacher with 4 layers
gpt2_config = GPT2Config(
    vocab_size=100,
    n_positions=128,
    n_embd=8,
    n_layer=4,
    n_head=2,
)
teacher_gpt2 = GPT2LMHeadModel(config=gpt2_config)

ARGS = {
    "teacher": teacher_roberta_lm,
    "num_layers": 2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RobertaForCausalLM — a RobertaForCausalLM output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a RobertaForCausalLM output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
BaseModel Not yet run
unverified (harvested, no recorded run)
jetbrains-research/commit_message_generation/src/model/configurations/encoder_decoder_wrapper.py
code served (permissive licence) · get_code("69bd5c80d76febfd")
How it ran

no invocation recorded.

Batch Not yet run
unverified (harvested, no recorded run)
jetbrains-research/commit_message_generation/src/model/configurations/encoder_decoder_wrapper.py
code served (permissive licence) · get_code("71f1a07d4d450ff9")
How it ran

no invocation recorded.

BatchTest Not yet run
unverified (harvested, no recorded run)
jetbrains-research/commit_message_generation/src/model/configurations/encoder_decoder_wrapper.py
code served (permissive licence) · get_code("a268843ac76f4d5f")
How it ran

no invocation recorded.

EncoderDecoderWrapper Not yet run
unverified (harvested, no recorded run)
jetbrains-research/commit_message_generation/src/model/configurations/encoder_decoder_wrapper.py
code served (permissive licence) · get_code("682362de430d8871")
How it ran

no invocation recorded.

Seq2Seq Not yet run
unverified (harvested, no recorded run)
salesforce/CodeT5/CodeT5/models.py
code served (permissive licence) · get_code("fde59ee6f478c51c")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

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.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2109.00859")
get_code_for_paper("2109.00859")
have("2109.00859")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2109.00859.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2109.00859.svg)](https://syntology.ai/paper/2109.00859)

Connect an agent — have() is free.