SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1807.02322 · 2018

Memory Augmented Policy Optimization for Program Synthesis and Semantic Parsing

arXiv · PDF · Open in the Atlas

Code that ran

7 of 15 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 7 have no contract verdict; 0 failures of our instrument; 8 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/1807.02322.json · badge: /api/ran/1807.02322.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
crazydonkey200/neural-symbolic-machines canonical (classifier label)
classifier basis: census
7 ran · 6 no recorded run
theSparta/neural-symbolic-machines community (classifier label)
classifier basis not recorded on the link
0 ran · 2 no recorded run
FunctionStatusWhere it lives
attn_sum_bahdanau Ran
ran on a synthesized input
crazydonkey200/neural-symbolic-machines/nsm/tf_utils.py
code served (permissive licence) · get_code("c3104e5e2d8a40e4")
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, 3) 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
import numpy as np

# Create small tensors for the Bahdanau attention mechanism
batch_size = 2
time_steps = 3
key_dim = 4

# v_attn: attention variable with shape (key_dim,)
v_attn = tf.constant(np.random.randn(key_dim).astype(np.float32))

# keys: shape (batch_size, time_steps, key_dim)
keys = tf.constant(np.random.randn(batch_size, time_steps, key_dim).astype(np.float32))

# query: shape (batch_size, key_dim)
query = tf.constant(np.random.randn(batch_size, key_dim).astype(np.float32))

ARGS = {
    "v_attn": v_attn,
    "keys": keys,
    "query": query,
}
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, 3) — shape (2, 3) 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
attn_sum_dot Ran
ran on a synthesized input
crazydonkey200/neural-symbolic-machines/nsm/tf_utils.py
code served (permissive licence) · get_code("f1f2fe840e5c928e")
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, 3) 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
import numpy as np

# Set seed for reproducibility
np.random.seed(0)
tf.random.set_seed(0)

# Create small tensors for the function
# keys shape: (batch_size, time_steps, key_dim)
keys = tf.constant(np.random.randn(2, 3, 4).astype(np.float32))

# query shape: (batch_size, query_dim)
# Note: query_dim should match key_dim for the dot product to work
query = tf.constant(np.random.randn(2, 4).astype(np.float32))

ARGS = {
    "keys": keys,
    "query": query,
}
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, 3) — shape (2, 3) 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
bleu_score Ran
ran on a synthesized input
crazydonkey200/neural-symbolic-machines/nsm/nlp_utils.py
code served (permissive licence) · get_code("9073ba6a227f3a75")
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 float, ndim 0, dtype family float, 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 nltk
import torch

torch.manual_seed(0)

# The function expects:
# - sentence: a list of tokens (words)
# - gold_sentence: a list of tokens (words)

# These are passed to nltk.translate.bleu_score.sentence_bleu
# which expects references (a list of reference sentences) and a hypothesis sentence

sentence = ['the', 'cat', 'sat', 'on', 'the', 'mat']
gold_sentence = ['the', 'cat', 'is', 'sitting', 'on', 'the', 'mat']

ARGS = {
    'sentence': sentence,
    'gold_sentence': gold_sentence
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, ndim 0, dtype family float, 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
create_lm_inputs_labels Ran
ran on a synthesized input
crazydonkey200/neural-symbolic-machines/nsm/data_utils.py
code served (permissive licence) · get_code("ba6719f38bfb57e9")
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 numpy as np

class MockVocab:
    def __init__(self):
        self.decode_id = 10
        self.end_id = 11
        self._word_to_id = {
            'hello': 1,
            'world': 2,
            'foo': 3,
            'bar': 4,
            'baz': 5
        }
    
    def lookup(self, seq):
        """Convert sequence of words to list of ids."""
        return [self._word_to_id.get(word, 0) for word in seq]

vocab = MockVocab()
dataset = [
    ['hello', 'world'],
    ['foo', 'bar', 'baz']
]

ARGS = {
    'dataset': dataset,
    'vocab': vocab
}
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 — 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
create_seq2seq_inputs Ran
ran on a synthesized input
crazydonkey200/neural-symbolic-machines/nsm/data_utils.py
code served (permissive licence) · get_code("451d8aadbc0755dd")
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 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)

class Vocab:
    def __init__(self, start_id=1, decode_id=2, end_id=3):
        self.start_id = start_id
        self.decode_id = decode_id
        self.end_id = end_id
        self.word_to_id = {"hello": 10, "world": 11, "foo": 12, "bar": 13}
    
    def lookup(self, seq):
        """Convert sequence of words to list of ids"""
        return [self.word_to_id.get(word, 0) for word in seq]

en_vocab = Vocab(start_id=1, decode_id=2, end_id=3)
de_vocab = Vocab(start_id=1, decode_id=2, end_id=3)

en_dataset = [
    ["hello", "world"],
    ["foo", "bar"]
]

de_dataset = [
    ["hello", "world"],
    ["foo", "bar"]
]

ARGS = {
    "en_dataset": en_dataset,
    "en_vocab": en_vocab,
    "de_dataset": de_dataset,
    "de_vocab": de_vocab
}
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 3, 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
tensormul Ran
ran on a synthesized input
crazydonkey200/neural-symbolic-machines/nsm/tf_utils.py
code served (permissive licence) · get_code("cc1113db8b905bd0")
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 3, dtype family float, shape (2, 3, 5) 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

# Create two tensors for matrix multiplication
# t1 shape: (2, 3, 4) - batch of 2, 3 rows, 4 columns
# t2 shape: (4, 5) - 4 rows, 5 columns
# Result will be (2, 3, 5) after tensormul

