SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1903.02188 · 2019

Bidirectional Attentive Memory Networks for Question Answering over Knowledge Bases

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 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 9 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/1903.02188.json · badge: /api/ran/1903.02188.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
hugochan/BAMnet canonical (classifier label)
classifier basis: census
1 ran · 2 no recorded run
hugochan/PFoodReq community (classifier label)
classifier basis not recorded on the link
8 ran · 0 no recorded run
FunctionStatusWhere it lives
expand_personalized_query Ran
ran on a synthesized input
hugochan/PFoodReq/data_builder/src/generate_all_qa.py
code served (permissive licence) · get_code("e5bbaef1e96051cb")
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 string

# Construct the persona dictionary with the required keys
persona = {
    'nutrition_preferences': ['low-sugar', 'high-protein'],
    'ingredient_likes': ['garlic', 'olive oil', 'basil'],
    'ingredient_dislikes': ['nuts', 'dairy']
}

# Construct the query string
query = "What recipes can you suggest?"

# Construct the adds list (optional parameter with default)
adds = ['nutrition_preferences', 'ingredient_likes', 'ingredient_dislikes']

# Define ARGS mapping all parameters to their values
ARGS = {
    'query': query,
    'persona': persona,
    'adds': adds
}
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
expand_query_with_guidelines Ran
ran on a synthesized input
hugochan/PFoodReq/data_builder/src/generate_all_qa.py
code served (permissive licence) · get_code("7b91003a8f6ce910")
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

ARGS = {
    "query": "What meals are healthy?",
    "guideline": {
        "Protein": {
            "unit": "g",
            "meal": {
                "lower": 20.0,
                "upper": 50.0
            }
        },
        "Carbohydrates": {
            "percentage": "total daily calories",
            "meal": {
                "lower": 45.0,
                "upper": 65.0
            }
        }
    }
}
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
generate_personal_preferences Ran
ran on a synthesized input
hugochan/PFoodReq/data_builder/src/generate_all_qa.py
code served (permissive licence) · get_code("798984742b8f27da")
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

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

# Define sample nutrition types
all_nutrition_types = np.array(['protein', 'carbs', 'fat', 'fiber', 'vitamins'])

# Define sample ingredients
ingredients = np.array(['chicken', 'rice', 'broccoli', 'salmon', 'spinach', 'olive_oil', 'garlic', 'onion'])

# Define max parameters
max_num_nutritions = 3
max_num_ingredient_likes = 2
max_num_ingredient_dislikes = 2

ARGS = {
    'all_nutrition_types': all_nutrition_types,
    'ingredients': ingredients,
    'max_num_nutritions': max_num_nutritions,
    'max_num_ingredient_likes': max_num_ingredient_likes,
    'max_num_ingredient_dislikes': max_num_ingredient_dislikes,
}
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
load_json Ran
ran on a synthesized input
hugochan/PFoodReq/data_builder/src/utils/io_utils.py
code served (permissive licence) · get_code("e26cf1b4355fc107")
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 tempfile
import os

# Create a temporary JSON file with valid data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.json")

test_data = {
    "key1": "value1",
    "key2": [1, 2, 3],
    "key3": {"nested": "object"}
}

with open(temp_file, 'w') as f:
    json.dump(test_data, f)

