LongCoder: A Long-Range Pre-trained Language Model for Code Completion

Daya Guo, Canwen Xu, Nan Duan, Jian Yin, Julian McAuley
6/26/2023
cs.SEcs.AIcs.CL

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

Abstract

In this paper, we introduce a new task for code completion that focuses on handling long code input and propose a sparse Transformer model, called LongCoder, to address this task. LongCoder employs a sliding window mechanism for self-attention and introduces two types of globally accessible tokens - bridge tokens and memory tokens - to improve performance and efficiency. Bridge tokens are inserted throughout the input sequence to aggregate local information and facilitate global interaction, while memory tokens are included to highlight important statements that may be invoked later and need to be memorized, such as package imports and definitions of classes, functions, or structures. We conduct experiments on a newly constructed dataset that contains longer code context and the publicly available CodeXGLUE benchmark. Experimental results demonstrate that LongCoder achieves superior performance on code completion tasks compared to previous models while maintaining comparable efficiency in terms of computational resources during inference. All the codes and data are available at https://github.com/microsoft/CodeBERT.

View on arXivView PDF

Code Implementations(1)

microsoft/CodeBERTOfficial100%
MIT

CodeBERT

2,786498Shell, PythonJun 17, 20203 years agoMIT

Similar Papers

Cite this paper

@article{guo2023longcoder,
  title  = {LongCoder: A Long-Range Pre-trained Language Model for Code Completion},
  author = {Daya Guo and Canwen Xu and Nan Duan and Jian Yin and Julian McAuley},
  year   = {2023},
  eprint = {2306.14893},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2306.14893v1},
  journal = {ICML 2023 2023}
}

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

Discussion