arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2105.12485cs.LGcs.PL
收藏

TreeBERT:一种基于树的程序设计语言预训练模型

TreeBERT: A Tree-Based Pre-Trained Model for Programming Language

Shandong Normal University(山东师范大学);Nanjing University of Science and Technology(南京理工大学)

Xue Jiang, Zhuoran Zheng, Chen Lyu, Liang Li, Lei Lyu

摘要:

源代码可以根据定义的语法规则解析成抽象语法树(AST)。然而,在预训练中,很少有工作考虑将树结构纳入学习过程。在本文中,我们提出了TreeBERT,一个基于树的预训练模型,用于改进面向程序设计语言的生成任务。为了利用树结构,TreeBERT将代码对应的AST表示为一组合成路径,并引入节点位置嵌入。该模型通过树掩码语言建模(TMLM)和节点顺序预测(NOP)的混合目标进行训练。TLM使用一种新的屏蔽策略,根据树的特点设计,以帮助模型理解AST和推断AST的语义缺失。通过NOP,TreeBERT通过学习AST中节点的顺序约束来提取语法结构。我们在涵盖多种程序设计语言的数据集上预训练了TreeBERT。在代码总结和代码文档任务方面,TreeBERT优于其他预训练模型和为这些任务设计的最先进模型。此外,TreeBERT在转移到预先训练的看不见的程序设计语言时表现良好。

英文摘要:

Source code can be parsed into the abstract syntax tree (AST) based on defined syntax rules. However, in pre-training, little work has considered the incorporation of tree structure into the learning process. In this paper, we present TreeBERT, a tree-based pre-trained model for improving programming language-oriented generation tasks. To utilize tree structure, TreeBERT represents the AST corresponding to the code as a set of composition paths and introduces node position embedding. The model is trained by tree masked language modeling (TMLM) and node order prediction (NOP) with a hybrid objective. TMLM uses a novel masking strategy designed according to the tree's characteristics to help the model understand the AST and infer the missing semantics of the AST. With NOP, TreeBERT extracts the syntactical structure by learning the order constraints of nodes in AST. We pre-trained TreeBERT on datasets covering multiple programming languages. On code summarization and code documentation tasks, TreeBERT outperforms other pre-trained models and state-of-the-art models designed for these tasks. Furthermore, TreeBERT performs well when transferred to the pre-trained unseen programming language.

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

↑