paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Multi-task learning based pre-trained language model for code completion

基于多任务学习的代码补全预训练语言模型
ASE Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering2020匹配度 2/10 · 论文虽属机器学习与程序语言交叉,但聚焦代码补全的预训练模型,未涉及用户关注的静态分析、形式化验证、浮点/贝叶斯程序分析或LLM/Agent在程序分析中的应用,匹配度低。引用 164 inbox
Fang Liu, Ge Li, Yunfei Zhao, Zhi Jin
crossref: 2026-09-12

AI 速览

一句话:提出基于 Transformer 的多任务预训练语言模型,联合预测下一个 token 及其类型以提升代码补全性能。

代码补全是 IDE 中最实用的功能之一,可基于上下文实时建议下一个可能的 token。已有基于统计语言模型的方法虽能从大规模代码库中学习,但存在两个问题:一是使用静态词嵌入,同一 token 在不同上下文中共享同一向量,丢失了语义差异;二是这些模型在补全标识符时表现较差,且大多忽略了标识符的类型信息。本文提出一个面向代码理解与代码生成的预训练语言模型,采用 Transformer 架构,使用融合代码理解与代码生成任务的混合目标函数进行预训练,再在代码补全任务上微调。补全时模型并不直接预测下一个 token,而是通过多任务学习联合预测 token 及其类型,并利用预测出的类型辅助 token 预测。在两个真实数据集上的实验结果表明,该模型优于当时的最先进方法。

问题
现有基于统计语言模型的代码补全方法使用静态词嵌入,无法刻画 token 在不同上下文中的语义差异;同时补全标识符的能力不足,且普遍忽略标识符的类型信息。
方法
构建基于 Transformer 的预训练语言模型,以融合代码理解与代码生成的混合目标进行预训练,并在代码补全微调阶段采用多任务学习,联合预测下一个 token 与其类型,用类型预测辅助 token 预测。
评估
在两个真实世界的代码数据集上进行实验,并与当时的最先进方法进行比较,验证模型在代码补全上的有效性。
原文摘要(Abstract)

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.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot5885,
  title = {Multi-task learning based pre-trained language model for code completion},
  author = {Fang Liu and Ge Li and Yunfei Zhao and Zhi Jin},
  booktitle = {ASE},
  year = {2020},
  doi = {10.1145/3324884.3416591}
}