SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2206.06888 · IJCAI · 2022

CERT: Continual Pre-Training on Sketches for Library-Oriented Code Generation

Jian-Guang Lou, Bei Chen, Zeqi Lin, Weizhu Chen, Minsu Kim, Yongji Wang, Dejian Yang, Daoguang Zan, Bei Guan

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 3 failures of our instrument; 4 no recorded run), measured 2026-11-23; 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/2206.06888.json · badge: /api/ran/2206.06888.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
microsoft/PyCodeGPT community
Papers with Code archive
6 ran · 4 no recorded run
FunctionStatusWhere it lives
CodeGenConfig Ran
ran on a synthesized input · constructed an object; no result was computed
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("9a98005a158c5a7f")
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 an instance of its own class, CodeGenConfig: the run constructed the object and did not call it, so no result was computed. 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.configuration_utils import PretrainedConfig

torch.manual_seed(0)

ARGS = {
    'vocab_size': 50400,
    'n_positions': 2048,
    'n_ctx': 2048,
    'n_embd': 4096,
    'n_layer': 28,
    'n_head': 16,
    'rotary_dim': 64,
    'n_inner': None,
    'activation_function': 'gelu_new',
    'resid_pdrop': 0.0,
    'embd_pdrop': 0.0,
    'attn_pdrop': 0.0,
    'layer_norm_epsilon': 1e-05,
    'initializer_range': 0.02,
    'scale_attn_weights': True,
    'gradient_checkpointing': False,
    'use_cache': True,
    'bos_token_id': 50256,
    'eos_token_id': 50256,
}
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 CodeGenConfig — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CodeGenConfig 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
CodeGenMLP Ran
ran on a synthesized input · constructed an object; no result was computed
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("54ceacab7967b07f")
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 an instance of its own class, CodeGenMLP: the run constructed the object and did not call it, so no result was computed. 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
from transformers.activations import ACT2FN

torch.manual_seed(0)

class Config:
    def __init__(self):
        self.n_embd = 4
        self.activation_function = "gelu"
        self.resid_pdrop = 0.1

config = Config()
intermediate_size = 8

ARGS = {
    "intermediate_size": intermediate_size,
    "config": config,
}
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 CodeGenMLP — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CodeGenMLP 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
CodeGenPreTrainedModel Ran
ran on a synthesized input · constructed an object; no result was computed
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("0c1bb45c5236e470")
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 an instance of its own class, CodeGenPreTrainedModel: the run constructed the object and did not call it, so no result was computed. 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
from transformers.modeling_utils import PreTrainedModel
from transformers.configuration_utils import PretrainedConfig

torch.manual_seed(0)

class CodeGenConfig(PretrainedConfig):
    model_type = 'codegen'

    def __init__(self, vocab_size=50400, n_positions=2048, n_ctx=2048, n_embd=4096, n_layer=28, n_head=16, rotary_dim=64, n_inner=None, activation_function='gelu_new', resid_pdrop=0.0, embd_pdrop=0.0, attn_pdrop=0.0, layer_norm_epsilon=1e-05, initializer_range=0.02, scale_attn_weights=True, gradient_checkpointing=False, use_cache=True, bos_token_id=50256, eos_token_id=50256, **kwargs):
        super().__init__(bos_token_id=bos_token_id, eos_token_id=eos_token_id, **kwargs)
        self.vocab_size = vocab_size
        self.n_ctx = n_ctx
        self.n_positions = n_positions
        self.n_embd = n_embd
        self.n_layer = n_layer
        self.n_head = n_head
        self.n_inner = n_inner
        self.rotary_dim = rotary_dim
        self.activation_function = activation_function
        self.resid_pdrop = resid_pdrop
        self.embd_pdrop = embd_pdrop
        self.attn_pdrop = attn_pdrop
        self.layer_norm_epsilon = layer_norm_epsilon
        self.initializer_range = initializer_range
        self.gradient_checkpointing = gradient_checkpointing
        self.scale_attn_weights = scale_attn_weights
        self.use_cache = use_cache
        self.bos_token_id = bos_token_id
        self.eos_token_id = eos_token_id

    @property
    def max_position_embeddings(self):
        return self.n_positions

    @property
    def hidden_size(self):
        return self.n_embd

    @property
    def num_attention_heads(self):
        return self.n_head

    @property
    def num_hidden_layers(self):
        return self.n_layer

