Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Iamhankai Forest of Thought Parse Args

From Leeroopedia
Revision as of 13:07, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Iamhankai_Forest_of_Thought_Parse_Args.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Configuration, CLI
Last Updated 2026-02-14 03:00 GMT

Overview

Concrete tool for parsing experiment configuration from command-line arguments provided by the Forest-of-Thought repository.

Description

The parse_args function defines all hyperparameters for FoT experiments using Python's argparse module. It configures forest width, MCTS depth, model selection, dataset filtering, stopping strategy, and output paths. Two variants exist: one for benchmark evaluation (run_with_mcf_stop_noearly.py) and one for Game24 solving (scripts/game24/run.py).

Usage

Import and call this function at the start of any FoT experiment script. It is typically invoked in the if __name__ == "__main__" block before model loading and dataset preparation.

Code Reference

Source Location

Signature

def parse_args():
    """
    Parses command-line arguments for Monte Carlo Forest execution.

    Returns:
        argparse.Namespace: Parsed arguments with all hyperparameters.
    """
    parser = argparse.ArgumentParser()
    parser.add_argument("--tree_nums", type=int, default=2)
    parser.add_argument("--max_iter", type=int, default=1)
    parser.add_argument("--model_path", type=str, default="")
    parser.add_argument("--model_type", type=str, default="qwen")
    parser.add_argument("--dataset", type=str, default="aime-new-mcts-")
    parser.add_argument("--level", type=int, default=1)
    parser.add_argument("--dataset_filepath", type=str, default="")
    parser.add_argument("--output_dir", type=str, default="outputs")
    parser.add_argument("--stop", type=str, default="cgdm",
                        choices=["cgdm", "random", "majority", "score"])
    parser.add_argument("--base_mode", type=str, default="mcts",
                        choices=["cot", "tot", "mcts"])
    parser.add_argument("--start_id", type=int, default=0)
    parser.add_argument("--end_id", type=int, default=500)
    parser.add_argument("--dynamic_self_correction", action="store_true")
    return parser.parse_args()

Import

# Defined in the main script; not importable as a module
# Typically called inline:
args = parse_args()

I/O Contract

Inputs

Name Type Required Description
sys.argv list[str] Yes Command-line arguments passed by shell scripts

Outputs

Name Type Description
args argparse.Namespace Structured namespace with tree_nums, max_iter, model_path, model_type, dataset, level, dataset_filepath, output_dir, stop, base_mode, start_id, end_id, dynamic_self_correction

Usage Examples

Shell Script Invocation

python run_with_mcf_stop_noearly.py \
    --tree_nums 4 \
    --max_iter 8 \
    --model_path /path/to/Qwen2.5-7B-Instruct \
    --model_type qwen \
    --dataset gsm8k \
    --base_mode mcts \
    --stop cgdm \
    --start_id 0 \
    --end_id 100

In Python

if __name__ == "__main__":
    args = parse_args()

    # Use parsed arguments to configure the experiment
    client = Pipeline(
        model_id=args.model_path,
        model_type=args.model_type,
        correction=args.dynamic_self_correction
    )
    mcf = Monte_Carlo_Forest(args)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment