arXiv:2502.17442cs.SEcs.AI2025-02ACL被引 4

ThinkCoder通过深度探索与优化精炼,用极少计算量实现高效代码生成。

Thinking Before Running! Efficient Code Generation with Thorough Exploration and Optimal Refinement

  • 先广泛探索解空间,再精细优化选最优解,减少盲目试错。
  • 单模型下Pass@1比MapCoder高3.0%,计算成本仅其6.4%。
  • 适合追求低延迟、高效率代码生成的开发者与研究者。

代码生成在软件工程中对自动化编码至关重要。尽管测试时计算方法有潜力,但因多轮计算导致延迟高。为此,我们提出ThinkCoder框架,结合深入探索与最优精炼。探索阶段通过搜索潜在解来扩展解空间,随后的精炼阶段提升精度。该方法在行动前进行充分思考,避免过多试错。为降低测试时计算开销,引入基于偏好学习的强化自训练(ReST),利用ThinkCoder的探索轨迹引导大模型演化,提高探索效率,降低成本并保持准确率。ThinkCoder在HumanEval和MBPP等基准上表现优异,相比最先进模型,其单模型设置下Pass@1比MapCoder高3.0%,计算成本仅为6.4%;相较AgentCoder,在2轮内达到0.5%更高的Pass@1,优于其5轮结果。此外,采用成功轨迹的ReST使LLaMA2-7B仅需20%计算资源即可达成竞争力结果。这些成果证明了该框架的有效性与可扩展性。

原文摘要 · Abstract (English)

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.

代码生成大模型效率优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。