ARGS = {
    "file": temp_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 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
load_ndjson Ran
ran on a synthesized input
hugochan/PFoodReq/data_builder/src/utils/io_utils.py
code served (permissive licence) · get_code("e666a0b5fcf7e4e1")
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
import tempfile
import os

# Create a temporary NDJSON file
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.ndjson')
temp_file_path = temp_file.name

try:
    # Write sample NDJSON data
    temp_file.write(json.dumps({"key1": "value1", "id": 1}) + '\n')
    temp_file.write(json.dumps({"key2": "value2", "id": 2}) + '\n')
    temp_file.write(json.dumps({"key3": "value3", "id": 3}) + '\n')
    temp_file.close()
    
    # Define arguments for load_ndjson
    ARGS = {
        'file': temp_file_path,
        'return_type': 'array'
    }
finally:
    # Clean up will happen after function execution
    pass
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
load_ndjson_to_array Ran
ran on a synthesized input
hugochan/PFoodReq/data_builder/src/utils/io_utils.py
code served (permissive licence) · get_code("4462c267d24c10ba")
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
import tempfile
import os

# Create a temporary NDJSON file with sample data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.ndjson")

# Write sample NDJSON data
with open(temp_file, 'w') as f:
    f.write('{"id": 1, "text": "hello"}\n')
    f.write('{"id": 2, "text": "world"}\n')
    f.write('{"id": 3, "text": "test"}\n')

ARGS = {
    "file": temp_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
prepare_similar_ground_truth_answers Ran
ran on a synthesized input
hugochan/PFoodReq/BAMnet/src/run_online.py
code served (permissive licence) · get_code("aebe3994bd79e09a")
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 torch
import numpy as np

def get_final_answer_score(kbqa_score, answer_name, similar_recipes, max_kbqa_score, min_kbqa_score):
    """Mock function that returns a final score based on kbqa_score and answer characteristics."""
    base_score = (kbqa_score - min_kbqa_score) / (max_kbqa_score - min_kbqa_score)
    recipe_boost = similar_recipes.get(answer_name, {}).get('similarity', 0.1)
    return base_score + recipe_boost * 0.2

def get_ingredient_names(answer_name):
    """Mock function that returns a set of ingredient names for an answer."""
    ingredient_map = {
        'pasta_carbonara': {'pasta', 'eggs', 'bacon', 'cheese'},
        'chicken_soup': {'chicken', 'broth', 'vegetables', 'salt'},
        'salad': {'lettuce', 'tomato', 'cucumber'},
        'pizza': {'dough', 'tomato', 'cheese', 'basil'},
        'risotto': {'rice', 'broth', 'wine', 'cheese'},
    }
    return ingredient_map.get(answer_name, set())

kbqa_answers = ['pasta_carbonara', 'chicken_soup']

similar_recipes = {
    'pasta_carbonara': {
        'constraint_satisfaction': 'all',
        'similarity': 0.9
    },
    'chicken_soup': {
        'constraint_satisfaction': 'partial',
        'similarity': 0.7
    },
    'salad': {
        'constraint_satisfaction': 'all',
        'similarity': 0.6
    },
    'pizza': {
        'constraint_satisfaction': 'none',
        'similarity': 0.4
    },
    'risotto': {
        'constraint_satisfaction': 'partial',
        'similarity': 0.5
    },
}

ground_truth_answer_ranking_margin = 0.1

filter_out_ingredients = ['salt', 'pepper']

ARGS = {
    'get_final_answer_score': get_final_answer_score,
    'get_ingredient_names': get_ingredient_names,
    'kbqa_answers': kbqa_answers,
    'similar_recipes': similar_recipes,
    'ground_truth_answer_ranking_margin': ground_truth_answer_ranking_margin,
    'filter_out_ingredients': filter_out_ingredients,
}
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 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
string_search Ran
ran on a synthesized input
hugochan/PFoodReq/BAMnet/src/core/bamnet/bamnet.py
code served (permissive licence) · get_code("58012762e2fad6b4")
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 torch

torch.manual_seed(0)

# The function string_search takes two parameters: src and tgt
# Both are used with enumerate, indexing, slicing, and equality comparison
# They appear to be sequences (likely lists or strings)

# Create simple list arguments
src = [1, 2, 3, 4, 5, 2, 3, 6]
tgt = [2, 3]

ARGS = {
    "src": src,
    "tgt": tgt
}
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 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
to_cuda Ran
ran on a synthesized input
hugochan/BAMnet/src/core/bamnet/utils.py
code served (permissive licence) · get_code("f9709cf808e3e49a")
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. 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 to pass as x
x = torch.randn(2, 4)

# Define ARGS dict with all parameters
ARGS = {
    "x": x,
    "use_cuda": False
}
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
create_mask Not yet run
unverified (harvested, no recorded run)
hugochan/BAMnet/src/core/bamnet/modules.py
code served (permissive licence) · get_code("5724b23174c5ed85")
How it ran

no invocation recorded.

get_text_overlap Not yet run
unverified (harvested, no recorded run)
hugochan/BAMnet/src/core/bamnet/bamnet.py
code served (permissive licence) · get_code("785387dacb6461ef")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 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 11 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

When answering natural language questions over knowledge bases (KBs), different question components and KB aspects play different roles. However, most existing embedding-based methods for knowledge base question answering (KBQA) ignore the subtle inter-relationships between the question and the KB (e.g., entity types, relation paths and context). In this work, we propose to directly model the two-way flow of interactions between the questions and the KB via a novel Bidirectional Attentive Memory Network, called BAMnet. Requiring no external resources and only very few hand-crafted features, on the WebQuestions benchmark, our method significantly outperforms existing information-retrieval based methods, and remains competitive with (hand-crafted) semantic parsing based methods. Also, since we use attention mechanisms, our method offers better interpretability compared to other baselines.

For agents

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

get_harvested_code_for_paper("1903.02188")
get_code_for_paper("1903.02188")
have("1903.02188")

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

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

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

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

Connect an agent — have() is free.