SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1809.06309 · 2018

Commonsense for Generative Multi-Hop Question Answering Tasks

arXiv · PDF · Open in the Atlas

Code that ran

5 of 7 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 5 have no contract verdict; 0 failures of our instrument; 2 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/1809.06309.json · badge: /api/ran/1809.06309.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
yicheng-w/CommonSenseMultiHopQA canonical (classifier label)
classifier basis: census
2 ran · 0 no recorded run
a414351664/NarrativeQA community (classifier label)
classifier basis not recorded on the link
3 ran · 2 no recorded run
FunctionStatusWhere it lives
encode_commonsense Ran
ran on a synthesized input
a414351664/NarrativeQA/src/data.py
code served (permissive licence) · get_code("767033d2a158e95e")
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 numpy as np

class SimpleVocab:
    """Minimal vocabulary object with required methods."""
    PAD = "<pad>"
    UNK = "<unk>"
    
    def __init__(self):
        self.word_to_id = {
            "<pad>": 0,
            "<unk>": 1,
            "hello": 2,
            "world": 3,
            "commonsense": 4,
            "test": 5,
        }
    
    def word2id(self, word):
        """Return word id, or UNK id if word not in vocab."""
        return self.word_to_id.get(word, self.word_to_id[self.UNK])

# Create test data: batch_size=2, with varying commonsense triples
data = [
    # First example: 3 commonsense triples
    [
        ["hello", "world", "commonsense"],
        ["test", "hello", "world"],
        ["commonsense", "test", "hello"],
    ],
    # Second example: 2 commonsense triples
    [
        ["world", "test", "hello"],
        ["commonsense", "hello", "test"],
    ],
]

vocab = SimpleVocab()
oov_vocab = {"rare_word": 10}
max_len = 4
max_triple_len = 3

ARGS = {
    "data": data,
    "max_len": max_len,
    "max_triple_len": max_triple_len,
    "vocab": vocab,
    "oov_vocab": oov_vocab,
}
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 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
encode_commonsense_paths Ran
ran on a synthesized input
a414351664/NarrativeQA/src/data.py
code served (permissive licence) · get_code("b1dc93ca4a785d10")
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 numpy as np

class MockVocab:
    def __init__(self):
        self.word_map = {
            'word1': 1,
            'word2': 2,
            'word3': 3,
            'word4': 4,
            'word5': 5,
        }
    
    def word2id(self, word):
        return self.word_map.get(word, 0)

# Create mock data: batch_size x max_time_step x max_triple_step
# This is a list of list of lists where innermost lists are words
data = [
    # First example in batch
    [
        ['word1', 'word2', 'word3'],
        ['word4', 'word5'],
        ['word1', 'word2'],
    ],
    # Second example in batch
    [
        ['word2', 'word3', 'word4', 'word5'],
        ['word1'],
    ],
]

# Parameters
max_len = 5  # max number of paths/triples
max_path_len = 4  # max number of words per path/triple
vocab = MockVocab()
oov_vocab = {'oov_word': 99}  # out-of-vocab mapping

ARGS = {
    'data': data,
    'max_len': max_len,
    'max_path_len': max_path_len,
    'vocab': vocab,
    'oov_vocab': oov_vocab,
}
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 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
gen_mc_preds Ran
ran on a synthesized input
a414351664/NarrativeQA/src/utils.py
code served (permissive licence) · get_code("3ad3ac6b3b3eab24")
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
import torch
import torch.nn as nn
import copy

torch.manual_seed(0)

# Define a minimal config class
class Config:
    def __init__(self):
        self.batch_size = 2

# Define a minimal model class that satisfies the interface
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
    
    def encode(self, data_list, is_training):
        # Returns a feed_dict-like object that model.eval expects
        return {"encoded": True}
    
    def eval(self, sess, fd):
        # Returns (something, predictions)
        # predictions should be numpy array of scores
        num_items = len(fd.get("data_list", [])) if isinstance(fd, dict) else 2
        preds = np.random.random(2).astype(np.float32)
        return None, preds

