SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2204.05999 · ICLR · 2023

InCoder: A Generative Model for Code Infilling and Synthesis

Eric Wallace, Mike Lewis, Wen-Tau Yih, Berkeley Uc, Sida Wang, Daniel Fried, Armen Aghajanyan, Jessy Lin, Freda Shi, Ruiqi Zhong, ♡ Luke, Tti-Chicago

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 (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 2 have no contract verdict; 3 failures of our instrument; 4 no recorded run), measured 2026-11-24; 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/2204.05999.json · badge: /api/ran/2204.05999.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
dpfried/incoder canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
eth-sri/sven community
Papers with Code archive
4 ran · 4 no recorded run
FunctionStatusWhere it lives
XGLMAttention Ran
ran on a synthesized input
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("0854e65df6769a95")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. 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 numpy as np
from typing import Optional, Tuple, Union, List

INIT_ARGS = {
    'embed_dim': 4,
    'num_heads': 2,
    'dropout': 0.0,
    'is_decoder': False,
    'bias': True
}

# Create input tensors for forward pass
bsz = 2
tgt_len = 3
src_len = 4
hidden_states = torch.randn(bsz, tgt_len, INIT_ARGS['embed_dim'])
key_value_states = torch.randn(bsz, src_len, INIT_ARGS['embed_dim'])
attention_mask = torch.zeros(bsz, 1, tgt_len, src_len)
attention_mask[:, :, :, 2:] = -1e9  # Mask some positions

