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.
翻译:大语言模型在代码生成领域展现出卓越能力,但仍难以应对具有挑战性的编程任务。自我修复——即模型对自己生成的代码进行调试和错误修正——近来成为提升此类任务性能的流行方法。然而,现有文献对自我修复的有效工作机制与适用场景的研究十分有限,人们可能质疑:当代码由同一模型生成时,模型究竟能在多大程度上提供关于代码错误的准确反馈?本文针对包含多样化编程挑战的APPS数据集,系统分析了GPT-3.5与GPT-4的自我修复能力。为此,我们首先建立了名为pass@t的新型评估策略——通过衡量模型采样总token数的任务通过率,实现与纯采样方法的公平对比。基于该评估策略,我们发现自我修复的有效性仅体现在GPT-4上。同时观察到,自我修复的瓶颈在于反馈环节:当使用GPT-4为GPT-3.5生成的程序提供反馈,以及邀请人类专家程序员为GPT-4生成的程序提供反馈时,性能获得了显著提升。