SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.01750 · ACL · 2023

Few-shot In-context Learning for Knowledge Base Question Answering ♠

Wenhu Chen, Yu Su, Yu Gu, Xueguang Ma, Tianle Li

arXiv · PDF · Open in the Atlas

Code that ran

9 of 16 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 8 have no contract verdict; 1 failure of our instrument; 7 no recorded run), measured 2026-11-23; 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/2305.01750.json · badge: /api/ran/2305.01750.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
ltl3A87/KB-BINDER canonical (classifier label)
classifier basis: census
9 ran · 6 no recorded run
ltl3a87/kb-binder canonical (classifier label)
classifier basis: census
0 ran · 1 no recorded run
FunctionStatusWhere it lives
lisp_to_nested_expression Ran
ran; our contract draft was wrong, not the code
ltl3A87/KB-BINDER/sparql_exe.py
code served (permissive licence) · get_code("720f89c903a8b4ab")
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. 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.

# Setup code for lisp_to_nested_expression

ARGS = {
    "lisp_string": "(count (division first))"
}
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 — a list 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
lisp_to_sparql Ran
ran on a synthesized input
ltl3A87/KB-BINDER/sparql_exe.py
code served (permissive licence) · get_code("d843b1f90d24d2ff")
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.

# Analyze the function signature and body
# The function lisp_to_sparql takes a single parameter: lisp_program (str)
# It processes LISP-formatted strings representing logical forms/SPARQL queries

# Looking at the function body, it:
# 1. Calls lisp_to_nested_expression(lisp_program) - expects a LISP string
# 2. Processes nested list expressions
# 3. Handles ARGMAX/ARGMIN operations
# 4. Processes JOIN, AND, and other operations
# 5. Builds SPARQL clauses

# The function expects a valid LISP program string
# Examples from the docstring and function body suggest formats like:
# - "(count (division first))"
# - Programs with JOIN operations like "(JOIN relation entity)"
# - Programs with AND operations
# - Programs that may contain ARGMAX or ARGMIN

# Create a simple valid LISP program string
ARGS = {
    "lisp_program": "(JOIN (R location.location.contains) m.02nd)"
}
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
process_file Ran
ran on a synthesized input
ltl3A87/KB-BINDER/utils.py
code served (permissive licence) · get_code("767c14bec8de2d7b")
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 JSON file with the required structure
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, 'test_data.json')

# Create sample data matching the expected structure
sample_data = [
    {
        'qid': 'q1',
        'question': 'What is the capital of France?',
        'sparql_query': 'SELECT ?x WHERE { ?x rdf:type dbpedia:City }',
        's_expression': '(filter (instance ?x City) (join (var ?x)))',
        'answer': 'Paris'
    },
    {
        'qid': 'q2',
        'question': 'Who wrote Hamlet?',
        'sparql_query': 'SELECT ?x WHERE { ?x dbpedia:wrote dbpedia:Hamlet }',
        's_expression': '(filter (wrote ?x Hamlet) (var ?x))',
        'answer': 'William Shakespeare'
    }
]

# Write sample data to temporary file
with open(temp_file, 'w') as f:
    json.dump(sample_data, f)

