Debug like a Human: A Large Language Model Debugger via Verifying Runtime Execution Step-by-step
作者: Li Zhong, Zilong Wang, Jingbo Shang
分类: cs.SE, cs.AI, cs.CL
发布日期: 2024-02-25 (更新: 2024-06-06)
备注: Preprint
💡 一句话要点
提出大型语言模型调试器以解决程序调试效率低下问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大型语言模型 程序调试 运行时信息 代码生成 性能提升 基本块 中间变量
📋 核心要点
- 现有方法将生成的程序视为整体,缺乏对复杂逻辑和数据操作的细致调试,导致调试效率低下。
- 本文提出的LDB框架通过将程序分段为基本块,利用运行时信息逐块验证程序的正确性,从而提高调试效率。
- 实验结果显示,LDB在多个基准测试中提升了调试性能,最高可达9.8%的提升,展示了其有效性。
📝 摘要(中文)
大型语言模型(LLMs)在代码生成方面取得了显著进展。近期的研究将单元测试和程序验证器集成到LLMs中,以迭代地优化生成的程序。然而,这些研究将生成的程序视为不可分割的整体,导致在调试复杂逻辑和数据操作时效果不佳。本文提出了大型语言模型调试器(LDB),该框架通过运行时执行信息对生成的程序进行细化。LDB将程序分段为基本块,并在每个块执行后跟踪中间变量的值,使LLMs能够逐块验证程序的正确性,从而高效定位潜在错误。实验结果表明,LDB在HumanEval、MBPP和TransCoder基准测试中,性能提升最高可达9.8%,在代码调试领域实现了新的最先进性能。
🔬 方法详解
问题定义:本文旨在解决现有大型语言模型在调试复杂程序时效率低下的问题。现有方法将生成的程序视为不可分割的整体,未能有效利用运行时执行信息。
核心思路:LDB框架通过将程序分割为基本块,并在每个块执行后跟踪中间变量的值,使得LLMs能够逐块验证程序的正确性,从而提高调试的精确性和效率。
技术框架:LDB的整体架构包括程序分块、运行时信息跟踪和逐块验证三个主要模块。程序首先被分割为基本块,然后在执行过程中收集中间变量的值,最后逐块进行正确性验证。
关键创新:LDB的主要创新在于引入了运行时执行信息的逐块验证机制,使得LLMs能够像人类开发者一样进行调试,显著提升了调试的准确性和效率。
关键设计:在设计中,LDB采用了动态跟踪中间变量的策略,并结合了基于任务描述的逐块验证方法,确保了调试过程的高效性和准确性。
🖼️ 关键图片
📊 实验亮点
实验结果表明,LDB在HumanEval、MBPP和TransCoder基准测试中,调试性能提升最高可达9.8%。这一结果不仅超越了现有的基线性能,还在多个测试中实现了新的最先进水平,展示了LDB的有效性和实用性。
🎯 应用场景
该研究的潜在应用领域包括软件开发、自动化测试和代码审查等。通过提高大型语言模型在程序调试中的效率,LDB能够帮助开发者更快速地定位和修复错误,从而提升软件开发的整体质量和效率。未来,LDB可能会在更广泛的编程语言和复杂系统中得到应用,推动智能编程工具的发展。
📄 摘要(原文)
Large language models (LLMs) are leading significant progress in code generation. Beyond one-pass code generation, recent works further integrate unit tests and program verifiers into LLMs to iteratively refine the generated programs. However, these works consider the generated programs as an indivisible entity, which falls short for LLMs in debugging the programs, especially when the programs contain complex logic flows and data operations. In contrast, when human developers debug programs, they typically set breakpoints and selectively examine runtime execution information. The execution flow and the intermediate variables play a crucial role in the debugging process, yet they are underutilized in the existing literature on code generation. In this study, we introduce Large Language Model Debugger (LDB), a novel debugging framework that enables LLMs to refine their generated programs with the runtime execution information. Specifically, LDB segments the programs into basic blocks and tracks the values of intermediate variables after each block throughout the runtime execution. This allows LLMs to concentrate on simpler code units within the overall execution flow, verify their correctness against the task description block by block, and efficiently pinpoint any potential errors. Experiments demonstrate that LDB consistently enhances the baseline performance by up to 9.8% across the HumanEval, MBPP, and TransCoder benchmarks, archiving new state-of-the-art performance in code debugging for various LLM selections.