[论文解读] A study on Prompt Design, Advantages and Limitations of ChatGPT for Deep Learning Program Repair
本论文评估 ChatGPT 在调试、定位故障和修复深度学习(DL)程序方面的能力,并显示经过增强的提示设计和对话比基线显著提升修复性能。
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 在调试 DL 程序(故障检测、定位、修复)方面的有效性。
- 研究提示策略如何影响 ChatGPT 在 DL 代码上的修复性能。
- 探索多轮对话在促进 DL 程序修复中的作用。
- 对影响 DL 程序修复结果的提示设计因素进行分类。
提出的方法
- 使用一个包含对多种依赖(TensorFlow、PyTorch 等)的 58 个有错误 DL 程序的修复基准。
- 将 ChatGPT 与 AutoTrainer 和 DeepFD 基线在故障检测、定位和修复方面进行比较。
- 评估三种提示模板:基础(PT-B)、增强(PT-E),以及集成故障定位信息的提示对话变体(PT-Loc、PT-IncR)。
- 为每个查询运行五次独立的 ChatGPT 请求,以应对非确定性并报告多数结论。
- 分析真实世界开发者问题以为提示设计提供信息并推导出增强的提示模板。
- 记录提示和响应以便复现。

实验结果
研究问题
- RQ1RQ1: 与基线相比,ChatGPT 能否有效调试 DL 程序(故障检测、定位、修复)?
- RQ2RQ2: 通过提示(模板设计、代码意图、依赖/版本意识)如何提升 ChatGPT 的修复性能?
- RQ3RQ3: 对话(多轮交互)是否能够进一步促进修复过程?
主要发现
- 使用基础提示的 ChatGPT 能在 34 个有缺陷的 DL 程序中检测到 27 个故障,而 DeepFD 基线能够检测到全部 34/34。
- 增强提示(PT-E)将故障检测提升到 34/34,并将正确故障定位从 23 提升到 50、将正确修复从 16 提升到 43,翻倍。
- 使用 PT-E 时,能够在 34/34 的案例中完全修复的有 16 例,而使用 PT-B 时为 6/34,表明更清晰的意图和任务/数据集指导带来显著提升。
- 结合真实世界的提示信息(症状、任务、数据集、版本/依赖等)在故障定位和修复准确性方面获得显著提升。
- 基于对话的提示(增加故障定位引导和迭代修正)在 PT-E 体系下进一步提高正确修复数(从 16 增至 43)。
- ChatGPT 显示在检测 API 使用错误/弃用和代码异味方面的优势,但在默认参数识别和在没有明确修复目标的情况下保持正确定位方面存在困难。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。