使用稀疏指针网络学习Python代码建议
Learning Python Code Suggestion with a Sparse Pointer Network
摘要:
为了提高开发人员的生产力,所有现代集成开发环境(IDE)都包括代码建议功能,该功能可以在光标处建议可能的下一个令牌。虽然当前的IDE对于静态类型语言工作得很好,但它们对类型注释的依赖意味着它们不能为动态规划语言提供与静态类型语言相同级别的支持。此外,现代IDE中的建议引擎不建议表达式或多语句惯用代码。最近的工作表明,语言模型可以通过从软件存储库中学习来改进代码建议系统。本文介绍了一种神经语言模型与稀疏指针网络,旨在捕捉非常长的距离依赖。我们发布了一个大规模的代码建议语料库,其中包含从GitHub抓取的4100万行Python代码。在这个语料库中,我们发现标准神经语言模型在提示局部现象方面表现良好,但在引用过去引入的许多标记的标识符时却很困难。通过使用专门引用预定义标识符类的指针网络来增强神经语言模型,与LSTM基线相比,我们获得了更低的困惑度和5个百分点的代码建议准确度。事实上,代码建议准确性的提高是由于对标识符的预测准确性提高了13倍。此外,定性分析表明,该模型确实捕获了有趣的长距离依赖关系,例如引用过去定义的超过60个标记的类成员。
英文摘要:
To enhance developer productivity, all modern integrated development environments (IDEs) include code suggestion functionality that proposes likely next tokens at the cursor. While current IDEs work well for statically-typed languages, their reliance on type annotations means that they do not provide the same level of support for dynamic programming languages as for statically-typed languages. Moreover, suggestion engines in modern IDEs do not propose expressions or multi-statement idiomatic code. Recent work has shown that language models can improve code suggestion systems by learning from software repositories. This paper introduces a neural language model with a sparse pointer network aimed at capturing very long-range dependencies. We release a large-scale code suggestion corpus of 41M lines of Python code crawled from GitHub. On this corpus, we found standard neural language models to perform well at suggesting local phenomena, but struggle to refer to identifiers that are introduced many tokens in the past. By augmenting a neural language model with a pointer network specialized in referring to predefined classes of identifiers, we obtain a much lower perplexity and a 5 percentage points increase in accuracy for code suggestion compared to an LSTM baseline. In fact, this increase in code suggestion accuracy is due to a 13 times more accurate prediction of identifiers. Furthermore, a qualitative analysis shows this model indeed captures interesting long-range dependencies, like referring to a class member defined over 60 tokens in the past.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。