ARGS = {
    'filename': 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
process_file_node Ran
ran on a synthesized input
ltl3A87/KB-BINDER/utils.py
code served (permissive licence) · get_code("23f4493d2360085d")
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 structure
temp_fd, temp_path = tempfile.mkstemp(suffix='.json', text=True)

# Create sample data matching the function's expected structure
sample_data = [
    {
        'question': 'What is the capital of France?',
        'graph_query': {
            'nodes': [
                {
                    'node_type': 'entity',
                    'id': 'Q90',
                    'friendly_name': 'Paris'
                },
                {
                    'node_type': 'entity',
                    'id': 'Q142',
                    'friendly_name': 'France'
                }
            ]
        },
        'topic_entity': 'Q142',
        'topic_entity_name': 'France'
    },
    {
        'question': 'Who wrote Hamlet?',
        'graph_query': {
            'nodes': []
        },
        'topic_entity': 'Q692',
        'topic_entity_name': 'William Shakespeare'
    },
    {
        'question': 'What is the largest planet?',
        'graph_query': {
            'nodes': [
                {
                    'node_type': 'entity',
                    'id': 'Q318',
                    'friendly_name': 'Jupiter'
                }
            ]
        },
        'topic_entity': 'Q318',
        'topic_entity_name': 'Jupiter'
    }
]

# Write sample data to temp file
with os.fdopen(temp_fd, 'w') as f:
    json.dump(sample_data, f)

ARGS = {
    'filename': temp_path
}
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
process_file_test Ran
ran on a synthesized input
ltl3A87/KB-BINDER/utils.py
code served (permissive licence) · get_code("6a407d6225053a42")
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 JSON file with the required structure
temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False)
data = [
    {
        'qid': 'q1',
        'question': 'What is the capital of France?'
    },
    {
        'qid': 'q2',
        'question': 'What is the capital of Germany?'
    }
]
json.dump(data, temp_file)
temp_file.close()

ARGS = {
    'filename': temp_file.name
}
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
ques_ans_process Ran
ran on a synthesized input
ltl3A87/KB-BINDER/metaqa_src/metaqa_1hop.py
code served (permissive licence) · get_code("ff8aed0193581b80")
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 tempfile
import os

# Create a temporary file with the expected format
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("What is [Barack Obama]?\tBarack Hussein Obama|Obama\n")
temp_file.write("Who founded [Apple Inc]?\tSteve Jobs|Steve Wozniak|Ronald Wayne\n")
temp_file.close()

ARGS = {
    'file_name': temp_file.name
}
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
select_shot_prompt_train Ran
ran on a synthesized input
ltl3A87/KB-BINDER/few_shot_kbqa.py
code served (permissive licence) · get_code("408ea195a95c1b8d")
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 logging
import random

logging.basicConfig(level=logging.INFO)

# Construct valid arguments for select_shot_prompt_train

train_data_in = [
    {
        'question': 'What is the maximum value?',
        's_expression': 'ARGMAX(column1)'
    },
    {
        'question': 'Is value greater than 5?',
        's_expression': 'gt(column1, 5)'
    },
    {
        'question': 'Find the sum of values',
        's_expression': 'sum(column1, column2)'
    },
    {
        'question': 'Is value less than or equal to 10?',
        's_expression': 'le(column1, 10)'
    },
    {
        'question': 'Calculate average',
        's_expression': 'avg(column1)'
    },
    {
        'question': 'What is the minimum?',
        's_expression': 'ARGMIN(column1)'
    },
    {
        'question': 'Multiply two columns',
        's_expression': 'mul(column1, column2)'
    },
    {
        'question': 'Is value greater than or equal to 3?',
        's_expression': 'ge(column1, 3)'
    }
]

shot_number = 4

ARGS = {
    'train_data_in': train_data_in,
    'shot_number': shot_number
}
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 — 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
sub_mid_to_fn Ran
ran on a synthesized input
ltl3A87/KB-BINDER/few_shot_kbqa.py
code served (permissive licence) · get_code("0916c09fee1c5e2c")
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.

# Analyze the function to understand what it needs
# The function takes:
# 1. question: a string (key to look up in question_to_mid_dict)
# 2. string: a string containing segments, some starting with 'm.' or 'g.'
# 3. question_to_mid_dict: a nested dict mapping question -> mid -> function name

# Build the arguments
question = "What is the capital of France?"

# Create a string with MID references (segments starting with m. or g.)
string = "The answer is m.12345 and g.67890 in the context"

# Create the question_to_mid_dict with mappings from MIDs to function names
question_to_mid_dict = {
    "What is the capital of France?": {
        "m.12345": "Paris",
        "g.67890": "Europe"
    }
}

