SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1611.08307 · 2016

Learning Python Code Suggestion with a Sparse Pointer Network

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 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 3 have no contract verdict; 4 failures of our instrument; 2 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/1611.08307.json · badge: /api/ran/1611.08307.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
uclnlp/pycodesuggest canonical (classifier label)
classifier basis: classifier_2025
4 ran · 0 no recorded run
uclmr/pycodesuggest canonical (classifier label)
classifier basis: census
3 ran · 2 no recorded run
FunctionStatusWhere it lives
construct_feed_dict Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
uclnlp/pycodesuggest/lm/Trainer.py
code served (permissive licence) · get_code("21ecd560e4d4c5d4")
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 1, 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
import torch.nn as nn

torch.manual_seed(0)

class MockModel(nn.Module):
    def __init__(self, is_attention_model=False, num_layers=2, batch_size=2, seq_len=5, input_size=4, state_size=3):
        super().__init__()
        self.is_attention_model = is_attention_model
        self.batch_size = batch_size
        self.seq_len = seq_len
        self.input_size = input_size
        self.state_size = state_size
        self.num_layers = num_layers
        
        # Create dummy placeholders for input/output tensors
        self.input_data = torch.zeros(batch_size, seq_len, input_size)
        self.targets = torch.zeros(batch_size, seq_len, dtype=torch.long)
        self.actual_lengths = torch.zeros(batch_size, dtype=torch.long)
        self.masks = torch.ones(batch_size, seq_len)
        
        # Create initial state structure
        if is_attention_model:
            # Tuple of (state_tuple, att_states_list, att_ids_list, att_values_list, att_counts_list)
            state_cells = [(torch.zeros(batch_size, state_size), torch.zeros(batch_size, state_size)) 
                          for _ in range(num_layers)]
            att_states = [torch.zeros(batch_size, state_size) for _ in range(num_layers)]
            att_ids = [torch.zeros(batch_size, dtype=torch.long) for _ in range(num_layers)]
            att_counts = [torch.zeros(batch_size, dtype=torch.long) for _ in range(num_layers)]
            
            self.initial_state = (state_cells, att_states, att_ids, None, att_counts)
        else:
            # Just state cells for non-attention model
            self.initial_state = [(torch.zeros(batch_size, state_size), torch.zeros(batch_size, state_size)) 
                                 for _ in range(num_layers)]

# Create model instance
model = MockModel(is_attention_model=True, num_layers=2, batch_size=2, seq_len=5, input_size=4, state_size=3)

# Create seq_batch tuple: (input_data, targets, masks, identifier_usage, actual_lengths)
seq_batch = (
    torch.randn(2, 5, 4),  # input_data
    torch.randint(0, 10, (2, 5)),  # targets
    torch.ones(2, 5),  # masks
    {"token1": 1, "token2": 2},  # identifier_usage
    torch.tensor([5, 4], dtype=torch.long)  # actual_lengths
)

# Create state for each layer: list of (cell, memory) tuples
state = [
    (torch.randn(2, 3), torch.randn(2, 3)),
    (torch.randn(2, 3), torch.randn(2, 3))
]

# Create attention states, ids, and counts
att_states = [torch.randn(2, 3) for _ in range(2)]
att_ids = [torch.randint(0, 5, (2,)) for _ in range(2)]
att_counts = [torch.tensor([1, 2], dtype=torch.long) for _ in range(2)]

ARGS = {
    "model": model,
    "seq_batch": seq_batch,
    "state": state,
    "att_states": att_states,
    "att_ids": att_ids,
    "att_counts": att_counts
}
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 1, 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
create_repos Ran
ran; our contract draft was wrong, not the code
uclnlp/pycodesuggest/github-scraper/scraper.py
code served (permissive licence) · get_code("cafacac10b08f067")
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 list, ndim 1, 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 pickle
import os
import tempfile

# Create a temporary directory for testing
temp_dir = tempfile.mkdtemp()
db_file = os.path.join(temp_dir, "test_db.pkl")

