[论文解读] Learning Structural Edits via Incremental Tree Transformations
本文提出了一种神经编辑器,通过迭代生成并应用树编辑操作(如添加、删除或复制子树),对树形结构数据(如代码的抽象语法树)执行增量式结构编辑。该方法引入了一种新型编辑编码器以表示编辑动作,并采用结合DaggerSampling和PostRefineSampling的动态模仿学习方法,在源代码编辑基准测试中实现了最先进性能,优于一次性生成模型。
While most neural generative models generate outputs in a single pass, the human creative process is usually one of iterative building and refinement. Recent work has proposed models of editing processes, but these mostly focus on editing sequential data and/or only model a single editing pass. In this paper, we present a generic model for incremental editing of structured data (i.e., "structural edits"). Particularly, we focus on tree-structured data, taking abstract syntax trees of computer programs as our canonical example. Our editor learns to iteratively generate tree edits (e.g., deleting or adding a subtree) and applies them to the partially edited data, thereby the entire editing process can be formulated as consecutive, incremental tree transformations. To show the unique benefits of modeling tree edits directly, we further propose a novel edit encoder for learning to represent edits, as well as an imitation learning method that allows the editor to be more robust. We evaluate our proposed editor on two source code edit datasets, where results show that, with the proposed edit encoder, our editor significantly improves accuracy over previous approaches that generate the edited program directly in one pass. Finally, we demonstrate that training our editor to imitate experts and correct its mistakes dynamically can further improve its performance.
研究动机与目标
- 将树形结构数据(如程序AST)的迭代式、结构性编辑建模为一系列增量树变换。
- 解决一次性生成模型直接输出编辑结果但未建模编辑过程的局限性。
- 基于抽象语法描述语言(ASDL)开发一种通用、语法有效且与语言无关的结构编辑框架。
- 通过新型编辑编码器和带错误纠正的动态模仿学习,提升鲁棒性和准确性。
- 在真实世界代码编辑数据集上验证增量编辑的有效性。
提出的方法
- 编辑器通过每一步生成并应用一个编辑动作(如添加、删除或复制子树)来执行迭代式树变换。
- 新型编辑编码器通过编码真实编辑动作序列来学习表示,而非压缩标记级差异或联合编码输入-输出对。
- 采用模仿学习训练编辑器以实现动态纠错,结合两种采样策略:DaggerSampling和PostRefineSampling。
- DaggerSampling通过混合系数β结合专家示范与自生成动作,实现基于反馈的纠正。
- PostRefineSampling通过在生成后对动作进行优化,提升稳定性,减少如重复添加-删除循环等振荡行为。
- 模型在两个代码编辑数据集上进行训练与评估,采用树形输出空间,通过ASDL确保语法正确性。
实验结果
研究问题
- RQ1增量树编辑是否能在结构化数据编辑任务中超越一次性生成方法?
- RQ2一种可学习的编辑编码器若能建模编辑序列,是否能提升编辑表示与性能?
- RQ3结合自纠正机制的动态模仿学习是否能稳定编辑过程并减少振荡行为?
- RQ4DaggerSampling中β的选择对编辑策略的稳定性和准确性有何影响?
- RQ5与DaggerSampling相比,PostRefineSampling是否能带来更稳定且更准确的编辑表现?
主要发现
- 所提出的编辑器结合新型编辑编码器,在代码编辑基准测试中显著优于以往的一次性生成模型。
- 采用模仿学习结合PostRefineSampling后,如重复添加-删除循环等不稳定行为的发生率降至不足0.5%,而β=0的DaggerSampling中该比例高达23%。
- 在DaggerSampling中将β设为0.5可降低振荡编辑的频率并提升准确性,表明其更有利于长期纠错学习。
- 即使仅使用20%的训练数据,模型仍表现出强大性能,显示出良好的样本效率。
- 编辑编码器优于基于标记级和联合编码的基线模型,证明了直接建模编辑序列的优势。
- 模型对未知标记和语法错误具有鲁棒性,剩余错误大多位于模型搜索空间之外。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。