SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1909.05803 · 2019

Self-Assembling Modular Networks for Interpretable Multi-Hop Reasoning

arXiv · PDF · Open in the Atlas

Code that ran

9 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; 2 honoured the contract we drafted, 1 violated it and 5 have no contract verdict; 1 failure of our instrument; 3 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/1909.05803.json · badge: /api/ran/1909.05803.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
jiangycTarheel/NMN-MultiHopQA canonical (classifier label)
classifier basis: census
9 ran · 3 no recorded run
FunctionStatusWhere it lives
apply_mask Ran
ran on a synthesized input
jiangycTarheel/NMN-MultiHopQA/snmn/nmn.py
code served (permissive licence) · get_code("6662273c573ec3c2")
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 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 tensorflow as tf
import numpy as np

# Create small test tensors
batch_size = 2
height = 4
width = 3

# x: input tensor with shape (batch, height, width, channels)
x = tf.constant(np.random.randn(batch_size, height, width, 5).astype(np.float32))

# mask: binary mask with shape (batch, height, width)
# The function indexes it as mask[:, :, :, ax] which adds a new axis at the end
mask = tf.constant(np.random.randint(0, 2, size=(batch_size, height, width)).astype(np.float32))

ARGS = {
    'x': x,
    'mask': mask
}
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 4, dtype family float — no output shape is stated: observe_signature.py recorded SymbolicTensor ndim 4, which disagrees with the fixture run
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
compute_answer_span Ran
ran, honoured the contract we drafted
jiangycTarheel/NMN-MultiHopQA/basic/evaluator.py
code served (permissive licence) · get_code("1a22c29a8b5a8d23")
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 re

def compute_answer_span(context, answer):
    """
    Author: Yichen Jiang
    Find the first occuring answer in the context, and return its span.
    """
    answer = answer.replace(' – ', ' ').lower()
    context = context.lower()
    a = re.search('({})'.format(answer), context)
    if a is None:
        return (None, None)
    start = a.start()
    end = start + len(answer)
    return (start, end)


ARGS = {
    "context": "The quick brown fox jumps over the lazy dog",
    "answer": "brown fox"
}
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
exact_match_score Ran
ran, violated the contract we drafted
jiangycTarheel/NMN-MultiHopQA/hotpotqa/evaluate-v1.1.py
code served (permissive licence) · get_code("f6c275d6a18330a9")
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) and returned bool, 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 string
import re

def normalize_answer(s):
    """Lower text and remove punctuation, articles and extra whitespace."""

    def remove_articles(text):
        return re.sub('\\b(a|an|the)\\b', ' ', text)

    def white_space_fix(text):
        return ' '.join(text.split())

    def remove_punc(text):
        exclude = set(string.punctuation)
        return ''.join((ch for ch in text if ch not in exclude))

    def lower(text):
        return text.lower()
    return white_space_fix(remove_articles(remove_punc(lower(s))))

def exact_match_score(prediction, ground_truth):
    return normalize_answer(prediction) == normalize_answer(ground_truth)

ARGS = {
    "prediction": "The quick brown fox jumps over the lazy dog.",
    "ground_truth": "the quick brown fox jumps over the lazy dog"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 bool, 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
f1_score Ran
ran, honoured the contract we drafted
jiangycTarheel/NMN-MultiHopQA/hotpotqa/evaluate-v1.1.py
code served (permissive licence) · get_code("2112c433b9c6d343")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) 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.

ARGS = {
    "prediction": "The quick brown fox jumps over the lazy dog.",
    "ground_truth": "A quick brown fox jumped over a lazy dog"
}
Setup block drafted by
a language model, Claude Sonnet 4.5, prompt python_fixture_v1
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 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
get_hotpotqa_data_filter Ran
ran on a synthesized input
jiangycTarheel/NMN-MultiHopQA/basic/read_data.py
code served (permissive licence) · get_code("0a7bd9aa65e64d9f")
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 torch
import numpy as np

