SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2004.13781 · EMNLP Findings · 2020

Graph-to-Tree Neural Networks for Learning Structured Input-Output Translation with Applications to Semantic Parsing and Math Word Problem

Lingfei Wu, Shiwei Feng, Shucheng Li, Fengyuan Xu, Fangli Xu, Sheng Zhong

arXiv · PDF · Open in the Atlas

Code that ran

4 of 4 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 4 have no contract verdict; 0 failures of our instrument; 0 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/2004.13781.json · badge: /api/ran/2004.13781.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
IBM/Graph2Tree canonical (classifier label)
classifier basis: census
4 ran · 0 no recorded run
FunctionStatusWhere it lives
combine_fn Ran
ran on a synthesized input
IBM/Graph2Tree/src/nn_modules.py
code served (permissive licence) · get_code("963fc267238fcec4")
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, 12) 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)

# combine_fn takes x (a sequence of tensors) and dim (int)
# It calls torch.cat(x, dim) which concatenates tensors along the specified dimension

# Create a list of small tensors to concatenate
x = [
    torch.randn(2, 4),
    torch.randn(2, 3),
    torch.randn(2, 5)
]

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, 12) — shape (2, 12) 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
cons_batch_graph Ran
ran on a synthesized input
IBM/Graph2Tree/src/graph_utils.py
code served (permissive licence) · get_code("4341bd2e76ed19d1")
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 dict. 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

torch.manual_seed(0)

# Construct minimal graph structures that match what cons_batch_graph expects
# Each graph needs: 'g_ids', 'g_adj', 'g_ids_features'

graph1 = {
    'g_ids': ['0', '1', '2'],
    'g_adj': {
        '0': ['1'],
        '1': ['2'],
        '2': []
    },
    'g_ids_features': {
        '0': torch.randn(4),
        '1': torch.randn(4),
        '2': torch.randn(4)
    }
}

graph2 = {
    'g_ids': ['0', '1'],
    'g_adj': {
        '0': ['1'],
        '1': []
    },
    'g_ids_features': {
        '0': torch.randn(4),
        '1': torch.randn(4)
    }
}

graphs = [graph1, graph2]

ARGS = {
    'graphs': graphs
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
read_graph_data Ran
ran on a synthesized input
IBM/Graph2Tree/src/graph_utils.py
code served (permissive licence) · get_code("b70328a0fa542ebf")
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 json
from collections import OrderedDict
import tempfile
import os

# Create a temporary input file with valid graph data
temp_dir = tempfile.mkdtemp()
input_file = os.path.join(temp_dir, "graph_data.jsonl")

# Write sample graph data to the file
sample_graphs = [
    {
        "g_ids": [1, 2, 3],
        "g_ids_features": [[0.1, 0.2], [0.3, 0.4], [0.5, 0.6]],
        "g_adj": [[0, 1, 0], [1, 0, 1], [0, 1, 0]]
    },
    {
        "g_ids": [4, 5],
        "g_ids_features": [[0.7, 0.8], [0.9, 1.0]],
        "g_adj": [[0, 1], [1, 0]]
    }
]

with open(input_file, 'w') as f:
    for graph in sample_graphs:
        f.write(json.dumps(graph) + '\n')

ARGS = {
    "input_file": input_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
vectorize_batch_graph Ran
ran on a synthesized input
IBM/Graph2Tree/src/graph_utils.py
code served (permissive licence) · get_code("dd3636932a9b7354")
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 dict. 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 as np

class WordManager:
    def __init__(self):
        self.symbol_map = {
            'word1': 1,
            'word2': 2,
            'word3': 3,
            'word4': 4,
        }
    
    def get_symbol_idx(self, token):
        return self.symbol_map.get(token, 0)

word_manager = WordManager()

graph = {
    'g_ids_features': {
        0: 'word1 word2',
        1: 'word3',
        2: 'word4 word1 word2',
    },
    'g_ids': [0, 1, 2],
    'g_nodes': np.array([10, 20, 30]),
    'g_fw_adj': {
        0: [1, 2],
        1: [2],
        2: [0],
    },
    'g_bw_adj': {
        0: [2],
        1: [0],
        2: [0, 1],
    },
}

ARGS = {
    'graph': graph,
    'word_manager': word_manager,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 0 later) and 3 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
cons_batch_graph 3 other papers
3 dated earlier
1804.00823 (2018-04)
Graph2Seq: Graph to Sequence Learning with Attention-based Neural Networks
1808.07624 (2018-08)
Exploiting Rich Syntactic Information for Semantic Parsing with Graph-to-Sequence Model
1809.05255 (2018-09)
SQL-to-Text Generation with Graph-to-Sequence Model

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

The celebrated Seq2Seq technique and its numerous variants achieve excellent performance on many tasks such as neural machine translation, semantic parsing, and math word problem solving. However, these models either only consider input objects as sequences while ignoring the important structural information for encoding, or they simply treat output objects as sequence outputs instead of structural objects for decoding. In this paper, we present a novel Graph-to-Tree Neural Networks, namely Graph2Tree consisting of a graph encoder and a hierarchical tree decoder, that encodes an augmented graph-structured input and decodes a tree-structured output. In particular, we investigated our model for solving two problems, neural semantic parsing and math word problem. Our extensive experiments demonstrate that our Graph2Tree model outperforms or matches the performance of other state-of-the-art models on these tasks.

For agents

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

get_harvested_code_for_paper("2004.13781")
get_code_for_paper("2004.13781")
have("2004.13781")

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

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

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

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

Connect an agent — have() is free.