arXivDaily arXiv每日学术速递 周一至周五更新
北美退伍军人节(Veterans Day),12 日无更新
arXiv 2004.05249cs.SEcs.LGcs.PL
收藏

现代IDE中代码完成的序列模型设计

Sequence Model Design for Code Completion in the Modern IDE

Google Inc.(谷歌公司);Columbia University(哥伦比亚大学)

Gareth Ari Aye, Gail E. Kaiser

摘要:

代码完成在现代集成开发环境(IDE)中扮演着重要的角色。机器学习在类似的自然语言写作和搜索软件中已经无处不在,在更少的搜索次数中呈现更相关的自动完成和搜索建议。先前的研究已经报道了训练高精度、深度神经网络来对源代码进行建模,但是很少关注交互式开发工具所施加的实际约束。特别是,用于源代码建模的神经语言模型,如在Maybe Deep神经网络是建模源代码的最佳选择中描述的模型,是围绕代码完成构建的,但只报告下一个令牌预测的准确性。然而,为了使语言模型(LM)在真实世界的代码完成系统中良好地工作,它还必须始终提出建议,以产生有效的代码,这些代码类型转换以支持代码完成在正确性检查中的作用;返回即时结果以帮助程序员在更少的时间内更有效地编码;并且足够小,可以舒适地安装在开发人员工作站的磁盘和内存中,因为几乎所有现代IDE都在本地运行并支持脱机使用。为了满足这些额外的要求,我们提出了一种新的设计,预测前k个下一个令牌,结合静态分析的能力,列举所有有效的关键字和范围内的标识符与语言模型的能力,把一个概率分布在他们身上。我们的模型将字符级输入表示与令牌输出相结合,以有意义地表示词汇表外(OOV)令牌,并最大限度地减少预测延迟。OOV令牌可以通过检测软件中常见的局部重复来预测。这种设计在源代码建模方面达到了最先进的精度,并符合现代IDE中真实代码完成实现所施加的约束。

英文摘要:

Code completion plays a prominent role in modern integrated development environments (IDEs). Machine learning has become ubiquitous in analogous natural language writing and search software, surfacing more relevant autocompletions and search suggestions in fewer keystrokes. Prior research has reported training high-accuracy, deep neural networks for modeling source code, but little attention has been given to the practical constraints imposed by interactive developer tools. In particular, neural language models for source code modeling like the one described in Maybe Deep Neural Networks are the Best Choice for Modeling Source Code are framed around code completion, but only report accuracy of next-token prediction. However, in order for a language model (LM) to work well within real-world code completion systems, it must also always make suggestions that produce valid code that typechecks to support code completion's role in correctness-checking; return instantaneous results to help programmers code more efficiently in fewer keystrokes; and be small enough to fit comfortably on disk and in memory on developer workstations, since virtually all modern IDEs run locally and support offline usage. To meet these additional requirements, we propose a novel design for predicting top-k next tokens that combines static analysis' ability to enumerate all valid keywords and in-scope identifiers with the ability of a language model to place a probability distribution over them. Our model mixes character-level input representation with token output to represent out-of-vocabulary (OOV) tokens meaningfully and minimize prediction latency. OOV tokens can be predicted through detection of local repetition common in software. This design achieves state-of-art accuracy in source code modeling and fits the constraints imposed by real-world code completion implementations in modern IDEs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