SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2310.08975 · 2023

ChatKBQA: A Generate-then-Retrieve Framework for Knowledge Base Question Answering with Fine-tuned Large Language Models

arXiv · PDF · Open in the Atlas

Code that ran

11 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; 2 honoured the contract we drafted, 1 violated it and 0 have no contract verdict; 8 failures of our instrument; 5 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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/2310.08975.json · badge: /api/ran/2310.08975.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
lhrlab/chatkbqa canonical (classifier label)
classifier basis: census
11 ran · 5 no recorded run
FunctionStatusWhere it lives
to_list Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/config.py
pointer only (licence: MIT); the stored copy get_code serves, from AI-secure/InfoBERT, is pointer only (licence: NONE) · get_code("9df40357afea56cc")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from AI-secure/InfoBERT, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

date_post_process Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/eval_final.py
pointer only (licence: MIT); the stored copy get_code serves, from Applied-Machine-Learning-Lab/AMAR, is pointer only (licence: NONE) · get_code("7c96e3db8ff7299a")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Applied-Machine-Learning-Lab/AMAR, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

extract_entities Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/components/expr_parser.py
code served (permissive licence) · get_code("e73dc55f0b4f1aed")
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

def tokenize_s_expr(expr):
    expr = expr.replace('(', ' ( ')
    expr = expr.replace(')', ' ) ')
    toks = expr.split(' ')
    toks = [x for x in toks if len(x)]
    return toks

def extract_entities(expr):
    toks = tokenize_s_expr(expr)
    return [x for x in toks if x.startswith('m.')]

# Set seed for reproducibility
torch.manual_seed(0)

# Build test arguments
# The function takes a single parameter 'expr' which is a string
# It processes it by tokenizing and extracting entities that start with 'm.'

test_expr = "(m.entity1 m.entity2 (m.entity3 other_token))"

ARGS = {
    'expr': test_expr
}
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 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
extract_relations Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/components/expr_parser.py
code served (permissive licence) · get_code("eb0198ee05eaa775")
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

torch.manual_seed(0)

def tokenize_s_expr(expr):
    expr = expr.replace('(', ' ( ')
    expr = expr.replace(')', ' ) ')
    toks = expr.split(' ')
    toks = [x for x in toks if len(x)]
    return toks

def extract_relations(expr):
    toks = tokenize_s_expr(expr)
    return [x for x in toks if '.' in x and (not x.startswith('m.')) and (not '^^' in x)]

# The function extract_relations takes a single parameter: expr (a string)
# It tokenizes the expression and filters for tokens containing '.' that don't start with 'm.' and don't contain '^^'

expr_value = "(foo.bar baz.qux m.hidden (qux.prop thing^^type))"

ARGS = {
    'expr': expr_value
}
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 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
httpPort Ran
ran, honoured the contract we drafted
lhrlab/chatkbqa/Freebase-Setup/virtuoso.py
code served (permissive licence) · get_code("2bc45468ebfe2d61")
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 int, ndim 0, dtype family int, 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 torch
import torch.nn as nn

torch.manual_seed(0)

# The function httpPort simply takes a port parameter and returns it
# No complex setup needed - port should be an integer

ARGS = {
    "port": 8080
}
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 int, ndim 0, dtype family int, 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
is_number Ran
ran, violated the contract we drafted
lhrlab/chatkbqa/eval_final.py
pointer only (licence: MIT); the stored copy get_code serves, from Applied-Machine-Learning-Lab/AMAR, is pointer only (licence: NONE) · get_code("b2feca00ae40a160")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Applied-Machine-Learning-Lab/AMAR, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

isqlPort Ran
ran, honoured the contract we drafted
lhrlab/chatkbqa/Freebase-Setup/virtuoso.py
code served (permissive licence) · get_code("f42bcb1c173e1a09")
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 int, ndim 0, dtype family int, 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 torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "port": 5
}
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 int, ndim 0, dtype family int, 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
prepare_dataloader Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/run_generator_final.py
code served (permissive licence) · get_code("7600856fdde258c1")
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 file with sample JSON data
temp_dir = tempfile.mkdtemp()
data_file = os.path.join(temp_dir, 'test_data.jsonl')

# Write sample JSONL data
sample_data = [
    {'text': 'hello world', 'label': 0},
    {'text': 'foo bar', 'label': 1},
    {'text': 'test example', 'label': 0},
]

with open(data_file, 'w', encoding='utf-8') as f:
    for item in sample_data:
        f.write(json.dumps(item) + '\n')

# Create args object as a simple class with required attribute
class Args:
    def __init__(self, data_file_name):
        self.data_file_name = data_file_name

