SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1805.04623 · 2018

Sharp Nearby, Fuzzy Far Away: How Neural Language Models Use Context

arXiv · PDF · Open in the Atlas

Code that ran

5 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; 1 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 1 failure of our instrument; 6 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/1805.04623.json · badge: /api/ran/1805.04623.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
urvashik/lm-context-analysis canonical (classifier label)
classifier basis: census
5 ran · 6 no recorded run
FunctionStatusWhere it lives
batchify Ran
ran; our contract draft was wrong, not the code
urvashik/lm-context-analysis/utils.py
code served (permissive licence) · get_code("6bd10c3dd56c2b8c")
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 2, dtype family float, shape (16, 2) as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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 tensor for data
# The function calls data.size(0), data.narrow(), data.view(), and data.t()
# So we need a 2D tensor
data = torch.randn(8, 4)  # 8 rows, 4 columns

# Batch size
bsz = 2

# Args object with cuda attribute
class Args:
    def __init__(self, cuda=False):
        self.cuda = cuda

args = Args(cuda=False)

ARGS = {
    "data": data,
    "bsz": bsz,
    "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 Tensor, ndim 2, dtype family float, shape (16, 2) — shape (16, 2) 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
batchify_context Ran
ran on a synthesized input
urvashik/lm-context-analysis/utils_context.py
code served (permissive licence) · get_code("ebc7e86b33b13d8c")
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 2, dtype family float, shape (8, 4) as a later run recorded it. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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

torch.manual_seed(0)

# Create a small tensor for the data parameter
# The function calls data.size(0), data.narrow(), and optionally data.cuda()
# So we need a tensor with at least batch_size elements in dimension 0
data = torch.randn(8, 4)  # 8 tokens, 4 features

# Create an args object with the required attributes
class Args:
    def __init__(self):
        self.batch_size = 2
        self.cuda = False

args = Args()

ARGS = {
    'data': data,
    '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 Tensor, ndim 2, dtype family float, shape (8, 4) — shape (8, 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
get_batch Ran
ran on a synthesized input
urvashik/lm-context-analysis/utils.py
code served (permissive licence) · get_code("be3874d8cf97dae0")
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 2, 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 torch
from torch.autograd import Variable

torch.manual_seed(0)

# Create a small source tensor (sequence of tokens/embeddings)
# Shape: (sequence_length, batch_size) or (sequence_length,) depending on use
# We'll make it (10,) - a 1D tensor of 10 elements for simplicity
source = torch.randint(0, 100, (10,))

# Create args object with required attributes
class Args:
    def __init__(self):
        self.bptt = 5  # backprop through time - sequence length

args = Args()

# Define ARGS dict with all parameters
ARGS = {
    'source': source,
    'i': 0,
    'args': args,
    'seq_len': None,
    'evaluation': False
}
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 2, 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_context_batch Ran
ran on a synthesized input
urvashik/lm-context-analysis/utils_context.py
code served (permissive licence) · get_code("7ff48303eab5927b")
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 4, 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
from torch.autograd import Variable

torch.manual_seed(0)

# Create a simple source tensor - a sequence of token embeddings
# We need enough tokens to construct multiple batches with context
# batch_size=2, seq_len=5, so we need at least batch_size * seq_len + seq_len tokens
source = torch.randn(20, 4)  # 20 tokens, each with embedding dim 4

# Create args object with required attributes
class Args:
    def __init__(self):
        self.batch_size = 2
        self.seq_len = 5

args = Args()

# i is the batch index
i = 0

ARGS = {
    'source': source,
    'i': i,
    '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 tuple, ndim 4, 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
one_hot Ran
ran, honoured the contract we drafted
urvashik/lm-context-analysis/pointer.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from Asteur/RERITES-AvgWeightDescentLSTM-PoetryGeneration, is pointer only (licence: NONE) · get_code("d38f82da04a3f93e")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from Asteur/RERITES-AvgWeightDescentLSTM-PoetryGeneration, and GitHub detected no licence in that repository 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.

drop_pos Not yet run
unverified (harvested, no recorded run)
urvashik/lm-context-analysis/perturbations.py
code served (permissive licence) · get_code("e376a38c76548861")
How it ran

no invocation recorded.

embedded_dropout Not yet run
unverified (harvested, no recorded run)
urvashik/lm-context-analysis/embed_regularize.py
code served (permissive licence) · get_code("3c2fe307e011be7d")
How it ran

no invocation recorded.

get_vocab_all_pos Not yet run
unverified (harvested, no recorded run)
urvashik/lm-context-analysis/utils_context.py
code served (permissive licence) · get_code("24a81b705de4283b")
How it ran

no invocation recorded.

keep_pos Not yet run
unverified (harvested, no recorded run)
urvashik/lm-context-analysis/perturbations.py
code served (permissive licence) · get_code("f4b8e8869b6d4203")
How it ran

no invocation recorded.

random_drop_many Not yet run
unverified (harvested, no recorded run)
urvashik/lm-context-analysis/perturbations.py
code served (permissive licence) · get_code("336b12c05af1b60e")
How it ran

no invocation recorded.

repackage_hidden Not yet run
unverified (harvested, no recorded run)
urvashik/lm-context-analysis/utils.py
code served (permissive licence) · get_code("d98e69125467f2f0")
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, 5 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 1 the same month, 4 later) and 6 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
batchify 7 other papers
1 dated earlier, 6 later
1803.08240 (2018-03)
An Analysis of Neural Language Modeling at Multiple Scales
1808.09029 (2018-08)
Pyramidal Recurrent Unit for Language Modeling
1810.09536 (2018-10)
Ordered Neurons: Integrating Tree Structures into Recurrent Neural Networks
and 4 more not named here
repackage_hidden 6 other papers
2 dated earlier, 4 later
1709.07432 (2017-09)
Dynamic Evaluation of Neural Sequence Models
1710.02224 (2017-10)
Dilated Recurrent Neural Networks
1808.09029 (2018-08)
Pyramidal Recurrent Unit for Language Modeling
and 3 more not named here
one_hot 4 other papers
2 dated earlier, 2 later
1708.02182 (2017-08)
Regularizing and Optimizing LSTM Language Models
1803.08240 (2018-03)
An Analysis of Neural Language Modeling at Multiple Scales
1905.11881 (2019-05)
Why gradient clipping accelerates training: A theoretical justification for adaptivity
and 1 more not named here
embedded_dropout 1 other paper
1 the same month
1805.04836 (2018-05)
Building Language Models for Text with Named Entities
get_batch 1 other paper
1 later
1808.09029 (2018-08)
Pyramidal Recurrent Unit for Language Modeling

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

We know very little about how neural language models (LM) use prior linguistic context. In this paper, we investigate the role of context in an LSTM LM, through ablation studies. Specifically, we analyze the increase in perplexity when prior context words are shuffled, replaced, or dropped. On two standard datasets, Penn Treebank and WikiText-2, we find that the model is capable of using about 200 tokens of context on average, but sharply distinguishes nearby context (recent 50 tokens) from the distant history. The model is highly sensitive to the order of words within the most recent sentence, but ignores word order in the long-range context (beyond 50 tokens), suggesting the distant past is modeled only as a rough semantic field or topic. We further find that the neural caching model (Grave et al., 2017b) especially helps the LSTM to copy words from within this distant context. Overall, our analysis not only provides a better understanding of how neural LMs use their context, but also sheds light on recent success from cache-based models.

For agents

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

get_harvested_code_for_paper("1805.04623")
get_code_for_paper("1805.04623")
have("1805.04623")

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

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

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

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

Connect an agent — have() is free.