コードから正確性へ:階層デバッグを用いたコード生成の最終段階のクローズ
From Code to Correctness: Closing the Last Mile of Code Generation with Hierarchical Debugging
October 2, 2024
著者: Yuling Shi, Songsong Wang, Chengcheng Wan, Xiaodong Gu
cs.AI
要旨
大規模言語モデルはコード生成において大きな進歩を遂げてきましたが、生成されたコードの合格率は微妙なエラーに制約されており、特に複雑な問題ではテストをパスするために人間の介入がしばしば必要となります。既存のLLMベースのデバッグシステムは生成されたプログラムを一枚岩の単位として扱い、低レベルの構文エラーから高レベルのアルゴリズム上の欠陥まで、複数の粒度でバグを解決することができません。本論文では、Multi-Granularity Debugger(MGDebugger)を導入し、さまざまな粒度でのバグを分離、特定、解決する階層型コードデバッガーを提案します。MGDebuggerは問題のあるコードをサブファンクションの階層木構造に分解し、各レベルが特定のエラーの粒度を表します。デバッグ中には、各サブファンクションを分析し、ボトムアップの方法でバグを反復的に解決します。各サブファンクションを効果的にテストするために、LLMシミュレートされたPython実行エンジンを提案し、コードの実行をトレースし、重要な変数の状態を追跡してエラーを正確に特定します。広範な実験により、MGDebuggerが既存のデバッグシステムを上回り、HumanEvalにおけるシード生成の正解率を18.9%向上させ、HumanEvalFixにおける97.6%の修復成功率を達成することが示されました。さらに、MGDebuggerは異なるカテゴリや難易度レベルのバグを効果的に修正し、その堅牢性と効果を示しています。
English
While large language models have made significant strides in code generation,
the pass rate of the generated code is bottlenecked on subtle errors, often
requiring human intervention to pass tests, especially for complex problems.
Existing LLM-based debugging systems treat generated programs as monolithic
units, failing to address bugs at multiple levels of granularity, from
low-level syntax errors to high-level algorithmic flaws. In this paper, we
introduce Multi-Granularity Debugger (MGDebugger), a hierarchical code debugger
by isolating, identifying, and resolving bugs at various levels of granularity.
MGDebugger decomposes problematic code into a hierarchical tree structure of
subfunctions, with each level representing a particular granularity of error.
During debugging, it analyzes each subfunction and iteratively resolves bugs in
a bottom-up manner. To effectively test each subfunction, we propose an
LLM-simulated Python executor, which traces code execution and tracks important
variable states to pinpoint errors accurately. Extensive experiments
demonstrate that MGDebugger outperforms existing debugging systems, achieving
an 18.9% improvement in accuracy over seed generations in HumanEval and a 97.6%
repair success rate in HumanEvalFix. Furthermore, MGDebugger effectively fixes
bugs across different categories and difficulty levels, demonstrating its
robustness and effectiveness.Summary
AI-Generated Summary