# Create a sample repos list and pickle it
sample_repos = [
    {"name": "repo1", "url": "https://example.com/repo1"},
    {"name": "repo2", "url": "https://example.com/repo2"}
]

with open(db_file, 'wb') as f:
    pickle.dump(sample_repos, f)

ARGS = {
    "dbFile": db_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
get_evals Ran
ran; our contract draft was wrong, not the code
uclnlp/pycodesuggest/lm/Trainer.py
code served (permissive licence) · get_code("46b2d065f3655464")
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 list, 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
import torch.nn as nn

torch.manual_seed(0)

# Create a mock model class
class MockModel(nn.Module):
    def __init__(self, is_attention_model=False):
        super().__init__()
        self.is_attention_model = is_attention_model
        
        if is_attention_model:
            # For attention model: final_state is a tuple of 6 elements
            # Element 0 is an iterable of (c, m) pairs
            # Elements 1-4 are lists
            # Element 5 is a single value
            c1 = torch.randn(2, 4)
            m1 = torch.randn(2, 4)
            c2 = torch.randn(2, 4)
            m2 = torch.randn(2, 4)
            
            self.final_state = (
                [(c1, m1), (c2, m2)],  # Element 0: list of tuples
                [torch.randn(2, 4)],   # Element 1: list
                [torch.randn(2, 4)],   # Element 2: list
                [torch.randn(2, 4)],   # Element 3: list
                [torch.randn(2, 4)],   # Element 4: list
                torch.randn(2, 4)      # Element 5: single tensor
            )
        else:
            # For non-attention model: final_state is an iterable of (c, m) pairs
            c1 = torch.randn(2, 4)
            m1 = torch.randn(2, 4)
            c2 = torch.randn(2, 4)
            m2 = torch.randn(2, 4)
            
            self.final_state = [(c1, m1), (c2, m2)]
    
    def forward(self, x):
        return x

# Test with attention model
model_attention = MockModel(is_attention_model=True)

# Test with non-attention model
model_non_attention = MockModel(is_attention_model=False)

# Create initial evals list
evals_attention = []
evals_non_attention = []

ARGS = {
    "evals": evals_attention,
    "model": model_attention
}
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 list, ndim 3, dtype family float — a list 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
get_initial_state Ran
ran; our contract draft was wrong, not the code
uclnlp/pycodesuggest/lm/Trainer.py
code served (permissive licence) · get_code("9dd711194f468a2d")
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. 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 DummyModel(nn.Module):
    def __init__(self, is_attention_model=False):
        super().__init__()
        self.is_attention_model = is_attention_model
        
        if is_attention_model:
            # For attention model: initial_state is a tuple of 3 elements
            # [0] is list of (c, m) tuples
            # [1] is list of attention states
            # [2] is list of attention ids
            # [4] is list of attention counts
            c1 = nn.Linear(4, 3)
            m1 = nn.Linear(4, 3)
            c2 = nn.Linear(4, 3)
            m2 = nn.Linear(4, 3)
            
            att_states = [nn.Linear(4, 3) for _ in range(2)]
            att_ids = [nn.Linear(4, 3) for _ in range(2)]
            att_counts = [nn.Linear(4, 3) for _ in range(2)]
            
            self.initial_state = (
                [(c1, m1), (c2, m2)],
                att_states,
                att_ids,
                None,  # [3]
                att_counts
            )
        else:
            # For non-attention model: initial_state is a list of (c, m) tuples
            c1 = nn.Linear(4, 3)
            m1 = nn.Linear(4, 3)
            c2 = nn.Linear(4, 3)
            m2 = nn.Linear(4, 3)
            
            self.initial_state = [(c1, m1), (c2, m2)]

# Test with non-attention model
model_non_att = DummyModel(is_attention_model=False)

# Test with attention model
model_att = DummyModel(is_attention_model=True)

ARGS = {
    "model": model_att
}
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 — 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: none by the harness; any seed is in the setup block
get_position Ran
ran on a synthesized input
uclmr/pycodesuggest/github-scraper/astwalker.py
code served (permissive licence) · get_code("a6b4c3bfba079b22")
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 1, dtype family int; 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 ast

# Create a mock AST node with lineno and col_offset attributes
class MockNode:
    def __init__(self, lineno, col_offset):
        self.lineno = lineno
        self.col_offset = col_offset

# Create a node instance
node = MockNode(lineno=42, col_offset=10)

ARGS = {
    "node": node,
    "offset": 0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family int — 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
get_source_tree Ran
ran on a synthesized input
uclmr/pycodesuggest/github-scraper/normalisation.py
code served (permissive licence) · get_code("316f1ff96e8a3964")
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 1, 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 tempfile
import os

# Create a temporary file with some Python code to parse
temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False)
temp_file.write("def hello():\n    return 42\n")
temp_file.close()

ARGS = {
    'filename': temp_file.name
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, 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
replace_source Ran
ran on a synthesized input
uclmr/pycodesuggest/github-scraper/normalisation.py
code served (permissive licence) · get_code("074cae12ca9e9f50")
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 re

# Analyze the function:
# - source: a string containing source code
# - name_dict: a nested dictionary with structure:
#   {scope: {typename: {name: replacement_value}}}
#   where scope is any key, typename is one of 'Class', 'function', 'attribute', 'arg', 'var'
#   and name/replacement_value are strings or None

# The function iterates through scopes and typenames, using regex substitution
# to replace variable names in the source code

source = """
def my_function(arg1, arg2):
    class MyClass:
        attribute = 10
    var1 = MyClass()
    return arg1 + arg2
"""

name_dict = {
    "scope1": {
        "Class": {
            "MyClass": "RenamedClass",
            "OtherClass": None
        },
        "function": {
            "my_function": "new_function",
            None: "ignored"
        },
        "attribute": {
            "attribute": "new_attribute"
        },
        "arg": {
            "arg1": "param1",
            "arg2": "param2"
        },
        "var": {
            "var1": "variable1",
            "var2": None
        }
    },
    "scope2": {
        "function": {
            "helper": "helper_renamed"
        }
    }
}

ARGS = {
    "source": source,
    "name_dict": name_dict
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
check_duplicates Not yet run
unverified (harvested, no recorded run)
uclmr/pycodesuggest/github-scraper/processFiles.py
code served (permissive licence) · get_code("15b1ab9da68f5ce2")
How it ran

no invocation recorded.

read_data Not yet run
unverified (harvested, no recorded run)
uclmr/pycodesuggest/github-scraper/processFiles.py
code served (permissive licence) · get_code("3e636a771fe0e881")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 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 9 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

To enhance developer productivity, all modern integrated development environments (IDEs) include code suggestion functionality that proposes likely next tokens at the cursor. While current IDEs work well for statically-typed languages, their reliance on type annotations means that they do not provide the same level of support for dynamic programming languages as for statically-typed languages. Moreover, suggestion engines in modern IDEs do not propose expressions or multi-statement idiomatic code. Recent work has shown that language models can improve code suggestion systems by learning from software repositories. This paper introduces a neural language model with a sparse pointer network aimed at capturing very long-range dependencies. We release a large-scale code suggestion corpus of 41M lines of Python code crawled from GitHub. On this corpus, we found standard neural language models to perform well at suggesting local phenomena, but struggle to refer to identifiers that are introduced many tokens in the past. By augmenting a neural language model with a pointer network specialized in referring to predefined classes of identifiers, we obtain a much lower perplexity and a 5 percentage points increase in accuracy for code suggestion compared to an LSTM baseline. In fact, this increase in code suggestion accuracy is due to a 13 times more accurate prediction of identifiers. Furthermore, a qualitative analysis shows this model indeed captures interesting long-range dependencies, like referring to a class member defined over 60 tokens in the past.

For agents

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

get_harvested_code_for_paper("1611.08307")
get_code_for_paper("1611.08307")
have("1611.08307")

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

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

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

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

Connect an agent — have() is free.