当前位置: X-MOL 学术arXiv.cs.SE › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Learning to Generate Code Sketches
arXiv - CS - Software Engineering Pub Date : 2021-06-18 , DOI: arxiv-2106.10158
Daya Guo, Alexey Svyatkovskiy, Jian Yin, Nan Duan, Marc Brockschmidt, Miltiadis Allamanis

Traditional generative models are limited to predicting sequences of terminal tokens. However, ambiguities in the generation task may lead to incorrect outputs. Towards addressing this, we introduce Grammformers, transformer-based grammar-guided models that learn (without explicit supervision) to generate sketches -- sequences of tokens with holes. Through reinforcement learning, Grammformers learn to introduce holes avoiding the generation of incorrect tokens where there is ambiguity in the target task. We train Grammformers for statement-level source code completion, i.e., the generation of code snippets given an ambiguous user intent, such as a partial code context. We evaluate Grammformers on code completion for C# and Python and show that it generates 10-50% more accurate sketches compared to traditional generative models and 37-50% longer sketches compared to sketch-generating baselines trained with similar techniques.

中文翻译:

学习生成代码草图

传统的生成模型仅限于预测终端令牌的序列。然而,生成任务中的歧义可能会导致不正确的输出。为了解决这个问题,我们引入了 Grammformers,这是一种基于转换器的语法引导模型,可以学习(没有明确的监督)来生成草图——有孔的标记序列。通过强化学习,Grammformers 学会引入漏洞,避免在目标任务中存在歧义的情况下生成不正确的标记。我们训练 Grammformers 进行语句级源代码完成,即在给定不明确的用户意图(例如部分代码上下文)的情况下生成代码片段。
更新日期:2021-06-25
down
wechat
bug