VerMCTS: Synthesizing Multi-Step Programs using a Verifier, a Large Language Model, and Tree Search

David Brandfonbrener, Simon Henniger, Sibi Raja, Tarun Prasad, Chloe Loughridge +6 more
2/13/2024
cs.SEcs.AIcs.LG

Official code: namin/llm-verified-with-monte-carlo-tree-search (292 stars, MIT, last commit 2025-03-31).

Abstract

Large Language Models (LLMs) can generate useful code, but often the code they generate cannot be trusted to be sound. In this paper, we present VerMCTS, an approach to begin to resolve this issue by generating verified programs in Dafny and Coq. VerMCTS uses a logical verifier in concert with an LLM to guide a modified Monte Carlo Tree Search (MCTS). This approach leverages the verifier to gain intermediate feedback inside the search algorithm by checking partial programs at each step to estimate an upper bound on the value function. To measure the performance of VerMCTS, we develop a new suite of multi-step verified programming problems in Dafny and Coq. In terms of pass@T, a new metric which computes the pass rate given a budget of T tokens sampled from the LLM, VerMCTS leads to more than a 30% absolute increase in average pass@5000 across the suite over repeated sampling from the base language model. Our code and benchmarks are available at https://github.com/namin/llm-verified-with-monte-carlo-tree-search .

View on arXivView PDF

Code Implementations(1)

MIT

LLM verified with Monte Carlo Tree Search

29229Shell, PythonNov 11, 20231 years agoMIT
aicoqdafnyleanllm+3 more

Cite this paper

@article{brandfonbrener2024vermcts,
  title  = {VerMCTS: Synthesizing Multi-Step Programs using a Verifier, a Large Language Model, and Tree Search},
  author = {David Brandfonbrener and Simon Henniger and Sibi Raja and Tarun Prasad and Chloe Loughridge and Federico Cassano and Sabrina Ruixin Hu and Jianang Yang and William E. Byrd and Robert Zinkov and Nada Amin},
  year   = {2024},
  eprint = {2402.08147},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2402.08147v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.08147.svg)](https://codeofpaper.com/paper/2402.08147)

Discussion