Can LLMs Reason About Runtime Behavior? A Repository-Level Dynamic Benchmark
作者: Hamed Taherkhani, Mohammad Abdollahi, Melika Sepidband, Hridya Dhulipala, Tien N. Nguyen, Hadi Hemmati
分类: cs.SE, cs.AI, cs.CL
发布日期: 2026-09-23
💡 一句话要点
提出SWE-Flux基准以解决LLMs在运行时行为推理的挑战
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 动态执行推理 大型语言模型 代码理解 基准测试 自动化测试
📋 核心要点
- 现有的基于代码库的问答基准主要集中在静态代码理解,缺乏对动态执行行为的有效评估。
- 本文提出SWE-Flux基准,通过自动收集测试执行的金标准答案,解决了现有方法的局限性。
- 实验结果表明,尽管模型在局部行为上表现较好,但在数据流和跨过程执行等方面仍面临挑战。
📝 摘要(中文)
大型语言模型(LLMs)在编码任务中的应用日益广泛,但其对代码执行的推理能力仍不明确。现有的基于代码库的问答基准主要评估静态代码理解,且多依赖于LLM的评估,而执行推理基准大多仅限于代码片段或函数。本文提出了SWE-Flux,这是一个包含480个执行基础实例的代码库级动态执行推理基准,覆盖12个真实的Python代码库。通过从仪器化测试执行中自动收集金标准答案,避免了手动编写或LLM判断的局限。基准涵盖了控制流、循环、程序状态、数据流、异常和程序不变式等方面的问题。对五个LLM的评估显示,这一任务仍然具有挑战性,最佳模型的准确率仅为37%。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在动态执行推理方面的不足,现有方法多集中于静态分析,缺乏对代码执行时行为的深入理解。
核心思路:通过引入SWE-Flux基准,利用自动化测试执行收集金标准答案,提供一个更具挑战性的动态推理评估框架。
技术框架:SWE-Flux基准包含480个实例,覆盖多个Python代码库,设计了单测和多测问题,涉及控制流、循环、异常等多个方面。
关键创新:最重要的创新在于通过仪器化测试自动收集答案,避免了手动编写的局限性,并且能够生成新的基准变体,增加了评估的多样性和挑战性。
关键设计:在设计中,采用了输入扰动的方法生成新变体,成功为近90%的实例生成有效变体,显著提高了基准的难度。
🖼️ 关键图片
📊 实验亮点
实验结果显示,最佳模型在SWE-Flux基准上的准确率仅为37%,表明该任务的挑战性。模型在局部行为(如不变式和简单循环)上表现较好,但在数据流和跨过程执行等复杂问题上仍存在显著不足。通过自动化生成的新变体,基准的难度显著提升,进一步验证了模型的局限性。
🎯 应用场景
该研究的潜在应用领域包括软件开发、自动化测试和代码审查等。通过提供更准确的动态执行推理评估,能够帮助开发者更好地理解和优化代码执行行为,提升代码质量和可靠性。未来,该基准可能推动LLMs在代码理解和生成方面的进一步研究与应用。
📄 摘要(原文)
Large language models (LLMs) are increasingly used in coding tasks, but their ability to reason about code execution remains unclear. Existing repository-level QA benchmarks mainly evaluate static code understanding and often rely on LLM-based evaluation, while execution-reasoning benchmarks are mostly limited to snippets or functions. We introduce SWE-Flux, a repository-level benchmark for dynamic execution reasoning containing 480 execution-grounded instances across 12 real Python repositories, with gold answers automatically harvested from instrumented test executions rather than written manually or judged by LLMs. The benchmark covers singletest and multi-test questions over control flow, loops, program state, dataflow, exceptions, and program invariants. Evaluating five LLMs shows that this task remains challenging. The best model achieves only 37% accuracy. Models perform better on localized behavior such as invariants, intra-procedural control flow, exceptions, and simple loops, but struggle with dataflow, inter-procedural execution, precise state reasoning, and suite-level aggregation. Finally, we show that the oracle-harvesting pipeline can generate fresh benchmark variants using input perturbation. It successfully harvests valid variants for almost 90% of the selected instances, and the resulting variants are substantially more challenging for the evaluated models.