SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2501.18922 · ICML · 2025

KBQA-o1: Agentic Knowledge Base Question Answering with Monte Carlo Tree Search

Wenhao Liu, Anh Luu, Tuan, Haoran Luo, Xiaobao Wu, Yikai Guo, Meina Song, Yifan Zhu, Qika Lin, Xinyu Mu, K Environment

arXiv · PDF · Open in the Atlas

Code that ran

2 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 0 failures of our instrument; 6 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/2501.18922.json · badge: /api/ran/2501.18922.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/kbqa-o1 marked official in Papers with Code
Papers with Code archive
2 ran · 6 no recorded run
FunctionStatusWhere it lives
MCTSAggregation Ran
ran on a synthesized input · constructed an object; no result was computed
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("e9dbab5ed596fade")
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 an instance of its own class, MCTSAggregation: the run constructed the object and did not call it, so no result was computed. 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
from typing import Hashable, Optional
from collections import defaultdict
import itertools

Action = str
Example = str
State = dict

class MCTSNode:
    id_iter = itertools.count()

    @classmethod
    def reset_id(cls):
        cls.id_iter = itertools.count()

    def __init__(self, state: Optional[State], action: Optional[Action], parent: Optional['MCTSNode']=None, fast_reward: float=0.0, fast_reward_details=None, is_terminal: bool=False, calc_q=np.mean):
        self.id = next(MCTSNode.id_iter)
        if fast_reward_details is None:
            fast_reward_details = {}
        self.cum_rewards: list[float] = []
        self.fast_reward = self.reward = fast_reward
        self.fast_reward_details = fast_reward_details
        self.is_terminal = is_terminal
        self.action = action
        self.state = state
        self.parent = parent
        self.children: Optional[list['MCTSNode']] = None
        self.calc_q = calc_q
        if parent is None:
            self.depth = 0
        else:
            self.depth = parent.depth + 1

    @property
    def Q(self) -> float:
        if self.state is None:
            return self.fast_reward
        else:
            return self.calc_q(self.cum_rewards)

def retrieve_answer_func(state: State) -> Optional[Hashable]:
    """Extract answer from state"""
    if state is None:
        return None
    return state.get('answer', None)

MCTSNode.reset_id()

root = MCTSNode(
    state={'value': 1, 'answer': 'answer_A'},
    action=None,
    parent=None,
    fast_reward=0.5,
    is_terminal=False
)

child1 = MCTSNode(
    state={'value': 2, 'answer': 'answer_A'},
    action='action_1',
    parent=root,
    fast_reward=0.3,
    is_terminal=True
)

child2 = MCTSNode(
    state={'value': 3, 'answer': 'answer_B'},
    action='action_2',
    parent=root,
    fast_reward=0.4,
    is_terminal=True
)

root.children = [child1, child2]

ARGS = {
    'retrieve_answer': retrieve_answer_func,
    'weight_policy': 'edge'
}
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 MCTSAggregation — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MCTSAggregation 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
MCTSResult Ran
ran on a synthesized input · constructed an object; no result was computed
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("c1fa3356de702795")
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 an instance of its own class, MCTSResult: the run constructed the object and did not call it, so no result was computed. 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 itertools
import numpy as np
from typing import NamedTuple, Optional, Callable

Action = str
Example = str
State = str

Trace = tuple[list[State], list[Action]]

class MCTSNode:
    id_iter = itertools.count()

    @classmethod
    def reset_id(cls):
        cls.id_iter = itertools.count()

    def __init__(self, state: Optional[State], action: Optional[Action], parent: 'Optional[MCTSNode]'=None, fast_reward: float=0.0, fast_reward_details=None, is_terminal: bool=False, calc_q: Callable[[list[float]], float]=np.mean):
        self.id = next(MCTSNode.id_iter)
        if fast_reward_details is None:
            fast_reward_details = {}
        self.cum_rewards: list[float] = []
        self.fast_reward = self.reward = fast_reward
        self.fast_reward_details = fast_reward_details
        self.is_terminal = is_terminal
        self.action = action
        self.state = state
        self.parent = parent
        self.children: 'Optional[list[MCTSNode]]' = None
        self.calc_q = calc_q
        if parent is None:
            self.depth = 0
        else:
            self.depth = parent.depth + 1

    @property
    def Q(self) -> float:
        if self.state is None:
            return self.fast_reward
        else:
            return self.calc_q(self.cum_rewards)

