GPTによるコード生成の自己修復の解明
Demystifying GPT Self-Repair for Code Generation
June 16, 2023
著者: Theo X. Olausson, Jeevana Priya Inala, Chenglong Wang, Jianfeng Gao, Armando Solar-Lezama
cs.AI
要旨
大規模言語モデル(LLM)はコード生成において顕著な能力を示しているが、難しいプログラミングタスクでは依然として苦戦している。自己修復(self-repair)——モデルが自身のコードの誤りをデバッグし修正するプロセス——は、最近、こうした状況でのパフォーマンス向上のための人気のある手法となっている。しかし、自己修復がどのように、そしてどのような場合に効果的に機能するかについての研究は文献上非常に限られており、モデルが自身で生成したコードについて、なぜそのコードが間違っているのか正確なフィードバックを提供できるのか、どの程度まで可能なのか疑問が残る。本論文では、GPT-3.5とGPT-4の自己修復能力を、多様なコーディング課題からなる難易度の高いデータセットAPPSにおいて分析する。そのために、まず、モデルからサンプリングされたトークン総数に対するタスクの合格率を測定する新しい評価戦略「pass@t」を確立し、純粋なサンプリングベースのアプローチとの公平な比較を可能にする。この評価戦略を用いて、自己修復の有効性はGPT-4でのみ見られることを明らかにした。また、自己修復はフィードバック段階でボトルネックになっていることが観察された。GPT-3.5が生成したプログラムに対してGPT-4を使用してフィードバックを与え、GPT-4が生成したプログラムに対して専門の人間プログラマーがフィードバックを与えることで、大幅なパフォーマンス向上が実現された。
English
Large Language Models (LLMs) have shown remarkable aptitude in code
generation but still struggle on challenging programming tasks. Self-repair --
in which the model debugs and fixes mistakes in its own code -- has recently
become a popular way to boost performance in these settings. However, only very
limited studies on how and when self-repair works effectively exist in the
literature, and one might wonder to what extent a model is really capable of
providing accurate feedback on why the code is wrong when that code was
generated by the same model. In this paper, we analyze GPT-3.5 and GPT-4's
ability to perform self-repair on APPS, a challenging dataset consisting of
diverse coding challenges. To do so, we first establish a new evaluation
strategy dubbed pass@t that measures the pass rate of the tasks against the
total number of tokens sampled from the model, enabling a fair comparison to
purely sampling-based approaches. With this evaluation strategy, we find that
the effectiveness of self-repair is only seen in GPT-4. We also observe that
self-repair is bottlenecked by the feedback stage; using GPT-4 to give feedback
on the programs generated by GPT-3.5 and using expert human programmers to give
feedback on the programs generated by GPT-4, we unlock significant performance
gains.