English

Understanding Long Programming Languages with Structure-Aware Sparse Attention

Computation and Language 2022-05-30 v1 Artificial Intelligence

Abstract

Programming-based Pre-trained Language Models (PPLMs) such as CodeBERT have achieved great success in many downstream code-related tasks. Since the memory and computational complexity of self-attention in the Transformer grow quadratically with the sequence length, PPLMs typically limit the code length to 512. However, codes in real-world applications are generally long, such as code searches, which cannot be processed efficiently by existing PPLMs. To solve this problem, in this paper, we present SASA, a Structure-Aware Sparse Attention mechanism, which reduces the complexity and improves performance for long code understanding tasks. The key components in SASA are top-kk sparse attention and Abstract Syntax Tree (AST)-based structure-aware attention. With top-kk sparse attention, the most crucial attention relation can be obtained with a lower computational cost. As the code structure represents the logic of the code statements, which is a complement to the code sequence characteristics, we further introduce AST structures into attention. Extensive experiments on CodeXGLUE tasks show that SASA achieves better performance than the competing baselines.

Keywords

Cite

@article{arxiv.2205.13730,
  title  = {Understanding Long Programming Languages with Structure-Aware Sparse Attention},
  author = {Tingting Liu and Chengyu Wang and Cen Chen and Ming Gao and Aoying Zhou},
  journal= {arXiv preprint arXiv:2205.13730},
  year   = {2022}
}

Comments

sigir 2022 accepted, code will be available at https://github.com/alibaba/EasyNLP

R2 v1 2026-06-24T11:30:26.799Z