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

Daya Guo, Shuai Lu, Nan Duan, Yanlin Wang, Ming Zhou +1 more
3/8/2022
1,212 citations
cs.CLcs.PLcs.SE

Official code: microsoft/CodeBERT (2,797 stars, Python, MIT, last commit 2023-07-09).

Abstract

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.

Show full abstract

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.

View on arXivView PDF

Code Implementations(1)

microsoft/CodeBERTOfficial100%
MIT

CodeBERT

2,797499Python, ShellJun 17, 20203 years agoMIT

Similar Papers

Cite this paper

@article{guo2022unixcoder,
  title  = {UniXcoder: Unified Cross-Modal Pre-training for Code Representation},
  author = {Daya Guo and Shuai Lu and Nan Duan and Yanlin Wang and Ming Zhou and Jian Yin},
  year   = {2022},
  eprint = {2203.03850},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.03850}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2203.03850.svg)](https://codeofpaper.com/paper/2203.03850)

Discussion