学习用草图完成代码
Learning to Complete Code with Sketches
摘要:
代码完成通常被转换为语言建模问题,即,以从左到右的方式继续输入。然而,在实践中,完成的某些部分(例如,字符串字面值)可能很难预测,而后续部分直接从上下文中得出。为了解决这个问题,我们考虑在模型不确定的地方插入“洞”来生成代码补全的场景。我们开发Grammformer,一个基于转换器的模型,引导代码生成的程序设计语言语法,并比较它的各种更标准的序列模型。我们训练模型的代码完成C#和Python给定的部分代码上下文。为了评估模型,我们考虑了ROUGE以及一个新的度量RegexAcc,该度量衡量了生成与尽可能少的孔匹配的长产出的完井的成功。在我们的实验中,与传统的生成模型相比,Grammformer生成的完成准确率高出10-50%,与使用类似技术训练的草图生成基线相比,草图长出37-50%。
英文摘要:
Code completion is usually cast as a language modelling problem, i.e., continuing an input in a left-to-right fashion. However, in practice, some parts of the completion (e.g., string literals) may be very hard to predict, whereas subsequent parts directly follow from the context. To handle this, we instead consider the scenario of generating code completions with "holes" inserted in places where a model is uncertain. We develop Grammformer, a Transformer-based model that guides code generation by the programming language grammar, and compare it to a variety of more standard sequence models. We train the models on code completion for C# and Python given partial code context. To evaluate models, we consider both ROUGE as well as a new metric RegexAcc that measures success of generating completions matching long outputs with as few holes as possible. In our experiments, Grammformer generates 10-50% more accurate completions compared to traditional generative models and 37-50% longer sketches compared to sketch-generating baselines trained with similar techniques.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。