ChatGPT has revolutionized many research and industrial fields. ChatGPT has shown great potential in software engineering to boost various traditional tasks such as program repair, code understanding, and code generation. However, whether automatic program repair (APR) applies to deep learning (DL) programs is still unknown. DL programs, whose decision logic is not explicitly encoded in the source code, have posed unique challenges to APR. While to repair DL programs, an APR approach needs to not only parse the source code syntactically but also needs to understand the code intention. With the best prior work, the performance of fault localization is still far less than satisfactory (only about 30\%). Therefore, in this paper, we explore ChatGPT's capability for DL program repair by asking three research questions. (1) Can ChatGPT debug DL programs effectively? (2) How can ChatGPT's repair performance be improved by prompting? (3) In which way can dialogue help facilitate the repair? On top of that, we categorize the common aspects useful for prompt design for DL program repair. Also, we propose various prompt templates to facilitate the performance and summarize the advantages and disadvantages of ChatGPT's abilities such as detecting bad code smell, code refactoring, and detecting API misuse/deprecation.
翻译:ChatGPT已经彻底改变了众多研究和工业领域。在软件工程中,ChatGPT展现出巨大潜力,能够推动程序修复、代码理解和代码生成等传统任务。然而,自动程序修复(APR)是否适用于深度学习(DL)程序仍属未知。深度学习程序的决策逻辑并未显式编码于源代码中,这给APR带来了独特挑战。要修复深度学习程序,APR方法不仅需要从语法层面解析源代码,还需理解代码意图。目前最佳方法在故障定位上的表现仍远未达到令人满意的程度(仅约30%)。因此,本文通过提出三个研究问题来探索ChatGPT在深度学习程序修复中的能力:(1)ChatGPT能否有效调试深度学习程序?(2)如何通过提示设计提升ChatGPT的修复性能?(3)对话以何种方式有助于促进修复?在此基础上,我们归纳了深度学习程序修复中提示设计的通用有效要素。同时,我们提出了多种提示模板以提升性能,并总结了ChatGPT在检测不良代码味道、代码重构以及检测API误用/弃用等方面的优势与局限性。