思考先行!通过彻底探索与最优精炼实现高效代码生成
Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinement
AI总结:
提出ThinkCoder框架,通过探索与精炼两阶段结合及ReST偏好优化,在降低计算成本的同时提升代码生成准确率,在HumanEval和MBPP基准上超越现有模型。
摘要:
代码生成在软件工程中对于高效自动化编码过程至关重要。虽然测试时计算方法展现出潜力,但由于多轮计算,它们遭受高延迟的困扰。为克服这一问题,我们提出了ThinkCoder框架,该框架将彻底探索与最优精炼相结合。探索阶段通过搜索潜在解决方案来多样化解空间,随后是精炼阶段以增强精确性。这种方法使我们能够在采取行动前通过仔细考虑来选择最佳解决方案,避免过度的试错。为进一步最小化测试时计算开销,我们引入了基于偏好优化的强化自训练(ReST),该技术利用ThinkCoder的探索轨迹来引导大语言模型的进化。这种方法通过偏好学习增强了大语言模型的探索效率,在保持准确性的同时降低了成本。ThinkCoder仅使用单个大语言模型即可提升性能,在HumanEval和MBPP等基准上表现出色。与最先进的模型相比,它仅以MapCoder计算成本的6.4%便将其Pass@1提高了3.0%。与AgentCoder相比,ThinkCoder在2轮后实现了0.5%更高的Pass@1,优于AgentCoder的5轮表现。此外,带有成功轨迹的ReST提高了效率,使LLaMA2-7B等模型仅使用20%的计算资源即可获得有竞争力的结果。这些结果凸显了该框架的有效性和可扩展性。
英文摘要:
Code generation is crucial in software engineering for automating the coding process efficiently. While test-time computation methods show promise, they suffer from high latency due to multiple computation rounds. To overcome this, we introduce \textbf{ThinkCoder}, a framework that combines thorough exploration with optimal refinement. The exploration phase diversifies the solution space by searching for potential solutions, followed by a refinement phase that enhances precision. This approach allows us to select the best solution through careful consideration before taking action, avoiding excessive trial and error. To further minimize test-time computation overhead, we introduce preference-driven optimization with Reinforced Self-Training (ReST), which uses exploration trajectories from ThinkCoder to guide LLM's evolution. This approach enhances LLM's exploration efficiency via preference learning, cutting costs while maintaining accuracy. ThinkCoder boosts the performance with a single LLM, excelling on benchmarks like HumanEval and MBPP. Compared to SOTA models, it improves Pass@1 by 3.0\% over MapCoder with just 6.4\% of the computation cost. Against AgentCoder, ThinkCoder achieves a 0.5\% higher Pass@1 after 2 rounds, outperforming AgentCoder's 5 rounds. Additionally, ReST with success trajectories enhances efficiency, allowing models like LLaMA2-7B to achieve competitive results using only 20\% of the computational resources. These results highlight the framework's effectiveness and scalability.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。