用自然语言规划提升代码生成搜索多样性,显著提高准确率。
Planning In Natural Language Improves LLM Search For Code Generation
- 通过生成问题的自然语言计划,扩大搜索空间多样性。
- 在LiveCodeBench上达77.0% pass@200,超越基准60.6%。
- 适合需要高精度代码生成的研究者与开发者参考。
尽管训练算力的扩展使大语言模型性能显著提升,但推理算力的扩展尚未带来类似收益。我们推测核心瓶颈在于模型输出缺乏多样性,导致搜索过程重复采样相似且错误的生成结果。实证表明,通过在自然语言层面搜索问题求解计划,可有效缓解这一问题。基于此,我们提出PlanSearch算法:先生成多样化的自然语言观察,再构建求解计划。相比直接搜索代码,该方法探索的解空间更广泛。在Claude 3.5 Sonnet基础上,PlanSearch在LiveCodeBench(无污染竞赛编码基准)上实现77.0% pass@200,优于无搜索时的41.4%和标准重复采样60.6%。此外,我们发现所有模型、算法与基准下,搜索性能增益可由生成想法的多样性直接预测。
原文摘要 · Abstract (English)
While scaling training compute has led to remarkable improvements in large language models (LLMs), scaling inference compute has not yet yielded analogous gains. We hypothesize that a core missing component is a lack of diverse LLM outputs, leading to inefficient search due to models repeatedly sampling highly similar, yet incorrect generations. We empirically demonstrate that this lack of diversity can be mitigated by searching over candidate plans for solving a problem in natural language. Based on this insight, we propose PlanSearch, a novel search algorithm which shows strong results across HumanEval+, MBPP+, and LiveCodeBench (a contamination-free benchmark for competitive coding). PlanSearch generates a diverse set of observations about the problem and then uses these observations to construct plans for solving the problem. By searching over plans in natural language rather than directly over code solutions, PlanSearch explores a significantly more diverse range of potential solutions compared to baseline search methods. Using PlanSearch on top of Claude 3.5 Sonnet achieves a state-of-the-art pass@200 of 77.0% on LiveCodeBench, outperforming both the best score achieved without search (pass@1 = 41.4%) and using standard repeated sampling (pass@200 = 60.6%). Finally, we show that, across all models, search algorithms, and benchmarks analyzed, we can accurately predict performance gains due to search as a direct function of the diversity over generated ideas. Code can be found at https://github.com/scaleapi/plansearch.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。