当前位置: X-MOL 学术arXiv.cs.PL › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
A Structural Model for Contextual Code Changes
arXiv - CS - Programming Languages Pub Date : 2020-05-27 , DOI: arxiv-2005.13209
Shaked Brody, Uri Alon and Eran Yahav

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 a 28% relative gain over state-of-the-art sequential models and 2x higher accuracy than syntactic models that learn to generate the edited code, as opposed to modeling the edits directly. Our code, dataset, and trained models are publicly available at https://github.com/tech-srl/c3po/ .

中文翻译:

上下文代码更改的结构模型

我们解决了基于对过去编辑进行训练的学习模型来预测编辑完成的问题。给定部分编辑的代码片段,我们的目标是预测片段其余部分的编辑完成。我们将此任务称为 EditCompletion 任务,并提出了一种解决它的新方法。主要思想是直接表示结构编辑。这使我们可以对编辑本身的可能性进行建模,而不是学习已编辑代码的可能性。我们将编辑操作表示为程序抽象语法树 (AST) 中的一条路径,从编辑源到编辑目标。使用这种表示,我们为 EditCompletion 任务提供了一个强大而轻量级的神经模型。我们进行彻底的评估,将我们的方法与由多个强大模型(如 LSTM、Transformer 和神经 CRF)驱动的各种表示和建模方法进行比较。我们的实验表明,我们的模型比最先进的序列模型实现了 28% 的相对增益,并且比学习生成编辑代码的句法模型高 2 倍的准确性,而不是直接对编辑进行建模。我们的代码、数据集和经过训练的模型可在 https://github.com/tech-srl/c3po/ 上公开获得。
更新日期:2020-10-13
down
wechat
bug