ARGS = {'args': Args(data_file_name=data_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
run Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/Freebase-Setup/virtuoso.py
code served (permissive licence) · get_code("acd5c28102430f1b")
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 bytes. 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 subprocess

def run(command):
    print(f'RUNNING: {command}')
    res = subprocess.run(command, shell=True, stdout=subprocess.PIPE)
    return res.stdout

ARGS = {
    'command': 'echo "Hello World"'
}
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 bytes — a bytes output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a bytes 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
tokenize_s_expr Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/components/expr_parser.py
code served (permissive licence) · get_code("75b1fc99101be3e8")
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

torch.manual_seed(0)

# The function tokenize_s_expr takes a single parameter: expr
# It expects a string representing an S-expression
# The function replaces parentheses with spaces, splits on whitespace, and filters empty strings

ARGS = {
    'expr': '(define (factorial n) (if (= n 0) 1 (* n (factorial (- n 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 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
type_checker Ran
ran; our contract draft was wrong, not the code
lhrlab/chatkbqa/eval_final.py
pointer only (licence: MIT); the stored copy get_code serves, from Applied-Machine-Learning-Lab/AMAR, is pointer only (licence: NONE) · get_code("038bd5a70277091b")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from Applied-Machine-Learning-Lab/AMAR, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

convert_cwq_sparql_instance Not yet run
unverified (harvested, no recorded run)
lhrlab/chatkbqa/parse_sparql_cwq.py
code served (permissive licence) · get_code("6f0de9ba1399e587")
How it ran

no invocation recorded.

convert_parse_instance Not yet run
unverified (harvested, no recorded run)
lhrlab/chatkbqa/parse_sparql_webqsp.py
code served (permissive licence) · get_code("b6fede6aafdf9760")
How it ran

no invocation recorded.

convert_webqsp_sparql_instance Not yet run
unverified (harvested, no recorded run)
lhrlab/chatkbqa/parse_sparql_webqsp.py
code served (permissive licence) · get_code("0632af12ebb615dc")
How it ran

no invocation recorded.

get_model_class Not yet run
unverified (harvested, no recorded run)
lhrlab/chatkbqa/config.py
code served (permissive licence) · get_code("e267b92fe2e9c426")
How it ran

no invocation recorded.

load_untrained_model Not yet run
unverified (harvested, no recorded run)
lhrlab/chatkbqa/config.py
code served (permissive licence) · get_code("e8cde2d16a8c1b7c")
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, 9 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 1 the same month, 9 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
to_list 41 other papers
34 dated earlier, 2 the same month, 4 later, 1 same year, order not determinable
1902.01718 (2019-02)
End-to-End Open-Domain Question Answering with BERTserini
1910.06188 (2019-10)
Q8BERT: Quantized 8Bit BERT
1911.02984 (2019-11)
The TechQA Dataset
and 38 more not named here
date_post_process 2 other papers
2 later
2412.18537 (2024-12)
Harnessing Large Language Models for Knowledge Graph Question Answering via Adaptive Multi-Aspect Retrieval-Augmentation
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering
httpPort 2 other papers
2 later
2024.findings-naacl.57 (2024 (year only))
BRING YOUR OWN KG: Self-Supervised Program Synthesis for Zero-Shot KGQA
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering
is_number 2 other papers
2 later
2412.18537 (2024-12)
Harnessing Large Language Models for Knowledge Graph Question Answering via Adaptive Multi-Aspect Retrieval-Augmentation
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering
isqlPort 2 other papers
2 later
2024.findings-naacl.57 (2024 (year only))
BRING YOUR OWN KG: Self-Supervised Program Synthesis for Zero-Shot KGQA
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering
run 2 other papers
2 later
2024.findings-naacl.57 (2024 (year only))
BRING YOUR OWN KG: Self-Supervised Program Synthesis for Zero-Shot KGQA
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering
type_checker 2 other papers
2 later
2412.18537 (2024-12)
Harnessing Large Language Models for Knowledge Graph Question Answering via Adaptive Multi-Aspect Retrieval-Augmentation
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering
get_model_class 1 other paper
1 later
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering
load_untrained_model 1 other paper
1 later
2603.20017 (2026-03)
RouterKGQA: Specialized-General Model Routing for Constraint-Aware Knowledge Graph Question Answering

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

Knowledge Base Question Answering (KBQA) aims to answer natural language questions over large-scale knowledge bases (KBs), which can be summarized into two crucial steps: knowledge retrieval and semantic parsing. However, three core challenges remain: inefficient knowledge retrieval, mistakes of retrieval adversely impacting semantic parsing, and the complexity of previous KBQA methods. To tackle these challenges, we introduce ChatKBQA, a novel and simple generate-then-retrieve KBQA framework, which proposes first generating the logical form with fine-tuned LLMs, then retrieving and replacing entities and relations with an unsupervised retrieval method, to improve both generation and retrieval more directly. Experimental results show that ChatKBQA achieves new state-of-the-art performance on standard KBQA datasets, WebQSP, and CWQ. This work can also be regarded as a new paradigm for combining LLMs with knowledge graphs (KGs) for interpretable and knowledge-required question answering. Our code is publicly available.

For agents

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

get_harvested_code_for_paper("2310.08975")
get_code_for_paper("2310.08975")
have("2310.08975")

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

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

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

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

Connect an agent — have() is free.