ARGS = {
    "question": question,
    "string": string,
    "question_to_mid_dict": question_to_mid_dict
}
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
type_process Ran
ran on a synthesized input
ltl3A87/KB-BINDER/metaqa_src/metaqa_1hop.py
code served (permissive licence) · get_code("59df621bd911e46d")
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 tempfile
import os

# Create a temporary file with test data
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_file.write("type1\n")
temp_file.write("type2\n")
temp_file.write("type3\n")
temp_file.close()

file_name = temp_file.name

ARGS = {
    'file_name': file_name
}
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
convert_que_to_logical_form Not yet run
unverified (harvested, no recorded run)
ltl3A87/KB-BINDER/metaqa_src/metaqa_2hop_retrieval.py
code served (permissive licence) · get_code("f1fc6cff45304a65")
How it ran

no invocation recorded.

convert_que_to_logical_form Not yet run
unverified (harvested, no recorded run)
ltl3A87/KB-BINDER/metaqa_src/metaqa_3hop_retrieval.py
code served (permissive licence) · get_code("1d153734964921c0")
How it ran

no invocation recorded.

two_hop_type_generator Not yet run
unverified (harvested, no recorded run)
ltl3A87/KB-BINDER/metaqa_src/metaqa_2hop.py
code served (permissive licence) · get_code("497120fe612c645c")
How it ran

no invocation recorded.

two_hop_type_generator Not yet run
unverified (harvested, no recorded run)
ltl3A87/KB-BINDER/metaqa_src/metaqa_3hop.py
code served (permissive licence) · get_code("7b0bb4230a4d8f59")
How it ran

no invocation recorded.

type_generator Not yet run
unverified (harvested, no recorded run)
ltl3A87/KB-BINDER/few_shot_kbqa.py
code served (permissive licence) · get_code("1579076f50506d33")
How it ran

no invocation recorded.

type_generator Not yet run
unverified (harvested, no recorded run)
ltl3A87/KB-BINDER/metaqa_src/metaqa_1hop.py
code served (permissive licence) · get_code("b8078083322e80ae")
How it ran

no invocation recorded.

type_generator Not yet run
unverified (harvested, no recorded run)
ltl3a87/kb-binder/metaqa_src/metaqa_1hop_retrieval.py
code served (permissive licence) · get_code("d50559ab9147187a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 16 samples lifted from this paper's linked repositories, 16 carry a function identity and 0 do not. Of the 16 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 15 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
lisp_to_nested_expression 1 other paper
1 later
2406.07080 (2024-06)
DARA: Decomposition-Alignment-Reasoning Autonomous Language Agent for Question Answering over Knowledge Graphs

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-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Question answering over knowledge bases is considered a difficult problem due to the challenge of generalizing to a wide variety of possible natural language questions. Additionally, the heterogeneity of knowledge base schema items between different knowledge bases often necessitates specialized training for different knowledge base question-answering (KBQA) datasets. To handle questions over diverse KBQA datasets with a unified trainingfree framework, we propose KB-BINDER, which for the first time enables few-shot incontext learning over KBQA tasks. Firstly, KB-BINDER leverages large language models like Codex to generate logical forms as the draft for a specific question by imitating a few demonstrations. Secondly, KB-BINDER grounds on the knowledge base to bind the generated draft to an executable one with BM25 score matching. The experimental results on four public heterogeneous KBQA datasets show that KB-BINDER can achieve a strong performance with only a few in-context demonstrations. Especially on GraphQA and 3-hop MetaQA, KB-BINDER can even outperform the state-of-the-art trained models. On GrailQA and WebQSP, our model is also on par with other fully-trained models. We believe KB-BINDER can serve as an important baseline for future research. Our code is available at https://github.com/ltl3A87/KB-BINDER Recently, large language models (LLMs) like GPT-3 and Codex (Brown et al., 2020a; Chen et al.,

For agents

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

get_harvested_code_for_paper("2305.01750")
get_code_for_paper("2305.01750")
have("2305.01750")

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

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

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

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

Connect an agent — have() is free.