arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2012.14631cs.SE
收藏

基于多任务学习的预训练语言模型的代码自动完成

Multi-task Learning based Pre-trained Language Model for Code Completion

Fang Liu, Ge Li, Yunfei Zhao, Zhi Jin

摘要:

代码补全是集成开发环境(IDE)中最有用的功能之一,它可以通过基于上下文代码实时建议下一个可能的令牌来加速软件开发。最近的研究表明,统计语言建模技术可以提高代码完成工具的性能,通过学习大规模的软件存储库。然而,这些模型有两个主要缺点:a)现有的研究使用静态嵌入,将单词映射到相同的向量,而不管其上下文。当每个令牌与单个表示相关联时,令牌在不同上下文中的含义的差异被丢失; b)现有的基于语言模型的代码完成模型在完成标识符方面表现不佳,并且标识符的类型信息在大多数这些模型中被忽略。为了应对这些挑战,在本文中,我们开发了一个基于多任务学习的预训练语言模型,用于代码理解和代码生成,并使用基于transformer的神经架构。我们使用混合目标函数对它进行预训练,该目标函数包含代码理解和代码生成任务。然后,我们在代码完成上微调预训练模型。在完成过程中,我们的模型不直接预测下一个令牌。相反,我们采用多任务学习来联合预测token及其类型,并利用预测的类型来辅助token预测。在两个真实数据集上的实验结果表明,与现有的方法相比,我们的模型是有效的。

英文摘要:

Code completion is one of the most useful features in the Integrated Development Environments (IDEs), which can accelerate software development by suggesting the next probable token based on the contextual code in real-time. Recent studies have shown that statistical language modeling techniques can improve the performance of code completion tools through learning from large-scale software repositories. However, these models suffer from two major drawbacks: a) Existing research uses static embeddings, which map a word to the same vector regardless of its context. The differences in the meaning of a token in varying contexts are lost when each token is associated with a single representation; b) Existing language model based code completion models perform poor on completing identifiers, and the type information of the identifiers is ignored in most of these models. To address these challenges, in this paper, we develop a multi-task learning based pre-trained language model for code understanding and code generation with a Transformer-based neural architecture. We pre-train it with hybrid objective functions that incorporate both code understanding and code generation tasks. Then we fine-tune the pre-trained model on code completion. During the completion, our model does not directly predict the next token. Instead, we adopt multi-task learning to predict the token and its type jointly and utilize the predicted type to assist the token prediction. Experiments results on two real-world datasets demonstrate the effectiveness of our model when compared with state-of-the-art methods.

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

↑