class MCTSResult(NamedTuple):
    terminal_state: State
    cum_reward: float
    trace: Trace
    trace_of_nodes: list[MCTSNode]
    tree_state: MCTSNode
    trace_in_each_iter: list[list[MCTSNode]] = None
    tree_state_after_each_iter: list[MCTSNode] = None
    aggregated_result: Optional[str] = None

MCTSNode.reset_id()

root_node = MCTSNode(state="state_root", action=None, parent=None, fast_reward=0.0, is_terminal=False)

child_node_1 = MCTSNode(state="state_child_1", action="action_1", parent=root_node, fast_reward=1.5, is_terminal=False)

child_node_2 = MCTSNode(state="state_child_2", action="action_2", parent=root_node, fast_reward=2.0, is_terminal=True)

terminal_state_value = "state_terminal"
cum_reward_value = 3.5

states_list = ["state_0", "state_1", "state_2"]
actions_list = ["action_a", "action_b", "action_c"]
trace_value = (states_list, actions_list)

trace_of_nodes_value = [root_node, child_node_1, child_node_2]

tree_state_value = child_node_2

trace_in_each_iter_value = [[root_node], [root_node, child_node_1], [root_node, child_node_2]]

tree_state_after_each_iter_value = [root_node, child_node_1, child_node_2]

aggregated_result_value = "final_result"

ARGS = {
    "terminal_state": terminal_state_value,
    "cum_reward": cum_reward_value,
    "trace": trace_value,
    "trace_of_nodes": trace_of_nodes_value,
    "tree_state": tree_state_value,
    "trace_in_each_iter": trace_in_each_iter_value,
    "tree_state_after_each_iter": tree_state_after_each_iter_value,
    "aggregated_result": aggregated_result_value,
}
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 MCTSResult — the run constructed an instance of its own class and did not call it; no shape 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
AlgorithmOutput Not yet run
unverified (harvested, no recorded run)
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("22d79f2a24676d64")
How it ran

no invocation recorded.

MCTS Not yet run
unverified (harvested, no recorded run)
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("ef265cb7e70e7f95")
How it ran

no invocation recorded.

MCTSNode Not yet run
unverified (harvested, no recorded run)
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("ad93a0a3f26917e5")
How it ran

no invocation recorded.

SearchAlgorithm Not yet run
unverified (harvested, no recorded run)
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("0929e8f968cb8553")
How it ran

no invocation recorded.

SearchConfig Not yet run
unverified (harvested, no recorded run)
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("8090ffd5c2edd546")
How it ran

no invocation recorded.

WorldModel Not yet run
unverified (harvested, no recorded run)
lhrlab/kbqa-o1/reasoners/algorithm/mcts.py
code served (permissive licence) · get_code("a3c3ee14a429c8f2")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 5 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
AlgorithmOutput
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2305.10601 (2023-05)
Tree of Thoughts: Deliberate Problem Solving with Large Language Models
SearchAlgorithm
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2305.10601 (2023-05)
Tree of Thoughts: Deliberate Problem Solving with Large Language Models
WorldModel
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2305.10601 (2023-05)
Tree of Thoughts: Deliberate Problem Solving with Large Language Models

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

Knowledge Base Question Answering (KBQA) aims to answer natural language questions with a large-scale structured knowledge base (KB). Despite advancements with large language models (LLMs), KBQA still faces challenges in weak KB awareness, imbalance between effectiveness and efficiency, and high reliance on annotated data. To address these challenges, we propose KBQA-o1, a novel agentic KBQA method with Monte Carlo Tree Search (MCTS). It introduces a ReAct-based agent process for stepwise logical form generation with KB environment exploration. Moreover, it employs MCTS, a heuristic search method driven by policy and reward models, to balance agentic exploration's performance and search space. With heuristic exploration, KBQA-o1 generates high-quality annotations for further improvement by incremental fine-tuning. Experimental results show that KBQA-o1 outperforms previous lowresource KBQA methods with limited annotated data, boosting Llama-3.1-8B model's GrailQA F1 performance to 78.5% compared to 48.5% of the previous sota method with GPT-3.5-turbo. Our code is publicly available at https://github. com/LHRLAB/KBQA-o1. He's a Bully, Charlie Brown m.02686wj KBQA-o1: Agentic Knowledge Base Question Answering with Monte Carlo Tree Search End-to-end LLM-based KBQA Methods Stey-by-step LLM-based KBQA Methods Heuristic LLM-based KBQA Retrieve-then-Generate Generate-then-Retrieve

For agents

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

get_harvested_code_for_paper("2501.18922")
get_code_for_paper("2501.18922")
have("2501.18922")

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

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

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

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

Connect an agent — have() is free.