Mcts Reasoning banner
queelius queelius

Mcts Reasoning

AI community

Description

Monte Carlo Tree Search for LLM-based reasoning with fluent API and advanced sampling strategies

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

MCTS-Reasoning

Monte Carlo Tree Search for LLM reasoning. Explores multiple reasoning paths using UCB1 to balance exploration and exploitation, with deterministic verifiers providing the reward signal.

See the [blog post](https://metafunctor.com/post/2026-04-01-i-spent-048-to-find-out-when-mcts-actually-works-for-llm-reasoning/) for experimental results and analysis.

When This Helps

MCTS adds value over best-of-N sampling under three conditions:

  1. A deterministic verifier scores solutions (not a learned reward model).
  2. The verifier provides partial credit (a gradient, not just pass/fail).
  3. The problem is hard enough that blind sampling can't reliably solve it.

On constraint satisfaction problems with 6-8 variables, MCTS(5+3) solved 100% of problems vs 90% for best-of-N and self-consistency, both using the same total budget of 8 solution attempts. Total API cost: $0.48.

Install

pip install -e .                    # Core
pip install -e ".[anthropic]"       # + Anthropic provider
pip install -e ".[openai]"          # + OpenAI provider
pip install -e ".[all]"             # Everything

Quick Start

CLI

mcts-reason "What is 15*7+23?" --answer 128 --simulations 10
mcts-reason "Question" --provider anthropic --model claude-haiku-4-5-20251001

Python

from mcts_reasoning.mcts import MCTS
from mcts_reasoning.generator import LLMGenerator
from mcts_reasoning.evaluator import NumericEvaluator
from mcts_reasoning.providers.anthropic import AnthropicProvider

llm = AnthropicProvider()
gen = LLMGenerator(llm=llm, temperature=0.7, max_tokens=150)
ev = NumericEvaluator(ground_truth=128)

mcts = MCTS(generator=gen, evaluator=ev, max_rollout_depth=5)
state = mcts.search("What is 15*7+23?", simulations=10)

Run Experiments

pip install -e ".[anthropic]"
export ANTHROPIC_API_KEY=your-key
python experiments/run_csp.py --hard --budget 1.00

The Anthropic provider tracks token usage and enfor