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.
翻译:代码完成通常是一个语言建模问题, 也就是说, 继续以左对右的方式输入。 但是, 实际上, 完成的部分( 如字符串字典) 可能很难预测, 而随后的部分直接随上下文而来。 要解决这个问题, 我们考虑在模型不确定的地方用“ 洞” 插入“ 洞” 生成代码完成的假想。 我们开发了基于 Grammerxe 的变异器模型, 通过编程语言语法来指导代码生成, 并将其与各种更标准的序列模型进行比较。 我们培训了 C# 和 Python 的代码完成模型, 并给部分代码环境做了部分代码背景。 为了评估模型, 我们考虑将 ROUGE 和 新的 Time RegexAcc 都作为衡量完成成功率的衡量标准, 与尽可能少的孔相匹配。 在我们的实验中, 格拉姆xw 生成了10- 50% 的精确完成率比传统的谱化模型要高10- 50%, 和37- 50% 50% 的素描图比以类似技术训练的素制作基线要长 。