规划以探索:基于好奇心的规划用于LLM测试生成
Planning to Explore: Curiosity-Driven Planning for LLM Test Generation
AI总结:
本文提出CovQValue方法,通过将覆盖地图反馈给LLM生成多样化计划,并利用LLM估计的Q值选择最信息量的计划,以平衡即时分支发现与未来可达性,优于贪心策略,在测试生成任务中取得更高覆盖率。
摘要:
LLM用于代码生成的应用已扩展到代码测试和评估。随着代码库规模和复杂性的增加,自动化测试生成的需求也随之增加。当前基于LLM的测试生成方法依赖于最大化即时覆盖率增益的策略,这是一种贪心方法,在代码中达到深分支需要设置步骤时会停滞。借鉴贝叶斯探索的原则,我们将程序的分支结构视为未知环境,并将演化的覆盖地图视为代理概率后验,代表LLM已发现的内容。我们的方法CovQValue将覆盖地图反馈给LLM,生成多样化的候选计划,并通过LLM估计的Q值选择最信息量的计划,以平衡即时分支发现与未来可达性。我们的方法在TestGenEval Lite上优于贪心选择,实现了51-77%更高的分支覆盖率,跨三个流行的LLM,在77-84%的目标上获胜。此外,我们构建了一个用于迭代测试生成的基准测试RepoExploreBench,在其中实现了40-74%的性能。这些结果展示了基于好奇心的规划方法在LLM探索中的潜力,通过顺序交互更有效地发现程序行为。
英文摘要:
The use of LLMs for code generation has naturally extended to code testing and evaluation. As codebases grow in size and complexity, so does the need for automated test generation. Current approaches for LLM-based test generation rely on strategies that maximize immediate coverage gain, a greedy approach that plateaus on code where reaching deep branches requires setup steps that individually yield zero new coverage. Drawing on principles of Bayesian exploration, we treat the program's branch structure as an unknown environment, and an evolving coverage map as a proxy probabilistic posterior representing what the LLM has discovered so far. Our method, CovQValue, feeds the coverage map back to the LLM, generates diverse candidate plans in parallel, and selects the most informative plan by LLM-estimated Q-values, seeking actions that balance immediate branch discovery with future reachability. Our method outperforms greedy selection on TestGenEval Lite, achieving 51-77% higher branch coverage across three popular LLMs and winning on 77-84% of targets. In addition, we build a benchmark for iterative test generation, RepoExploreBench, where they achieve 40-74%. These results show the potential of curiosity-driven planning methods for LLM-based exploration, enabling more effective discovery of program behavior through sequential interaction
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。