用树形前缀迭代生成,让AI更高效执行代码片段。
Treefix: Enabling Execution with a Tree of Prefixes
- 用LLM逐步构建前缀树,每步利用执行反馈优化生成
- 在两个数据集上分别比现有方法多覆盖25%和7%代码行
- 适合做程序分析、自动化测试的开发者使用
执行代码是动态程序分析的基础。学习引导执行通过神经模型预测缺失变量的可能值,使任意代码片段得以运行。尽管当前最优方法如LExecutor能执行较高比例的代码,但仍受限于可预测值范围,且无法利用历史执行反馈进一步提升。本文提出Treefix,一种新型学习引导执行方法,利用大语言模型(LLM)迭代生成可执行代码前缀。该方法分步进行:每一步根据代码片段及其执行结果反馈,指导LLM改进先前生成的前缀,逐步构建前缀树。最终返回一组能最大化执行代码行数的前缀。在两个Python代码片段数据集上的实验表明,Treefix相比当前最佳方法分别实现25%和7%的覆盖率提升,分别覆盖84%和82%的代码行。
原文摘要 · Abstract (English)
The ability to execute code is a prerequisite for various dynamic program analyses. Learning-guided execution has been proposed as an approach to enable the execution of arbitrary code snippets by letting a neural model predict likely values for any missing variables. Although state-of-the-art learning-guided execution approaches, such as LExecutor, can enable the execution of a relative high amount of code, they are limited to predicting a restricted set of possible values and do not use any feedback from previous executions to execute even more code. This paper presents Treefix, a novel learning-guided execution approach that leverages LLMs to iteratively create code prefixes that enable the execution of a given code snippet. The approach addresses the problem in a multi-step fashion, where each step uses feedback about the code snippet and its execution to instruct an LLM to improve a previously generated prefix. This process iteratively creates a tree of prefixes, a subset of which is returned to the user as prefixes that maximize the number of executed lines in the code snippet. In our experiments with two datasets of Python code snippets, Treefix achieves 25% and 7% more coverage relative to the current state of the art in learning-guided execution, covering a total of 84% and 82% of all lines in the code snippets.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。