SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1810.09536 · 2018

Ordered Neurons: Integrating Tree Structures into Recurrent Neural Networks

arXiv · PDF · Open in the Atlas

Code that ran

11 of 12 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 6 have no contract verdict; 4 failures of our instrument; 1 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/1810.09536.json · badge: /api/ran/1810.09536.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
yikangshen/Ordered-Neurons canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
IanTheColder/ONLSTM-analysis community (classifier label)
classifier basis not recorded on the link
8 ran · 1 no recorded run
zi-lin/on-lstm-tensorflow community (classifier label)
classifier basis not recorded on the link
1 ran · 0 no recorded run
FunctionStatusWhere it lives
balance Ran
ran on a synthesized input
IanTheColder/ONLSTM-analysis/parse_comparison.py
code served (permissive licence) · get_code("bef0350ba4dc9a48")
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 math

def spaceify(parse):
    return parse

def roundup2(N):
    """ Round up using factors of 2. """
    return int(2 ** math.ceil(math.log(N, 2)))

def full_transitions(N, left_full=False, right_full=False):
    """
    Recursively creates a full binary tree of with N
    leaves using shift reduce transitions.
    """
    if N == 1:
        return [0]
    if N == 2:
        return [0, 0, 1]
    assert not (left_full and right_full), 'Please only choose one.'
    if not left_full and (not right_full):
        N = float(N)
        assert math.log(N, 2) % 1 == 0, 'Bad value. N={}'.format(N)
        left_N = N / 2
        right_N = N - left_N
    if left_full:
        left_N = roundup2(N) / 2
        right_N = N - left_N
    if right_full:
        right_N = roundup2(N) / 2
        left_N = N - right_N
    return full_transitions(left_N, left_full=left_full, right_full=right_full) + full_transitions(right_N, left_full=left_full, right_full=right_full) + [1]

def tokenize_parse(parse):
    parse = spaceify(parse)
    return [token for token in parse.split() if token not in ['(', ')']]

def balance(parse, lowercase=False):
    tokens = tokenize_parse(parse)
    if len(tokens) > 1:
        transitions = full_transitions(len(tokens), right_full=True)
        stack = []
        for transition in transitions:
            if transition == 0:
                stack.append(tokens.pop(0))
            elif transition == 1:
                right = stack.pop()
                left = stack.pop()
                stack.append('( ' + left + ' ' + right + ' )')
        assert len(stack) == 1
    else:
        stack = tokens
    return stack[0]

# Test with a simple parse string containing 4 tokens (power of 2)
ARGS = {
    "parse": "the quick brown fox",
    "lowercase": False
}
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
batchify Ran
ran; our contract draft was wrong, not the code
IanTheColder/ONLSTM-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
build_tree Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
yikangshen/Ordered-Neurons/test_phrase_grammar.py
code served (permissive licence) · get_code("2cdc4ed134986036")
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. 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 numpy

# Analyze the function:
# - depth: a sequence that numpy.argmax is called on, needs to be array-like with numeric values
# - sen: a sequence that is sliced and indexed, needs to support len(), slicing, and indexing
# Both must have the same length

# Create simple test data
depth = numpy.array([1, 3, 2, 1])  # numeric array for argmax
sen = ['a', 'b', 'c', 'd']  # list of strings to build parse tree

