This is a repo for showcasing using Monte Carlo Search Tree(MCTS) with LLMs to solve gsm8k problems.
This is just a demo project that goes with my MCTS lecture video, so the implementation and code style can be a little bit rough, feel free to leave any issues or open PRs to contribute.
- 🥳 A huge shoutout to @euyis1019, this demo now supports both
openaianddeepseekapi calling, along with token usage statistics.
The MCTS implementation template is from minimal MCTS.
Watch how I implemented this Monte Carlo Search Tree on Bilibili(Chinese)
pip install -r requirements.txtThe project supports the following command line arguments:
--provider: Select model provider, options:openai(default) ordeepseek--model: Specify model name, defaults to provider-specific model if not specified--api-key: Directly provide API key, reads from environment variables if not specified--base-url: Specify API base URL, defaults to provider-specific URL if not specified--iterations: Specify number of MCTS iterations, default is 4
Example:
export OPENAI_API_KEY="Your API Key"
python main.pyor
python main.py --provider deepseek --model deepseek-chat --iterations 4 --api-key "Your DeepSeek API Key"If you find MCTS-GSM8k-Demo useful in your research or work, please cite it as:
@software{Wangmerlyn_MCTS_GSM8k_Demo_2025,
author = {Wang, Siyuan and {Eric} and Singh, Sudhanshu},
title = {MCTS-GSM8k-Demo},
year = {2025},
publisher = {Zenodo},
doi = {10.5281/zenodo.17587990},
url = {https://doi.org/10.5281/zenodo.17587990},
note = {Zenodo release. Video demo: https://www.bilibili.com/video/BV1BArPYQE8x},
keywords = {mcts, llm, gsm8k, reasoning, demo}
}