class CodeGenPreTrainedModel(PreTrainedModel):
    config_class = CodeGenConfig
    base_model_prefix = 'transformer'
    is_parallelizable = True

    def __init__(self, *inputs, **kwargs):
        super().__init__(*inputs, **kwargs)

    def _init_weights(self, module):
        """Initialize the weights."""
        if isinstance(module, (nn.Linear,)):
            module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
            if module.bias is not None:
                module.bias.data.zero_()
        elif isinstance(module, nn.Embedding):
            module.weight.data.normal_(mean=0.0, std=self.config.initializer_range)
            if module.padding_idx is not None:
                module.weight.data[module.padding_idx].zero_()
        elif isinstance(module, nn.LayerNorm):
            module.bias.data.zero_()
            module.weight.data.fill_(1.0)

config = CodeGenConfig(
    vocab_size=256,
    n_positions=128,
    n_ctx=128,
    n_embd=64,
    n_layer=2,
    n_head=4,
    rotary_dim=32,
    n_inner=None,
    activation_function='gelu_new',
    resid_pdrop=0.0,
    embd_pdrop=0.0,
    attn_pdrop=0.0,
    layer_norm_epsilon=1e-05,
    initializer_range=0.02,
    scale_attn_weights=True,
    gradient_checkpointing=False,
    use_cache=True,
    bos_token_id=50256,
    eos_token_id=50256
)

ARGS = {
    'config': config
}
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 CodeGenPreTrainedModel — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a CodeGenPreTrainedModel 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
apply_rotary_pos_emb Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("e206028c02336479")
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 Tensor, ndim 4, dtype family float, shape (2, 3, 1, 4) 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

torch.manual_seed(0)

# Create a small input tensor x with shape (batch=2, seq_len=3, _, hidden_dim=4)
# The function expects x to have shape [batch, seq_len, ..., hidden_dim]
# where hidden_dim must be even (for rotate_every_two to work)
x = torch.randn(2, 3, 1, 4)

# Create sincos tuple with sin and cos tensors
# These should have shape that after indexing and repeat_interleave matches x's last dim
# The function does: t[None, offset:x.shape[1] + offset, None, :].repeat_interleave(2, 3)
# So t should have shape [seq_len_or_more, 2] to produce shape [1, seq_len, 1, 4] after processing
sin = torch.randn(5, 2)  # seq_len dimension larger than needed
cos = torch.randn(5, 2)
sincos = (sin, cos)

# offset parameter
offset = 0

ARGS = {
    "x": x,
    "sincos": sincos,
    "offset": offset
}
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 Tensor, ndim 4, dtype family float, shape (2, 3, 1, 4) — shape (2, 3, 1, 4) 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
fixed_pos_embedding Ran
ran; our contract draft was wrong, not the code
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("d586789103877809")
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 tuple, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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)

# Create a small tensor with shape (batch=2, seq=3, dim=4)
# The function uses x.shape[-1] to get dim and x.shape[seq_dim] to get seq_len
x = torch.randn(2, 3, 4)

# seq_dim defaults to 1, which indexes into dimension 1 (size 3)
seq_dim = 1

# seq_len defaults to None, which causes the function to infer it from x.shape[seq_dim]
seq_len = None

ARGS = {
    "x": x,
    "seq_dim": seq_dim,
    "seq_len": seq_len,
}
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 tuple, ndim 3, dtype family float — a tuple output has no array shape of its own; none is stated
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
rotate_every_two Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("965428aef96cf65e")
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 Tensor, ndim 4, dtype family float, shape (2, 3, 4, 6) 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

torch.manual_seed(0)

# The function rotate_every_two takes a tensor x and performs operations on it
# x is indexed as: x[:, :, :, ::2] and x[:, :, :, 1::2]
# This means x needs at least 4 dimensions
# The function stacks along axis=-1 and then flattens the last 2 dimensions
# So x should be a 4D tensor

# Create a small 4D tensor: (batch=2, dim1=3, dim2=4, dim3=6)
# dim3=6 is chosen to have both even indices (0,2,4) and odd indices (1,3,5)
x = torch.randn(2, 3, 4, 6)

ARGS = {
    "x": x
}
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 Tensor, ndim 4, dtype family float, shape (2, 3, 4, 6) — shape (2, 3, 4, 6) 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
CodeGenAttention Not yet run
unverified (harvested, no recorded run)
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("b4b48d095d30d89f")
How it ran

no invocation recorded.

CodeGenBlock Not yet run
unverified (harvested, no recorded run)
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("214a0ce860b0d7f9")
How it ran

no invocation recorded.

CodeGenForCausalLM Not yet run
unverified (harvested, no recorded run)
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("f345d1ad92797f35")
How it ran

no invocation recorded.

CodeGenModel Not yet run
unverified (harvested, no recorded run)
microsoft/PyCodeGPT/apicoder/CodeGenAPI/nl2code/modeling_codegen.py
code served (permissive licence) · get_code("5c007506c5e12ee8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 3 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 3 the same month, 3 later) and 7 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.

FunctionAlso present inEarliest-datedOthers named
rotate_every_two
brick of this paper's assembly: helper
4 other papers
1 dated earlier, 1 the same month, 2 later
2203.13474 (2022-03)
CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
2206.13517 (2022-06)
ProGen2: Exploring the Boundaries of Protein Language Models
2309.01327 (2023-09)
Can I Trust Your Answer? Visually Grounded Video Question Answering
and 1 more not named here
apply_rotary_pos_emb
brick of this paper's assembly: model
3 other papers
1 dated earlier, 1 the same month, 1 later
2203.13474 (2022-03)
CodeGen: An Open Large Language Model for Code with Multi-Turn Program Synthesis
2206.13517 (2022-06)
ProGen2: Exploring the Boundaries of Protein Language Models
2512.02315 (2025-12)
Few-shot Protein Fitness Prediction via In-context Learning and Test-time Training
fixed_pos_embedding
brick of this paper's assembly: helper
2 other papers
1 the same month, 1 later
2206.13517 (2022-06)
ProGen2: Exploring the Boundaries of Protein Language Models
2512.02315 (2025-12)
Few-shot Protein Fitness Prediction via In-context Learning and Test-time Training

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

Repositories linked to this paper

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

Abstract

Code generation is a longstanding challenge, aiming to generate a code snippet based on a natural language description. Usually, expensive textcode paired data is essential for training a code generation model. Recently, thanks to the success of pre-training techniques, large language models are trained on large-scale unlabelled code corpora and perform well in code generation. In this paper, we investigate how to leverage an unlabelled code corpus to train a model for library-oriented code generation. Since it is a common practice for programmers to reuse third-party libraries, in which case the text-code paired data are harder to obtain due to the huge number of libraries. We observe that library-oriented code snippets are more likely to share similar code sketches. Hence, we present CERT with two steps: a sketcher generates the sketch, then a generator fills the details in the sketch. Both the sketcher and the generator are continually pre-trained upon a base model using unlabelled data. Furthermore, we craft two benchmarks named PandasEval and NumpyEval to evaluate library-oriented code generation. Experimental results demonstrate the impressive performance of CERT. For example, it surpasses the base model by an absolute 15.67% improvement in terms of pass@1 on PandasEval. Our work is available at https://github.com/microsoft/PyCodeGPT.

For agents

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

get_harvested_code_for_paper("2206.06888")
get_code_for_paper("2206.06888")
have("2206.06888")

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

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

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

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

Connect an agent — have() is free.