[论文解读] Neural Edit Completion.
本文提出了一种新颖的神经方法用于编辑补全(EditCompletion)任务,将代码结构化编辑建模为程序抽象语法树(AST)中的路径,直接预测代码编辑补全。该方法相较于最先进序列模型实现了28%的相对性能提升,且在准确率上是生成编辑后代码而非直接建模编辑本身的语法模型的两倍。
We address the problem of predicting edit completions based on a learned model that was trained on past edits. Given a code snippet that is partially edited, our goal is to predict a completion of the edit for the rest of the snippet. We refer to this task as the EditCompletion task and present a novel approach for tackling it. The main idea is to directly represent structural edits. This allows us to model the likelihood of the edit itself, rather than learning the likelihood of the edited code. We represent an edit operation as a path in the program's Abstract Syntax Tree (AST), originating from the source of the edit to the target of the edit. Using this representation, we present a powerful and lightweight neural model for the EditCompletion task. We conduct a thorough evaluation, comparing our approach to a variety of representation and modeling approaches that are driven by multiple strong models such as LSTMs, Transformers, and neural CRFs. Our experiments show that our model achieves 28% relative gain over state-of-the-art sequential models and 2$ imes$ higher accuracy than syntactic models that learn to generate the edited code instead of modeling the edits directly. We make our code, dataset, and trained models publicly available.
研究动机与目标
- 为解决部分编辑代码片段的补全预测挑战。
- 直接建模编辑操作的可能性,而非建模生成编辑后代码的可能性。
- 通过在抽象语法树(AST)中表示编辑为结构化路径,提升编辑预测的准确性。
- 开发一种轻量级但强大的神经模型,以有效捕捉编辑语义。
- 在编辑补全任务上超越现有的序列模型和语法建模方法。
提出的方法
- 将每次编辑表示为程序抽象语法树(AST)中从源节点到目标节点的路径。
- 训练神经模型,基于AST路径表示来预测编辑的补全。
- 使用序列建模架构(如LSTM、Transformer或CRF)处理AST路径,并预测剩余的编辑内容。
- 直接学习编辑的可能性,避免生成完整编辑后代码的需求。
- 利用AST中的结构信息以提升泛化能力和准确性。
- 设计一种轻量级模型,在计算开销最小化的同时保持高性能。
实验结果
研究问题
- RQ1将编辑操作建模为AST路径是否能提升相对于基于序列模型的编辑补全预测性能?
- RQ2直接建模编辑可能性是否优于那些生成编辑后代码的模型?
- RQ3所提出方法在编辑补全任务上与最先进序列模型和语法模型相比表现如何?
- RQ4基于AST的结构化表示在多大程度上提升了预测准确性?
- RQ5轻量级神经模型是否能在编辑补全任务上实现优越性能?
主要发现
- 所提模型在编辑补全任务上相较于最先进序列模型实现了28%的相对性能提升。
- 其准确率是学习生成编辑后代码而非直接建模编辑的语法模型的两倍。
- 该模型通过使用AST路径直接建模编辑可能性,展现出卓越的性能。
- 该方法在编辑补全预测中优于强大的序列模型(如LSTM、Transformer)和语法模型。
- 该模型轻量且高效,适用于代码编辑工具中的实际部署。
- 代码、数据集和训练好的模型已公开发布,以支持可复现性与进一步研究。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。