class Config:
    def __init__(self, ques_size_th=50, para_size_th=500, num_sents_th=10, sent_size_th=100, 
                 squash=False, single=False, data_filter='valid'):
        self.ques_size_th = ques_size_th
        self.para_size_th = para_size_th
        self.num_sents_th = num_sents_th
        self.sent_size_th = sent_size_th
        self.squash = squash
        self.single = single
        self.data_filter = data_filter

config = Config(
    ques_size_th=50,
    para_size_th=500,
    num_sents_th=10,
    sent_size_th=100,
    squash=False,
    single=False,
    data_filter='valid'
)

shared = {"placeholder": "shared_context"}

data_point = {
    'q': [1, 2, 3, 4, 5],
    'cq': [[1, 2], [3, 4], [5, 6]],
    'y': [((0, 0), (0, 10)), ((1, 5), (1, 20))],
    'x': [[1, 2, 3, 4, 5], [10, 20, 30, 40], [100, 200]],
    'cx': [[[1], [2], [3], [4], [5]], [[10], [20], [30], [40]], [[100], [200]]]
}

ARGS = {
    'config': config
}
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 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
handle_nobreak Ran
ran on a synthesized input
jiangycTarheel/NMN-MultiHopQA/hotpotqa/aug_squad.py
code served (permissive licence) · get_code("ea3c6f5d4a8f6795")
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
import numpy as np

def to_hex(s):
    return ' '.join(map(hex, map(ord, s)))

def handle_nobreak(cand, text):
    if cand == text:
        return cand
    if cand.replace(u'\xa0', ' ') == text:
        return cand
    elif cand == text.replace(u'\xa0', ' '):
        return text
    raise Exception("{} '{}' {} '{}'".format(cand, to_hex(cand), text, to_hex(text)))

# Setup code to construct valid arguments
# The function takes two string parameters: cand and text
# It compares them with and without non-breaking space character (\xa0)

# Case 1: cand == text (first condition is true)
cand_1 = "hello world"
text_1 = "hello world"

# Case 2: cand with \xa0 equals text (second condition is true)
cand_2 = "hello\xa0world"
text_2 = "hello world"

# Case 3: cand equals text with \xa0 (third condition is true)
cand_3 = "hello world"
text_3 = "hello\xa0world"

# We'll use Case 1 as the primary test case
ARGS = {
    "cand": cand_1,
    "text": text_1
}
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 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
load_metadata Ran
ran on a synthesized input
jiangycTarheel/NMN-MultiHopQA/basic/read_data.py
code served (permissive licence) · get_code("51367733c0620cb7")
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 json
import os
import tempfile
from unittest.mock import MagicMock

# Create a temporary directory for the test
temp_dir = tempfile.mkdtemp()

# Create a mock config object with a data_dir attribute
config = MagicMock()
config.data_dir = temp_dir

# Create sample metadata JSON file
metadata_content = {
    "num_classes": 10,
    "input_dim": 784,
    "hidden_dim": 256,
    "learning_rate": 0.001
}

data_type = "train"
metadata_path = os.path.join(temp_dir, f'metadata_{data_type}.json')
with open(metadata_path, 'w') as fh:
    json.dump(metadata_content, fh)

ARGS = {
    "config": config,
    "data_type": data_type
}
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 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
normalize_answer Ran
ran; our contract draft was wrong, not the code
jiangycTarheel/NMN-MultiHopQA/hotpotqa/evaluate-v1.1.py
code served (permissive licence) · get_code("c6a80c065d2e4851")
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) 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 string
import re

def normalize_answer(s):
    """Lower text and remove punctuation, articles and extra whitespace."""

    def remove_articles(text):
        return re.sub('\\b(a|an|the)\\b', ' ', text)

    def white_space_fix(text):
        return ' '.join(text.split())

    def remove_punc(text):
        exclude = set(string.punctuation)
        return ''.join((ch for ch in text if ch not in exclude))

    def lower(text):
        return text.lower()
    return white_space_fix(remove_articles(remove_punc(lower(s))))


