SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.14992 · EMNLP · 2023

Reasoning with Language Model is Planning with World Model

Zhiting Hu, Zhen Wang, San Diego, Shibo Hao, Yi Gu, Haodi Ma, Joshua Hong, ♣ Daisy

arXiv · PDF · Open in the Atlas

Code that ran

4 of 7 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; 2 failures of our instrument; 3 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/2305.14992.json · badge: /api/ran/2305.14992.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
Ber666/RAP community
Papers with Code archive
4 ran · 3 no recorded run
FunctionStatusWhere it lives
MCTS Ran
ran on a synthesized input · constructed an object; no result was computed
Ber666/RAP/rap/blocksworld_mcts.py
code served (permissive licence) · get_code("6ffecffc5ed458c7")
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, MCTS: 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.

from collections import defaultdict
import math
from abc import ABC, abstractmethod

class MCTSNode(ABC):

    @abstractmethod
    def find_children(self):
        return set()

    @abstractmethod
    def find_one_child(self) -> 'MCTSNode':
        raise NotImplementedError

    @property
    @abstractmethod
    def is_terminal(self):
        return True

    @property
    @abstractmethod
    def reward(self):
        return 0

    @property
    @abstractmethod
    def visited(self):
        return 0


class SimpleNode(MCTSNode):
    """A simple concrete implementation of MCTSNode for testing."""
    
    def __init__(self, name, is_terminal=False, reward_val=0.0, children_list=None):
        self.name = name
        self._is_terminal = is_terminal
        self._reward = reward_val
        self._children_list = children_list or []
        self._visited_count = 0
    
    def find_children(self):
        """Return set of child nodes."""
        return set(self._children_list)
    
    def find_one_child(self):
        """Return one child node or None."""
        if self._children_list:
            return self._children_list[0]
        return None
    
    @property
    def is_terminal(self):
        return self._is_terminal
    
    @property
    def reward(self):
        return self._reward
    
    @property
    def visited(self):
        return self._visited_count
    
    def __repr__(self):
        return f"SimpleNode({self.name})"
    
    def __hash__(self):
        return hash(id(self))
    
    def __eq__(self, other):
        return id(self) == id(other)


# Create a small tree of nodes for testing
child_1 = SimpleNode("child_1", is_terminal=True, reward_val=1.5)
child_2 = SimpleNode("child_2", is_terminal=True, reward_val=2.5)
root = SimpleNode("root", is_terminal=False, reward_val=0.5, children_list=[child_1, child_2])

ARGS = {
    'w_exp': 1.0,
    'discount': 0.99,
    'prior': False,
    'aggr_reward': 'sum',
    'aggr_child': 'max'
}
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 MCTS — 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 MCTS 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
ReasoningMCTSNode Ran
ran on a synthesized input · constructed an object; no result was computed
Ber666/RAP/rap/blocksworld_mcts.py
code served (permissive licence) · get_code("badb38d7b4f74a95")
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, ReasoningMCTSNode: 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 torch
import torch.nn as nn
import math
from typing import Callable, Optional

torch.manual_seed(0)

# Define minimal stand-in classes and functions
class DummyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(x)

def dummy_gen_fn(prompt: str, model) -> str:
    """Generate next token/text given a prompt"""
    return "generated_token"

def dummy_reward_fn(text: str) -> float:
    """Reward function that evaluates text quality"""
    return float(len(text)) * 0.1

# Create instances
model = DummyModel()
prompt = "Start reasoning here"
gen_fn = dummy_gen_fn
reward_fn = dummy_reward_fn
depth = 0
r1_default = 1.0
r_alpha = 0.5
max_depth = 10
parent = None
r0 = 0.0

