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

UniXcoder:统一的跨模态代码表示预训练

UniXcoder: Unified Cross-Modal Pre-training for Code Representation

Sun Yat-sen University(中山大学);Microsoft Research Asia(微软亚洲研究院);Langboat Technology(澜舟科技)

Daya Guo, Shuai Lu, Nan Duan, Yanlin Wang, Ming Zhou, Jian Yin

摘要:

程序设计语言的预训练模型最近在代码智能方面取得了巨大的成功。为了支持与代码相关的理解和生成任务,最近的工作试图预训练统一的编码器-解码器模型。然而,这种编码器-解码器框架对于自回归任务是次优的,特别是对于需要仅解码器方式以进行有效推断的代码完成。在本文中,我们提出了UniXcoder,一个统一的跨模态预训练模型的程序设计语言。该模型利用带有前缀适配器的掩码注意矩阵来控制模型的行为,并利用AST和代码注释等跨模态内容来增强代码表示。为了并行编码表示为树的AST,我们提出了一种一对一的映射方法来将AST转换为序列结构,该序列结构保留来自树的所有结构信息。此外,我们建议利用多模态内容来学习表示的代码片段的对比学习,然后对齐表示之间的程序设计语言使用跨模态生成任务。我们在九个数据集上对五个与代码相关的任务进行了评估。为了进一步评估代码片段表示的性能,我们还为一个新的任务构建了一个数据集,称为zero-shot代码到代码搜索。结果表明,我们的模型在大多数任务上都达到了最先进的性能,分析表明,注释和AST都可以增强UniXcoder。

英文摘要:

Pre-trained models for programming languages have recently demonstrated great success on code intelligence. To support both code-related understanding and generation tasks, recent works attempt to pre-train unified encoder-decoder models. However, such encoder-decoder framework is sub-optimal for auto-regressive tasks, especially code completion that requires a decoder-only manner for efficient inference. In this paper, we present UniXcoder, a unified cross-modal pre-trained model for programming language. The model utilizes mask attention matrices with prefix adapters to control the behavior of the model and leverages cross-modal contents like AST and code comment to enhance code representation. To encode AST that is represented as a tree in parallel, we propose a one-to-one mapping method to transform AST in a sequence structure that retains all structural information from the tree. Furthermore, we propose to utilize multi-modal contents to learn representation of code fragment with contrastive learning, and then align representations among programming languages using a cross-modal generation task. We evaluate UniXcoder on five code-related tasks over nine datasets. To further evaluate the performance of code fragment representation, we also construct a dataset for a new task, called zero-shot code-to-code search. Results show that our model achieves state-of-the-art performance on most tasks and analysis reveals that comment and AST can both enhance UniXcoder.

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

↑