Learning to Generate Unit Tests for Automated Debugging

要約

ユニットテスト(UT)は、コードの正確性を評価したり、大規模な言語モデル(LLM)にフィードバックを提供したり、自動テスト生成の動機付けにフィードバックを提供したりするのに役立ちます。
ただし、障害のあるコードが与えられたときにエラーを明らかにするユニットテスト入力の生成と、ゴールドソリューションにアクセスせずにユニットテスト出力を正しく予測する間のトレードオフを明らかにします。
このトレードオフに対処するために、utgenを提案します。これは、タスクの説明に基づいて正しい予想出力とともにエラーを明らかにするユニットテスト入力を生成することをLLMSに教えることを提案します。
モデル生成テストはノイズの多いシグナルを提供できるため(例:誤った予測出力から)、UTDEBUGを提案します。(i)テストタイム計算を介してUTの出力予測を改善し、(ii)過剰発電されたUTに基づいて編集を検証し、バックトラックし、オーバーメッキを避け、LLMSデバッグを効果的に助けます。
UTGENは、エラーを反映するUT入力と正しいUT出力の両方の存在を測定するメトリックに基づいて、他のLLMベースのベースラインを7.59%上回ることを示します。
Utdebugで使用すると、Utgenの単体テストからのフィードバックは、HumanEvalfixでのQWEN2.5 32Bのパス@1の精度を改善し、MBPP+を他のLLMベースのUTジェネレーションベースラインよりも3.17%および12.35%(それぞれ)以上(それぞれ)削減することができます。
最後に、Utgenはコードの正確性のより良い裁判官であり、最先端の訓練された8B報酬モデルをHumaneval+で4.43%上回ることを実証します。

要約(オリジナル)

Unit tests (UTs) play an instrumental role in assessing code correctness as well as providing feedback to large language models (LLMs), motivating automated test generation. However, we uncover a trade-off between generating unit test inputs that reveal errors when given a faulty code and correctly predicting the unit test output without access to the gold solution. To address this trade-off, we propose UTGen, which teaches LLMs to generate unit test inputs that reveal errors along with their correct expected outputs based on task descriptions. Since model-generated tests can provide noisy signals (e.g., from incorrectly predicted outputs), we propose UTDebug that (i) scales UTGen via test-time compute to improve UT output prediction, and (ii) validates and backtracks edits based on multiple generated UTs to avoid overfitting, and helps LLMs debug effectively. We show that UTGen outperforms other LLM-based baselines by 7.59% based on a metric measuring the presence of both error-revealing UT inputs and correct UT outputs. When used with UTDebug, we find that feedback from UTGen’s unit tests improves pass@1 accuracy of Qwen2.5 32B on HumanEvalFix and our own harder debugging split of MBPP+ by over 3.17% and 12.35% (respectively) over other LLM-based UT generation baselines. Lastly, we demonstrate that UTGen is a better judge for code correctness, outperforming a state-of-the-art trained 8B reward model by 4.43% on HumanEval+ with best-of-10 sampling using Qwen2.5 7B.

arxiv情報

著者 Archiki Prasad,Elias Stengel-Eskin,Justin Chih-Yao Chen,Zaid Khan,Mohit Bansal
発行日 2025-02-26 18:03:54+00:00
arxivサイト arxiv_id(pdf)

提供元, 利用サービス

arxiv.jp, Google

カテゴリー: cs.AI, cs.CL, cs.LG, cs.SE パーマリンク