SPT-Code: Sequence-to-Sequence Pre-Training for Learning Source Code Representations

Changan Niu, Chuanyi Li, Vincent Ng, Jidong Ge, Liguo Huang +1 more
1/5/2022
cs.SE

Official code: NougatCA/SPT-Code (49 stars, Python, MIT, last commit 2026-09-06).

Abstract

Recent years have seen the successful application of large pre-trained models to code representation learning, resulting in substantial improvements on many code-related downstream tasks. But there are issues surrounding their application to SE tasks.

Show full abstract

First, the majority of the pre-trained models focus on pre-training only the encoder of the Transformer. For generation tasks that are addressed using models with the encoder-decoder architecture, however, there is no reason why the decoder should be left out during pre-training. Second, many existing pre-trained models, including state-of-the-art models such as T5-learning, simply reuse the pre-training tasks designed for natural languages. Moreover, to learn the natural language description of source code needed eventually for code-related tasks such as code summarization, existing pre-training tasks require a bilingual corpus composed of source code and the associated natural language description, which severely limits the amount of data for pre-training. To this end, we propose SPT-Code, a sequence-to-sequence pre-trained model for source code. In order to pre-train SPT-Code in a sequence-to-sequence manner and address the aforementioned weaknesses associated with existing pre-training tasks, we introduce three pre-training tasks that are specifically designed to enable SPT-Code to learn knowledge of source code, the corresponding code structure, as well as a natural language description of the code without relying on any bilingual corpus, and eventually exploit these three sources of information when it is applied to downstream tasks. Experimental results demonstrate that SPT-Code achieves state-of-the-art performance on five code-related downstream tasks after fine-tuning.

View on arXivView PDF

Code Implementations(1)

NougatCA/SPT-CodeOfficial100%
MIT
497Python, ANTLRJul 5, 20212 months agoMIT

Similar Papers

Cite this paper

@article{niu2022sptcode,
  title  = {SPT-Code: Sequence-to-Sequence Pre-Training for Learning Source Code Representations},
  author = {Changan Niu and Chuanyi Li and Vincent Ng and Jidong Ge and Liguo Huang and Bin Luo},
  year   = {2022},
  eprint = {2201.01549},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2201.01549}
}

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/2201.01549.svg)](https://codeofpaper.com/paper/2201.01549)

Discussion