ARGS = {
    "s": "The Quick Brown Fox, jumps over the lazy dog!"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
to_hex Ran
ran on a synthesized input
jiangycTarheel/NMN-MultiHopQA/hotpotqa/aug_squad.py
code served (permissive licence) · get_code("da61fab219f83a2e")
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

def to_hex(s):
    return ' '.join(map(hex, map(ord, s)))

# The function takes a string parameter 's'
# It applies ord() to each character to get its Unicode code point
# Then applies hex() to convert to hexadecimal
# Finally joins them with spaces

ARGS = {
    's': 'hello'
}
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
hotpot_biattention Not yet run
unverified (harvested, no recorded run)
jiangycTarheel/NMN-MultiHopQA/basic/attention_modules.py
code served (permissive licence) · get_code("12371c63393ec5ff")
How it ran

no invocation recorded.

weighted_biattention Not yet run
unverified (harvested, no recorded run)
jiangycTarheel/NMN-MultiHopQA/basic/attention_modules.py
code served (permissive licence) · get_code("6d204f7c5b93ae5c")
How it ran

no invocation recorded.

zhong_selfatt Not yet run
unverified (harvested, no recorded run)
jiangycTarheel/NMN-MultiHopQA/basic/attention_modules.py
code served (permissive licence) · get_code("21ba4b4ff837438c")
How it ran

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 (5 with at least one paper dated earlier, 3 the same month, 3 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
normalize_answer 133 other papers
12 dated earlier, 2 the same month, 118 later, 1 undated · 1 only as an assembly brick
1508.06615 (2015-08)
Character-Aware Neural Language Models
1606.05250 (2016-06)
SQuAD: 100,000+ Questions for Machine Comprehension of Text
1608.07905 (2016-08)
Machine Comprehension Using Match-LSTM and Answer Pointer
and 130 more not named here
exact_match_score 56 other papers
14 dated earlier, 1 the same month, 41 later
1508.06615 (2015-08)
Character-Aware Neural Language Models
1606.05250 (2016-06)
SQuAD: 100,000+ Questions for Machine Comprehension of Text
1608.07905 (2016-08)
Machine Comprehension Using Match-LSTM and Answer Pointer
and 53 more not named here
f1_score 41 other papers
12 dated earlier, 2 the same month, 27 later
1508.06615 (2015-08)
Character-Aware Neural Language Models
1606.05250 (2016-06)
SQuAD: 100,000+ Questions for Machine Comprehension of Text
1608.07905 (2016-08)
Machine Comprehension Using Match-LSTM and Answer Pointer
and 38 more not named here
compute_answer_span 1 other paper
1 dated earlier
1906.05210 (2019-06)
Explore, Propose, and Assemble: An Interpretable Model for Multi-Hop Reading Comprehension
load_metadata 1 other paper
1 dated earlier
1906.05210 (2019-06)
Explore, Propose, and Assemble: An Interpretable Model for Multi-Hop Reading Comprehension

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

Multi-hop QA requires a model to connect multiple pieces of evidence scattered in a long context to answer the question. The recently proposed HotpotQA (Yang et al., 2018) dataset is comprised of questions embodying four different multi-hop reasoning paradigms (two bridge entity setups, checking multiple properties, and comparing two entities), making it challenging for a single neural network to handle all four. In this work, we present an interpretable, controller-based Self-Assembling Neural Modular Network (Hu et al., 2017, 2018) for multi-hop reasoning, where we design four novel modules (Find, Relocate, Compare, NoOp) to perform unique types of language reasoning. Based on a question, our layout controller RNN dynamically infers a series of reasoning modules to construct the entire network. Empirically, we show that our dynamic, multi-hop modular network achieves significant improvements over the static, single-hop baseline (on both regular and adversarial evaluation). We further demonstrate the interpretability of our model via three analyses. First, the controller can softly decompose the multi-hop question into multiple single-hop sub-questions to promote compositional reasoning behavior of the main network. Second, the controller can predict layouts that conform to the layouts designed by human experts. Finally, the intermediate module can infer the entity that connects two distantly-located supporting facts by addressing the sub-question from the controller.

For agents

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

get_harvested_code_for_paper("1909.05803")
get_code_for_paper("1909.05803")
have("1909.05803")

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

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

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

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

Connect an agent — have() is free.