arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2106.06600cs.LGcs.CLcs.SE
收藏

Break-It-Fix-It:用于程序修复的无监督学习

Break-It-Fix-It: Unsupervised Learning for Program Repair

Stanford University(斯坦福大学)

Michihiro Yasunaga, Percy Liang

摘要:

我们考虑修复任务:给定一个批评者(例如,编译器),其评估输入的质量,目标是训练将坏示例(例如,具有语法错误的代码)转换为好的代码(例如,没有语法错误的代码)。现有的工作通过使用统计学破坏好的示例来创建由(坏的,好的)对组成的训练数据(例如,丢弃令牌)。然而,在这种合成生成的数据上训练的修复者不能很好地外推到错误输入的真实分布。为了弥合这一差距,我们提出了一种新的训练方法,打破它,修复它(BIFI),它有两个关键的想法:(i)我们使用的评论家检查一个真正的坏输入修复器的输出,并添加良好的(固定)输出的训练数据,以及(ii)我们训练断路器从好代码生成现实的坏代码。基于这些想法,我们迭代地更新断路器和固定器,同时结合使用它们来生成更多的配对数据。我们在两个代码修复数据集上评估BIFI:GitHub-Python,我们引入的一个新数据集,目标是修复带有AST解析错误的Python代码; DeepFix,目标是修复带有编译器错误的C代码。BIFI优于现有方法,在GitHub-Python上获得90.5%的修复准确率(+28.5%),在DeepFix上获得71.7%(+5.6%)。值得注意的是,BIFI不需要任何标记数据;我们希望它将成为各种修复任务的无监督学习的一个强有力的起点。

英文摘要:

We consider repair tasks: given a critic (e.g., compiler) that assesses the quality of an input, the goal is to train a fixer that converts a bad example (e.g., code with syntax errors) into a good one (e.g., code with no syntax errors). Existing works create training data consisting of (bad, good) pairs by corrupting good examples using heuristics (e.g., dropping tokens). However, fixers trained on this synthetically-generated data do not extrapolate well to the real distribution of bad inputs. To bridge this gap, we propose a new training approach, Break-It-Fix-It (BIFI), which has two key ideas: (i) we use the critic to check a fixer's output on real bad inputs and add good (fixed) outputs to the training data, and (ii) we train a breaker to generate realistic bad code from good code. Based on these ideas, we iteratively update the breaker and the fixer while using them in conjunction to generate more paired data. We evaluate BIFI on two code repair datasets: GitHub-Python, a new dataset we introduce where the goal is to repair Python code with AST parse errors; and DeepFix, where the goal is to repair C code with compiler errors. BIFI outperforms existing methods, obtaining 90.5% repair accuracy on GitHub-Python (+28.5%) and 71.7% on DeepFix (+5.6%). Notably, BIFI does not require any labeled data; we hope it will be a strong starting point for unsupervised learning of various repair tasks.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