t1 = tf.constant([
    [[1.0, 2.0, 3.0, 4.0],
     [5.0, 6.0, 7.0, 8.0],
     [9.0, 10.0, 11.0, 12.0]],
    [[13.0, 14.0, 15.0, 16.0],
     [17.0, 18.0, 19.0, 20.0],
     [21.0, 22.0, 23.0, 24.0]]
], dtype=tf.float32)

t2 = tf.constant([
    [1.0, 2.0, 3.0, 4.0, 5.0],
    [6.0, 7.0, 8.0, 9.0, 10.0],
    [11.0, 12.0, 13.0, 14.0, 15.0],
    [16.0, 17.0, 18.0, 19.0, 20.0]
], dtype=tf.float32)

ARGS = {
    "t1": t1,
    "t2": t2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 3, dtype family float, shape (2, 3, 5) — shape (2, 3, 5) 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
with_graph_variable_scope Ran
ran on a synthesized input
crazydonkey200/neural-symbolic-machines/nsm/graph_factory.py
code served (permissive licence) · get_code("d34fbdeb6f1be262")
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 function. 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 os
import tensorflow as tf

class MockSelf:
    def __init__(self):
        self._graph = tf.Graph()
        self.vs = "test_scope"

def mock_func(self):
    return "result"

def with_graph_variable_scope(func):
    def func_wrapper(*args, **kwargs):
        self = args[0]
        with self._graph.as_default():
            pid = os.getpid()
            container_name = 'worker{}'.format(pid)
            with self._graph.container(container_name):
                with tf.variable_scope(self.vs):
                    return func(*args, **kwargs)
    return func_wrapper

mock_self = MockSelf()
decorated_func = with_graph_variable_scope(mock_func)

ARGS = {
    "func": mock_func
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
create_features Not yet run
unverified (harvested, no recorded run)
theSparta/neural-symbolic-machines/nsm/env_factory.py
code served (permissive licence) · get_code("88efa45be6ac471a")
How it ran

no invocation recorded.

create_multilayer_fnn Not yet run
unverified (harvested, no recorded run)
crazydonkey200/neural-symbolic-machines/nsm/graph_factory.py
code served (permissive licence) · get_code("42891135110a96ff")
How it ran

no invocation recorded.

create_seq_mse_loss Not yet run
unverified (harvested, no recorded run)
crazydonkey200/neural-symbolic-machines/nsm/graph_factory.py
code served (permissive licence) · get_code("ee764e83c41c8784")
How it ran

no invocation recorded.

edit_distance Not yet run
unverified (harvested, no recorded run)
crazydonkey200/neural-symbolic-machines/nsm/nlp_utils.py
code served (permissive licence) · get_code("54fb9ba175e6c08b")
How it ran

no invocation recorded.

show_samples Not yet run
unverified (harvested, no recorded run)
crazydonkey200/neural-symbolic-machines/table/experiment.py
code served (permissive licence) · get_code("fce4ea795a572f61")
How it ran

no invocation recorded.

tokenize Not yet run
unverified (harvested, no recorded run)
crazydonkey200/neural-symbolic-machines/nsm/nlp_utils.py
code served (permissive licence) · get_code("4fb20ccedc18c760")
How it ran

no invocation recorded.

unpack_program Not yet run
unverified (harvested, no recorded run)
crazydonkey200/neural-symbolic-machines/table/experiment.py
code served (permissive licence) · get_code("5677f59fb39ed6c9")
How it ran

no invocation recorded.

value_to_index Not yet run
unverified (harvested, no recorded run)
theSparta/neural-symbolic-machines/nsm/env_factory.py
code served (permissive licence) · get_code("9817d521556a77fa")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 11 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 11 later) and 4 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
attn_sum_bahdanau 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
attn_sum_dot 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
bleu_score 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
create_lm_inputs_labels 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
create_multilayer_fnn 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
create_seq2seq_inputs 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
create_seq_mse_loss 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
edit_distance 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
tensormul 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
tokenize 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing
with_graph_variable_scope 1 other paper
1 later
1911.12986 (2019-11)
Merging Weak and Active Supervision for Semantic Parsing

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

We present Memory Augmented Policy Optimization (MAPO), a simple and novel way to leverage a memory buffer of promising trajectories to reduce the variance of policy gradient estimate. MAPO is applicable to deterministic environments with discrete actions, such as structured prediction and combinatorial optimization tasks. We express the expected return objective as a weighted sum of two terms: an expectation over the high-reward trajectories inside the memory buffer, and a separate expectation over trajectories outside the buffer. To make an efficient algorithm of MAPO, we propose: (1) memory weight clipping to accelerate and stabilize training; (2) systematic exploration to discover high-reward trajectories; (3) distributed sampling from inside and outside of the memory buffer to scale up training. MAPO improves the sample efficiency and robustness of policy gradient, especially on tasks with sparse rewards. We evaluate MAPO on weakly supervised program synthesis from natural language (semantic parsing). On the WikiTableQuestions benchmark, we improve the state-of-the-art by 2.6%, achieving an accuracy of 46.3%. On the WikiSQL benchmark, MAPO achieves an accuracy of 74.9% with only weak supervision, outperforming several strong baselines with full supervision. Our source code is available at https://github.com/crazydonkey200/neural-symbolic-machines

For agents

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

get_harvested_code_for_paper("1807.02322")
get_code_for_paper("1807.02322")
have("1807.02322")

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

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

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

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

Connect an agent — have() is free.