Skip to main content
QUICK REVIEW

[论文解读] Repairing Bugs in Python Assignments Using Large Language Models

Jialu Zhang, José Cambronero|arXiv (Cornell University)|Sep 29, 2022
Software Engineering Research被引用 30
一句话总结

MMAPR 使用在代码上训练的大型语言模型来修复 Python 学生作业中的语法和语义错误,在最新的语法+语义基线之上取得更好表现,尤其在少样本学习时。

ABSTRACT

Students often make mistakes on their introductory programming assignments as part of their learning process. Unfortunately, providing custom repairs for these mistakes can require a substantial amount of time and effort from class instructors. Automated program repair (APR) techniques can be used to synthesize such fixes. Prior work has explored the use of symbolic and neural techniques for APR in the education domain. Both types of approaches require either substantial engineering efforts or large amounts of data and training. We propose to use a large language model trained on code, such as Codex, to build an APR system -- MMAPR -- for introductory Python programming assignments. Our system can fix both syntactic and semantic mistakes by combining multi-modal prompts, iterative querying, test-case-based selection of few-shots, and program chunking. We evaluate MMAPR on 286 real student programs and compare to a baseline built by combining a state-of-the-art Python syntax repair engine, BIFI, and state-of-the-art Python semantic repair engine for student assignments, Refactory. We find that MMAPR can fix more programs and produce smaller patches on average.

研究动机与目标

  • 通过减轻教师和助教工作负担,推动编程教育中可扩展的自动化反馈。
  • 开发一个统一的系统,能够修复入门级 Python 作业中的语法和语义错误。
  • 利用在代码上训练的大型语言模型,结合多模态提示和弱监督,以提升修复质量。
  • 针对强基线对 MMAPR 进行评估并分析设计选择,如程序分块和少样本学习。

提出的方法

  • 将多模态大语言模型(Codex)作为语法与语义修复的核心引擎。
  • 使用带有程序分块器的语法阶段,将可操作的代码片段分离以用于提示。
  • 生成并验证多组语法提示;接受通过语法本体(oracle)验证的修补。
  • 使用自然语言任务描述和测试用例来引导修复的语义阶段;可选地通过测试集相似性,将同侪的解法作为少样本示例。
  • 通过基于测试集向量检索相似的过往错误/正确程序对,来整合少样本学习。
  • 在存在多个有效候选修复时,偏好与原始有错程序的标记距离最小的修复。

实验结果

研究问题

  • RQ1MMAPR 是否能修复比结合语法和语义修复工具的最先进基线更高比例的有错误的 Python 提交?
  • RQ2MMAPR 的设计决策(程序分块、迭代查询、少样本学习、多模态提示)对修复率和修补大小有何影响?
  • RQ3使用在代码上训练的LLMC是否能够实现对学生作业中语法和语义错误的统一处理?
  • RQ4与教师参考解相比,MMAPR 的修复与原始学生提交的接近程度如何?

主要发现

问题编号提交数量MMAPR TED(无少样本)MMAPR 修复率(无少样本)MMAPR TED(有少样本)MMAPR 修复率(有少样本)BIFI + Refactory 修复率BIFI + Refactory TED(SD)
2865116.45 (4.74)100.006.45 (4.74)100.00100.005.28 (4.27)
2868282.75 (2.17)82.142.75 (2.17)100.00100.001.83 (1.11)
2869232.91 (2.41)73.912.91 (2.41)100.00100.008.35 (7.00)
2870272.33 (2.18)85.192.33 (2.18)100.00100.0015.74 (23.92)
2872182.39 (1.20)72.222.39 (1.20)100.00100.007.39 (13.01)
2873322.84 (2.58)84.382.84 (2.58)90.6390.6312.93 (15.47)
2874162.06 (1.84)87.502.06 (1.84)100.00100.008.50 (11.76)
2875232.78 (2.71)78.262.78 (2.71)100.0078.2611.52 (12.52)
2877212.19 (1.29)80.952.19 (1.29)100.0080.959.14 (16.79)
2878254.84 (8.58)0.004.84 (8.58)100.0040.236.32 (59.53)
28792118.86 (21.24)66.6718.86 (21.24)85.7185.71132.78 (52.61)
28822317.39 (23.23)86.9617.39 (23.23)91.300.00106.57 (77.57)
288355.60 (9.74)80.005.60 (9.74)100.0040.0053 (0.00)
29201010.30 (18.68)50.0010.30 (18.68)80.000.00N/A
292131.67 (0.58)100.001.67 (0.58)100.000.00N/A
  • MMAPR 在没有少样本学习的情况下修复了86.71%的程序,超过基线的67.13%。
  • 在少样本学习下,MMAPR 的修复率提升至96.50%。
  • MMAPR 修补与有错程序的平均标记距离更小(31.29–31.40),低于基线的42.50。
  • 迭代语法查询将修复率从82.87%提高到86.71%。
  • 移除程序分块器会使平均标记距离从5.46增加到9.38,表明分块有助于稳定最小改动。
  • 将多模态提示组合可获得最佳性能;同侪的少样本示例进一步提升修复率。

更好的研究,从现在开始

从论文设计到论文写作,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。