ARGS = {
    'hidden_states': hidden_states,
    'key_value_states': key_value_states,
    'past_key_value': None,
    'attention_mask': attention_mask,
    'layer_head_mask': None,
    'output_attentions': False
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
XGLMSinusoidalPositionalEmbedding Ran
ran on a synthesized input
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("eb281e9c8335db3a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 3, dtype family float, shape (2, 4, 8) 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
from typing import Optional, Tuple, Union, List
import math
from torch import nn

def create_position_ids_from_input_ids(input_ids, padding_idx, past_key_values_length=0):
    """
    Replace non-padding symbols with their position numbers. Position numbers begin at padding_idx+1. Padding symbols
    are ignored. This is modified from fairseq's `utils.make_positions`.
    """
    mask = input_ids.ne(padding_idx).int()
    incremental_indices = (torch.cumsum(mask, dim=1).type_as(mask) + past_key_values_length) * mask
    return incremental_indices.long() + padding_idx

class XGLMSinusoidalPositionalEmbedding(nn.Module):
    """This module produces sinusoidal positional embeddings of any length."""

    def __init__(self, num_positions: int, embedding_dim: int, padding_idx: Optional[int]=None):
        super().__init__()
        self.offset = 2
        self.embedding_dim = embedding_dim
        self.padding_idx = padding_idx
        self.make_weights(num_positions + self.offset, embedding_dim, padding_idx)

    def make_weights(self, num_embeddings: int, embedding_dim: int, padding_idx: Optional[int]=None):
        emb_weights = self.get_embedding(num_embeddings, embedding_dim, padding_idx)
        if hasattr(self, 'weights'):
            emb_weights = emb_weights.to(dtype=self.weights.dtype, device=self.weights.device)
        self.register_buffer('weights', emb_weights)

    @staticmethod
    def get_embedding(num_embeddings: int, embedding_dim: int, padding_idx: Optional[int]=None):
        """
        Build sinusoidal embeddings.

        This matches the implementation in tensor2tensor, but differs slightly from the description in Section 3.5 of
        "Attention Is All You Need".
        """
        half_dim = embedding_dim // 2
        emb = math.log(10000) / (half_dim - 1)
        emb = torch.exp(torch.arange(half_dim, dtype=torch.float) * -emb)
        emb = torch.arange(num_embeddings, dtype=torch.float).unsqueeze(1) * emb.unsqueeze(0)
        emb = torch.cat([torch.sin(emb), torch.cos(emb)], dim=1).view(num_embeddings, -1)
        if embedding_dim % 2 == 1:
            emb = torch.cat([emb, torch.zeros(num_embeddings, 1)], dim=1)
        if padding_idx is not None:
            emb[padding_idx, :] = 0
        return emb.to(torch.get_default_dtype())

    @torch.no_grad()
    def forward(self, input_ids: torch.Tensor=None, inputs_embeds: torch.Tensor=None, past_key_values_length: int=0):
        if input_ids is not None:
            bsz, seq_len = input_ids.size()
            position_ids = create_position_ids_from_input_ids(input_ids, self.padding_idx, past_key_values_length).to(input_ids.device)
        else:
            bsz, seq_len = inputs_embeds.size()[:-1]
            position_ids = self.create_position_ids_from_inputs_embeds(inputs_embeds, past_key_values_length)
        max_pos = self.padding_idx + 1 + seq_len + past_key_values_length
        if max_pos > self.weights.size(0):
            self.make_weights(max_pos + self.offset, self.embedding_dim, self.padding_idx)
        return self.weights.index_select(0, position_ids.view(-1)).view(bsz, seq_len, -1).detach()

    def create_position_ids_from_inputs_embeds(self, inputs_embeds, past_key_values_length):
        """
        We are provided embeddings directly. We cannot infer which are padded so just generate sequential position ids.

        Args:
            inputs_embeds: torch.Tensor

        Returns: torch.Tensor
        """
        input_shape = inputs_embeds.size()[:-1]
        sequence_length = input_shape[1]
        position_ids = torch.arange(self.padding_idx + 1, sequence_length + self.padding_idx + 1, dtype=torch.long, device=inputs_embeds.device)
        return position_ids.unsqueeze(0).expand(input_shape).contiguous() + past_key_values_length


INIT_ARGS = {
    'num_positions': 16,
    'embedding_dim': 8,
    'padding_idx': 0,
}

ARGS = {
    'input_ids': torch.tensor([[1, 2, 3, 0], [1, 2, 0, 0]], dtype=torch.long),
    'inputs_embeds': None,
    'past_key_values_length': 0,
}

if __name__ == '__main__':
    model = XGLMSinusoidalPositionalEmbedding(**INIT_ARGS)
    output = model(**ARGS)
    print("Output shape:", output.shape)
    print("Output:", output)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 3, dtype family float, shape (2, 4, 8) — shape (2, 4, 8) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
_expand_mask Ran
ran; our contract draft was wrong, not the code
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("775a840572f4ed73")
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) and returned Tensor, ndim 4, dtype family float, shape (2, 1, 3, 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 attention mask tensor of shape [bsz, seq_len]
# bsz=2, seq_len=4
mask = torch.randint(0, 2, (2, 4), dtype=torch.float32)

# dtype for expansion
dtype = torch.float32

# Optional target length (can be None or an int)
tgt_len = 3

ARGS = {
    "mask": mask,
    "dtype": dtype,
    "tgt_len": tgt_len,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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, 1, 3, 4) — shape (2, 1, 3, 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
create_position_ids_from_input_ids Ran
ran; our contract draft was wrong, not the code
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("336749dd7d699ef6")
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) and returned Tensor, ndim 2, dtype family int, shape (2, 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 input_ids tensor with shape (batch_size=2, seq_length=4)
# Values should include some padding tokens and some non-padding tokens
input_ids = torch.tensor([
    [0, 1, 2, 0],      # batch 1: padding_idx=0 at positions 0 and 3
    [1, 2, 0, 1]       # batch 2: padding_idx=0 at position 2
])

# padding_idx is the token ID used for padding (typically 0)
padding_idx = 0

# past_key_values_length represents how many tokens were processed before
# (used in autoregressive generation to offset position indices)
past_key_values_length = 0

ARGS = {
    "input_ids": input_ids,
    "padding_idx": padding_idx,
    "past_key_values_length": past_key_values_length
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family int, shape (2, 4) — shape (2, 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
make_sentinel Ran
ran; our contract draft was wrong, not the code
dpfried/incoder/example_usage.py
pointer only (licence: NONE) · get_code("bd9a376893413836")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, dpfried/incoder when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

remove_extra_code Ran
ran, violated the contract we drafted
dpfried/incoder/example_batched_usage.py
pointer only (licence: NONE) · get_code("0aa9acb3da041d44")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, dpfried/incoder when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

IncoderPrefixLM Not yet run
unverified (harvested, no recorded run)
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("54f7e0d1438b01d9")
How it ran

no invocation recorded.

XGLMDecoderLayer Not yet run
unverified (harvested, no recorded run)
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("0f9421d915df42a2")
How it ran

no invocation recorded.

XGLMForCausalLM Not yet run
unverified (harvested, no recorded run)
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("b7b3190b983be614")
How it ran

no invocation recorded.

XGLMModel Not yet run
unverified (harvested, no recorded run)
eth-sri/sven/sven/model.py
code served (permissive licence) · get_code("85ea2ae534378080")
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, 1 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
create_position_ids_from_input_ids
brick of this paper's assembly: helper
28 other papers
6 dated earlier, 1 the same month, 21 later
2107.00910 (2021-07)
Learned Token Pruning for Transformers
2107.14035 (2021-07)
ProtoTransformer: A Meta-Learning Approach to Providing Student Feedback
2201.11732 (2022-01)
IGLUE: A Benchmark for Transfer Learning across Modalities, Tasks, and Languages
and 25 more not named here
_expand_mask
brick of this paper's assembly: helper
16 other papers
1 dated earlier, 15 later · 8 only as an assembly brick
2203.08913 (2022-03)
Memorizing Transformers
2307.09288 (2023-07)
Llama 2: Open Foundation and Fine-Tuned Chat Models
2401.07159 (2024-01)
Quantized Side Tuning: Fast and Memory-Efficient Tuning of Quantized Large Language Models
and 13 more not named here
make_sentinel 1 other paper
1 later
2306.03438 (2023-06)
Large Language Models of Code Fail at Completing Code with Potential Bugs

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

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 is seldom written in a single left-to-right pass and is instead repeatedly edited and refined. We introduce INCODER, a unified generative model that can perform program synthesis (via left-to-right generation) as well as editing (via masking and infilling). InCoder is trained to generate code files from a large corpus of permissively licensed code, where regions of code have been randomly masked and moved to the end of each file, allowing code infilling with bidirectional context. Our model is the first large generative code model that is able to infill arbitrary regions of code, which we evaluate in a zero-shot setting on challenging tasks such as type inference, comment generation, and variable re-naming. We find that the ability to condition on bidirectional context substantially improves performance on these tasks, while still performing comparably on standard program synthesis benchmarks in comparison to left-to-right only models pretrained at similar scale. Our models and code are publicly released. 1

For agents

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

get_harvested_code_for_paper("2204.05999")
get_code_for_paper("2204.05999")
have("2204.05999")

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

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

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

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

Connect an agent — have() is free.