ARGS = {
    "prompt": prompt,
    "gen_fn": gen_fn,
    "reward_fn": reward_fn,
    "depth": depth,
    "r1_default": r1_default,
    "r_alpha": r_alpha,
    "max_depth": max_depth,
    "parent": parent,
    "r0": r0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ReasoningMCTSNode — 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 ReasoningMCTSNode 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
apply_change Ran
ran; our contract draft was wrong, not the code
Ber666/RAP/rap/blocksworld_mcts.py
code served (permissive licence) · get_code("d917f382b41e4ce4")
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
import re

torch.manual_seed(0)

# The function apply_change takes two parameters: change and state
# Both are strings based on the function body

# Construct a valid state string
# The state should contain descriptions separated by commas
# Valid states include things like:
# - "the red block is on the table"
# - "the hand is empty"
# - "the blue block is clear"
# - "the green block is on top of the red block"

state = "the red block is on the table, the hand is empty, the blue block is clear"

# Construct a valid change string
# The change describes what has changed in the format like:
# "the red block was on the table and now is on top of the blue block"

change = "the red block was on the table and now is on top of the blue block"

ARGS = {
    "change": change,
    "state": state
}
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_all_actions Ran
ran; our contract draft was wrong, not the code
Ber666/RAP/rap/blocksworld_mcts.py
code served (permissive licence) · get_code("455c2bccdc005bf2")
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 re

def generate_all_actions(state):
    return_list = []
    if 'hand is empty' in state:
        block = re.findall('the [a-z]{0,10} block is clear', state)
        block_color = [re.search('the ([a-z]{0,10}) block is clear', b).group(1) for b in block]
        for c in block_color:
            if f'the {c} block is on the table' in state:
                return_list.append(f'Pick up the {c} block')
            else:
                c_ = re.search(f'the {c} block' + ' is on top of the ([a-z]{0,10}) block', state).group(1)
                return_list.append(f'Unstack the {c} block from on top of the {c_} block')
    else:
        c = re.search('is holding the ([a-z]{0,10}) block', state).group(1)
        block = re.findall('the [a-z]{0,10} block is clear', state)
        clear_color = [re.search('the ([a-z]{0,10}) block is clear', b).group(1) for b in block]
        for c_ in clear_color:
            return_list.append(f'Stack the {c} block on top of the {c_} block')
        return_list.append(f'Put down the {c} block')
    return return_list

# Test case 1: hand is empty, blocks on table
state_empty_hand = (
    'the hand is empty. '
    'the red block is clear and the red block is on the table. '
    'the blue block is clear and the blue block is on the table.'
)

# Test case 2: hand holding block, other blocks clear
state_holding = (
    'the hand is holding the red block. '
    'the blue block is clear and the blue block is on the table. '
    'the green block is clear and the green block is on the table.'
)

ARGS = {
    'state': state_empty_hand
}
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
MCTSNode Not yet run
unverified (harvested, no recorded run)
Ber666/RAP/rap/blocksworld_mcts.py
code served (permissive licence) · get_code("1eb22998632706e9")
How it ran

no invocation recorded.

QueryLM Not yet run
unverified (harvested, no recorded run)
Ber666/RAP/rap/blocksworld_mcts.py
code served (permissive licence) · get_code("a4eddd834457a427")
How it ran

no invocation recorded.

reasoning_mcts_search Not yet run
unverified (harvested, no recorded run)
Ber666/RAP/rap/blocksworld_mcts.py
code served (permissive licence) · get_code("129e44593c44669a")
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, 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 6 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
MCTSNode
brick of this paper's assembly: helper
1 other paper
1 later · 1 only as an assembly brick
2309.17382 (2023-09)
Reason for Future, Act for Now: A Principled Framework for Autonomous LLM Agents with Provable Sample Efficiency

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

Large language models (LLMs) have shown remarkable reasoning capabilities, particularly with chain-of-thought (CoT) prompting. However, LLMs sometimes still struggle with problems that are easy for humans, such as generating action plans to achieve given goals in an environment, or performing complex math or logical reasoning. The deficiency stems from the key fact that LLMs lack an internal world model to predict the world state (e.g., environment status, intermediate variable values) and simulate long-term outcomes of actions. This prevents LLMs from performing deliberate planning akin to human brains, which involves exploring alternative reasoning paths, anticipating future states and rewards, and iteratively refining existing reasoning steps. To overcome the limitations, we propose a new LLM reasoning framework, Reasoning via Planning (RAP). RAP repurposes the LLM as both a world model and a reasoning agent, and incorporates a principled planning algorithm based on Monte Carlo Tree Search for strategic exploration in the vast reasoning space. During reasoning, the LLM (as agent) incrementally builds a reasoning tree under the guidance of the LLM (as world model) and rewards, and efficiently obtains a high-reward reasoning path with a proper balance between exploration vs. exploitation. We apply RAP to various challenging reasoning problems including plan generation, math reasoning, and logical inference, and demonstrate its superiority over strong baselines. RAP with LLaMA-33B even surpasses CoT with GPT-4, achieving 33% relative improvement in a plan generation setting. 1

For agents

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

get_harvested_code_for_paper("2305.14992")
get_code_for_paper("2305.14992")
have("2305.14992")

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

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

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

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

Connect an agent — have() is free.