[论文解读] A Controlled Experiment of Different Code Representations for Learning-Based Bug Repair
本文通过受控实验评估了21种不同的代码表示法和嵌入方法在基于深度学习的程序修复中的表现,重点关注名称相关的错误。研究发现,虽然更高层级的抽象能提升模型准确率,但会降低开发者对修复结果的感知实用性,且混合(异构)表示法优于同质表示法,凸显了在修复工具设计中需兼顾开发者可用性的重要性。
Training a deep learning model on source code has gained significant traction recently. Since such models reason about vectors of numbers, source code needs to be converted to a code representation before vectorization. Numerous approaches have been proposed to represent source code, from sequences of tokens to abstract syntax trees. However, there is no systematic study to understand the effect of code representation on learning performance. Through a controlled experiment, we examine the impact of various code representations on model accuracy and usefulness in deep learning-based program repair. We train 21 different generative models that suggest fixes for name-based bugs, including 14 different homogeneous code representations, four mixed representations for the buggy and fixed code, and three different embeddings. We assess if fix suggestions produced by the model in various code representations are automatically patchable, meaning they can be transformed to a valid code that is ready to be applied to the buggy code to fix it. We also conduct a developer study to qualitatively evaluate the usefulness of inferred fixes in different code representations. Our results highlight the importance of code representation and its impact on learning and usefulness. Our findings indicate that (1) while code abstractions help the learning process, they can adversely impact the usefulness of inferred fixes from a developer's point of view; this emphasizes the need to look at the patches generated from the practitioner's perspective, which is often neglected in the literature, (2) mixed representations can outperform homogeneous code representations, (3) bug type can affect the effectiveness of different code representations; although current techniques use a single code representation for all bug types, there is no single best code representation applicable to all bug types.
研究动机与目标
- 系统评估多样化代码表示法与嵌入方法对基于学习的程序修复准确率及修复实用性的影响。
- 探究使用更高层级抽象是否以降低开发者可用性为代价提升模型性能。
- 探索混合表示法(对错误代码和修复后代码使用不同表示法)相较于同质表示法的有效性。
- 通过开发者研究评估生成修复的感知实用性,弥补现有文献中常忽视实践者视角的空白。
- 提供一个可复用的基准框架 Reptory,以支持未来在基于深度学习的修复中对代码表示法的对比研究。
提出的方法
- 该研究使用14种同质代码表示法、4种混合表示法(错误代码与修复后代码使用不同表示法)以及3种嵌入方法,训练了21种不同的生成模型。
- 代码表示法包括标记序列、AST遍历以及基于抽象语法树(AST)路径的编码,涵盖原始形式与抽象化形式。
- 模型在包含真实世界名称错误(如参数互换、错误操作符)的现实数据集上进行训练,每类错误均有超过12万条数据点。
- 通过自动可修复性(即生成的修复能否被自动转换为有效且可编译的代码)来评估模型性能。
- 开展定性开发者研究,评估不同表示法下生成修复的感知实用性。
- 开发了一个名为 Reptory 的框架,以支持在程序修复中对代码表示法进行可复现的对比实验。
实验结果
研究问题
- RQ1不同代码表示法如何影响基于学习的程序修复中生成修复的准确率与可修复性?
- RQ2相较于同质表示法,使用异构代码表示法(错误代码与修复后代码使用不同表示法)在多大程度上提升了修复性能?
- RQ3代码表示法的抽象层级在多大程度上影响了开发者对修复结果的感知实用性?
- RQ4嵌入方法的选择是否显著影响不同错误类型下生成修复的质量?
- RQ5是否存在针对特定错误类型的最优代码表示法,还是存在一种适用于所有错误类型的通用最优表示法?
主要发现
- 修复错误二元操作数的模型准确率最高,达到99.996%,使用EID(Opnd)-20表示法;修复错误二元操作符的准确率为99.977%,使用EID(Oprt)-20表示法;修复参数互换错误的准确率为99.964%,使用EID(SA)-20表示法。
- 更高层级的抽象提升了模型准确率,但降低了开发者在评估中对修复结果的感知实用性,表明性能与实际可用性之间存在权衡。
- 混合表示法(即对错误代码与修复后代码使用不同表示法)在所有情况下均优于同质表示法,表明其更有效地建模了修复转换过程。
- 研究未发现适用于所有错误类型的单一最优代码表示法,其有效性在不同错误类别间差异显著。
- 有损或抽象化的表示法虽在生成可修复代码方面准确率较低,但仍能为开发者提供有用的调试提示,表明其价值不仅限于自动可修复性。
- Reptory 框架支持可复现的对比实验,已作为未来研究中代码表示法在程序修复领域应用的基准发布。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。