# Define a minimal valid_data class
class ValidData:
    def __init__(self):
        self.data = [
            {
                'candidates': [['token1', 'token2'], ['token3', 'token4'], ['token5', 'token6']],
                'answer1': ['init1'],
                'answer2': ['init2'],
                'orig_cand': [['result1'], ['result2'], ['result3']],
                'data_id': 'id_0'
            },
            {
                'candidates': [['token7', 'token8'], ['token9', 'token10']],
                'answer1': ['init3'],
                'answer2': ['init4'],
                'orig_cand': [['result4'], ['result5']],
                'data_id': 'id_1'
            }
        ]

# Define a minimal vocab (could be dict or object)
vocab = {'token1': 0, 'token2': 1, 'token3': 2}

# Define a minimal sess (mock session object)
class MockSession:
    pass

sess = MockSession()

# Build ARGS dictionary
ARGS = {
    'config': Config(),
    'valid_data': ValidData(),
    'vocab': vocab,
    'model': SimpleModel(),
    'sess': sess
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — 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
get_stop_words Ran
ran on a synthesized input
yicheng-w/CommonSenseMultiHopQA/src/read_data.py
code served (permissive licence) · get_code("7384690e07b3416d")
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.

from nltk.probability import FreqDist

# Construct valid arguments for get_stop_words
# The function expects:
# - total_words: a list/sequence of words to build frequency distribution from
# - num_stop_words: an integer specifying how many top words to extract

# Create a sample word list with some common words repeated
total_words = [
    'the', 'the', 'the', 'the', 'a', 'a', 'a', 'and', 'and', 'of',
    'to', 'in', 'he', 'she', 'him', 'her', 'is', 'was', 'be', 'have'
]

num_stop_words = 8

ARGS = {
    'total_words': total_words,
    'num_stop_words': num_stop_words
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk — 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
get_stop_words_1 Ran
ran on a synthesized input
yicheng-w/CommonSenseMultiHopQA/src/read_data.py
code served (permissive licence) · get_code("e5b96a8cac6d3215")
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.

from nltk.probability import FreqDist

# Create minimal test data matching the expected structure
data = [
    {
        'ques': ['what', 'is', 'python', 'the', 'the', 'a'],
        'answer1': ['python', 'is', 'a', 'programming', 'language', 'the'],
        'summary': [
            ['it', 'is', 'useful', 'the'],
            ['the', 'most', 'popular', 'language']
        ]
    },
    {
        'ques': ['how', 'to', 'learn', 'python', 'the'],
        'answer1': ['by', 'practicing', 'and', 'reading', 'the'],
        'summary': [
            ['practice', 'makes', 'perfect', 'the'],
            ['read', 'documentation', 'the', 'the']
        ]
    }
]

num_stop_words = 5

ARGS = {
    'data': data,
    'num_stop_words': num_stop_words
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
nltk — 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
eval_multiple_choice_dataset Not yet run
unverified (harvested, no recorded run)
a414351664/NarrativeQA/src/utils.py
code served (permissive licence) · get_code("63e2c59c60ff8e0c")
How it ran

no invocation recorded.

restore_vocab Not yet run
unverified (harvested, no recorded run)
a414351664/NarrativeQA/src/data.py
code served (permissive licence) · get_code("f853c33debd7891f")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 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.

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

Reading comprehension QA tasks have seen a recent surge in popularity, yet most works have focused on fact-finding extractive QA. We instead focus on a more challenging multi-hop generative task (NarrativeQA), which requires the model to reason, gather, and synthesize disjoint pieces of information within the context to generate an answer. This type of multi-step reasoning also often requires understanding implicit relations, which humans resolve via external, background commonsense knowledge. We first present a strong generative baseline that uses a multi-attention mechanism to perform multiple hops of reasoning and a pointer-generator decoder to synthesize the answer. This model performs substantially better than previous generative models, and is competitive with current state-of-the-art span prediction models. We next introduce a novel system for selecting grounded multi-hop relational commonsense information from ConceptNet via a pointwise mutual information and term-frequency based scoring function. Finally, we effectively use this extracted commonsense information to fill in gaps of reasoning between context hops, using a selectively-gated attention mechanism. This boosts the model's performance significantly (also verified via human evaluation), establishing a new state-of-the-art for the task. We also show promising initial results of the generalizability of our background knowledge enhancements by demonstrating some improvement on QAngaroo-WikiHop, another multi-hop reasoning dataset.

For agents

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

get_harvested_code_for_paper("1809.06309")
get_code_for_paper("1809.06309")
have("1809.06309")

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

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

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

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

Connect an agent — have() is free.