ARGS = {
    'depth': depth,
    'sen': sen
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list 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
cumsoftmax Ran
ran; our contract draft was wrong, not the code
yikangshen/Ordered-Neurons/ON_LSTM.py
code served (permissive licence) · get_code("4b59eaae917b5a2d")
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 (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
import torch.nn.functional as F

torch.manual_seed(0)

# The function cumsoftmax takes a tensor x and an optional dim parameter
# It applies softmax along dim, then cumsum along dim
# We need to provide a simple tensor as input

x = torch.randn(2, 4)  # Small tensor: batch size 2, feature dim 4

ARGS = {
    'x': x,
    'dim': -1
}
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 (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
cumsoftmax Ran
ran on a synthesized input
zi-lin/on-lstm-tensorflow/on_lstm_layer.py
code served (permissive licence) · get_code("71364ee53326b360")
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 EagerTensor, ndim 2, dtype family float, 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 tensorflow as tf
from tensorflow.python.keras import activations
import numpy as np

# Create a small tensor input for the cumsoftmax function
x = tf.constant([
    [1.0, 2.0, 3.0, 4.0],
    [0.5, 1.5, 2.5, 3.5]
], dtype=tf.float32)

ARGS = {
    "x": x,
    "axis": -1
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family float, 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
get_batch Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
IanTheColder/ONLSTM-analysis/utils.py
code served (permissive licence) · get_code("6f3c8e0b36d76af7")
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
import numpy as np

torch.manual_seed(0)

# Create a simple source tensor
# The function indexes into source with [i:i+seq_len] and [i+1:i+1+seq_len]
# So we need enough elements. Let's make it 1D with 20 elements
source = torch.arange(20, dtype=torch.long)

# Create a simple args object with bptt attribute
class Args:
    def __init__(self):
        self.bptt = 5

args = Args()

# i is an index into source
i = 0

# seq_len can be None or an int
seq_len = None

# evaluation is a boolean flag
evaluation = False

ARGS = {
    "source": source,
    "i": i,
    "args": args,
    "seq_len": seq_len,
    "evaluation": evaluation
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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, 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
parenthesize Ran
ran on a synthesized input
IanTheColder/ONLSTM-analysis/parse_by_baseline.py
code served (permissive licence) · get_code("7e3df128e06d7869")
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

# Construct valid arguments for parenthesize function
# The function takes a parameter 'l' which can be either:
# 1. A string - in which case it returns '(<word> ' + l + ')'
# 2. A list/tuple with two elements - recursively parenthesizes both elements

# Test case 1: simple string
l_string = "hello"

# Test case 2: nested structure with strings
l_nested = ["world", ["nested", "test"]]

# The function will be called with the string case
ARGS = {
    "l": l_string
}
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
randomize_split Ran
ran on a synthesized input
IanTheColder/ONLSTM-analysis/parse_by_baseline.py
code served (permissive licence) · get_code("31b75ccedc2bc209")
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. 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 random

def randomize_split(sentence):
    if len(sentence) == 2:
        return sentence
    elif len(sentence) == 1:
        return sentence[0]
    else:
        split = random.choice(list(range(len(sentence) - 1))) + 1
        return [randomize_split(sentence[:split]), randomize_split(sentence[split:])]

# The function expects a 'sentence' parameter that:
# - supports len() operation
# - supports slicing with [:split] and [split:]
# - can be recursively processed
# A list of strings or tokens works well

ARGS = {
    "sentence": ["hello", "world", "this", "is", "a", "test"]
}
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 — a list 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
repackage_hidden Ran
ran, honoured the contract we drafted
IanTheColder/ONLSTM-analysis/utils.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from mingruiliu-ml-lab/communication-efficient-local-gradient-clipping, is pointer only (licence: GPL-3.0) · get_code("4372bb4533fd1936")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from mingruiliu-ml-lab/communication-efficient-local-gradient-clipping, and GPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

roundup2 Ran
ran on a synthesized input
IanTheColder/ONLSTM-analysis/parse_comparison.py
code served (permissive licence) · get_code("219eb921a74ea62c")
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 int, ndim 0, dtype family int, 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 math

def roundup2(N):
    """ Round up using factors of 2. """
    return int(2 ** math.ceil(math.log(N, 2)))

ARGS = {
    "N": 5
}
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 int, ndim 0, dtype family int, 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
spaceify Ran
ran on a synthesized input
IanTheColder/ONLSTM-analysis/parse_comparison.py
code served (permissive licence) · get_code("ed1c4f48a3e8e92e")
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 'spaceify' takes a 'parse' parameter and returns it unchanged.
# Since the function body just returns the input, 'parse' can be any object.
# We'll use a simple string as a stand-in.

parse = "example_parse_input"

ARGS = {
    "parse": parse
}
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
embedded_dropout Not yet run
unverified (harvested, no recorded run)
IanTheColder/ONLSTM-analysis/embed_regularize.py
pointer only (licence: BSD-3-Clause); the stored copy get_code serves, from yx3266/SEN, is pointer only (licence: NONE) · get_code("62d148258bdd054f")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (BSD-3-Clause), but get_code serves the stored copy, first harvested from yx3266/SEN, 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. No invocation recorded.

Also present in other papers' code

Of 12 samples lifted from this paper's linked repositories, 12 carry a function identity and 0 do not. Of the 12 distinct functions with an identity, 5 are also present in other papers whose code we hold (4 with at least one paper dated earlier, 1 the same month, 5 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
repackage_hidden 15 other papers
4 dated earlier, 1 the same month, 10 later
1609.04309 (2016-09)
Efficient softmax approximation for GPUs
1704.05119 (2017-04)
Exploring Sparsity in Recurrent Neural Networks
1803.08240 (2018-03)
An Analysis of Neural Language Modeling at Multiple Scales
and 12 more not named here
batchify 7 other papers
3 dated earlier, 4 later
1803.08240 (2018-03)
An Analysis of Neural Language Modeling at Multiple Scales
1805.04623 (2018-05)
Sharp Nearby, Fuzzy Far Away: How Neural Language Models Use Context
1808.09029 (2018-08)
Pyramidal Recurrent Unit for Language Modeling
and 4 more not named here
embedded_dropout 6 other papers
1 dated earlier, 5 later
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
2006.07116 (2020-06)
NAS-Bench-NLP: Neural Architecture Search Benchmark for Natural Language Processing
and 3 more not named here
get_batch 4 other papers
1 dated earlier, 3 later
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
2010.02519 (2020-10)
Improved Analysis of Clipping Algorithms for Non-convex Optimization
and 1 more not named here
cumsoftmax 2 other papers
2 later
2106.01093 (2021-06)
LGESQL: Line Graph Enhanced Text-to-SQL Model with Mixed Local and Non-Local Relations
2203.10256 (2022-03)
Dependency-based Mixture Language Models

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

Natural language is hierarchically structured: smaller units (e.g., phrases) are nested within larger units (e.g., clauses). When a larger constituent ends, all of the smaller constituents that are nested within it must also be closed. While the standard LSTM architecture allows different neurons to track information at different time scales, it does not have an explicit bias towards modeling a hierarchy of constituents. This paper proposes to add such an inductive bias by ordering the neurons; a vector of master input and forget gates ensures that when a given neuron is updated, all the neurons that follow it in the ordering are also updated. Our novel recurrent architecture, ordered neurons LSTM (ON-LSTM), achieves good performance on four different tasks: language modeling, unsupervised parsing, targeted syntactic evaluation, and logical inference.

For agents

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

get_harvested_code_for_paper("1810.09536")
get_code_for_paper("1810.09536")
have("1810.09536")

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

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

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

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

Connect an agent — have() is free.