arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2409.09584cs.SEcs.CL
收藏

RethinkMCTS:在蒙特卡洛树搜索中修正错误思维以进行代码生成

RethinkMCTS: Refining Erroneous Thoughts in Monte Carlo Tree Search for Code Generation

Shanghai Jiao Tong University(上海交通大学);Huawei Noah’s Ark Lab(华为诺亚实验室)

Qingyao Li, Wei Xia, Kounianhua Du, Xinyi Dai, Ruiming Tang, Yasheng Wang, Yong Yu, Weinan Zhang

AI总结:

针对现有树搜索代码生成方法忽略推理过程且反思缺乏正确路径的问题,提出RethinkMCTS框架,在生成前用MCTS搜索思维并结合执行反馈修正错误思维,提升搜索质量,实验优于基线。

摘要:

树搜索方法在代码生成中展现了令人印象深刻的性能。先前的方法将树搜索与反思相结合,通过总结过去的错误来实现迭代改进。然而,这些方法面临重大挑战。首先,它们直接在代码语言空间中进行搜索,忽略了对于有效代码生成至关重要的底层推理过程。其次,基于反思的方法仅仅在记忆中积累历史错误,而没有提供正确的推理路径,使得后续搜索迭代难以识别最优解决方案,导致搜索质量下降。在这项工作中,我们提出了RethinkMCTS,一个系统性地探索和细化代码生成推理过程的框架。具体来说,我们在代码生成之前采用MCTS来搜索思维,并将MCTS与一种称为rethink的细化机制相结合,该机制整合细粒度的代码执行反馈,在搜索过程中修正错误的思维。它确保搜索路径与更好的推理保持一致,从而提高整体搜索质量。通过大量实验,我们证明RethinkMCTS优于先前基于搜索和反馈增强的代码生成基线。

英文摘要:

Tree search methods have demonstrated impressive performance in code generation. Previous methods combine tree search with reflection that summarizes past mistakes to achieve iterative improvement. However, these methods face significant challenges. First, they search directly within the code language space, neglecting the underlying reasoning process critical for effective code generation. Second, reflection-based approaches merely accumulate historical errors in memory without providing correct reasoning pathways, making it difficult for subsequent search iterations to identify optimal solutions, resulting in decreased search quality. In this work, we propose RethinkMCTS, a framework that systematically explores and refines the reasoning process for code generation. Specifically, we employ MCTS to search for thoughts before code generation and integrate MCTS with a refinement mechanism called rethink, which incorporates fine-grained code execution feedback to refine erroneous thoughts during the search. It ensures the search path aligns with better reasoning, improving overall search quality. Through extensive experiments, we demonstrate that RethinkMCTS outperforms previous search-based and feedback-enhanced code generation baselines.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