SparseCoder: Advancing Source Code Analysis with Sparse Attention and Learned Token Pruning

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Yang, Xueqi, Jakubowski, Mariusz, Kang, Li, Yu, Haojie, Menzies, Tim
Format: Preprint
Published: 2023
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866917774200143872
author Yang, Xueqi
Jakubowski, Mariusz
Kang, Li
Yu, Haojie
Menzies, Tim
author_facet Yang, Xueqi
Jakubowski, Mariusz
Kang, Li
Yu, Haojie
Menzies, Tim
contents As software projects rapidly evolve, software artifacts become more complex and defects behind get harder to identify. The emerging Transformer-based approaches, though achieving remarkable performance, struggle with long code sequences due to their self-attention mechanism, which scales quadratically with the sequence length. This paper introduces SparseCoder, an innovative approach incorporating sparse attention and learned token pruning (LTP) method (adapted from natural language processing) to address this limitation. Compared to previous state-of-the-art models CodeBERT, RoBERTa, and CodeT5, our experiments demonstrate that SparseCoder can handle significantly longer input sequences--at least twice as long, within the limits of our hardware resources and data statistics. Additionally, SparseCoder is four times faster than other methods measured in runtime, achieving a 50% reduction in floating point operations per second (FLOPs) with a negligible performance drop of less than 1% compared to Transformers using sparse attention (Sparse Atten). Plotting FLOPs of model inference against token lengths reveals that SparseCoder scales linearly, whereas other methods, including the current state-of-the-art model CodeT5, scale quadratically. Moreover, SparseCoder enhances interpretability by visualizing non-trivial tokens layer-wise.
format Preprint
id arxiv_https___arxiv_org_abs_2310_07109
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle SparseCoder: Advancing Source Code Analysis with Sparse Attention and Learned Token Pruning
Yang, Xueqi
Jakubowski, Mariusz
Kang, Li
Yu, Haojie
Menzies, Tim
Software Engineering
As software projects rapidly evolve, software artifacts become more complex and defects behind get harder to identify. The emerging Transformer-based approaches, though achieving remarkable performance, struggle with long code sequences due to their self-attention mechanism, which scales quadratically with the sequence length. This paper introduces SparseCoder, an innovative approach incorporating sparse attention and learned token pruning (LTP) method (adapted from natural language processing) to address this limitation. Compared to previous state-of-the-art models CodeBERT, RoBERTa, and CodeT5, our experiments demonstrate that SparseCoder can handle significantly longer input sequences--at least twice as long, within the limits of our hardware resources and data statistics. Additionally, SparseCoder is four times faster than other methods measured in runtime, achieving a 50% reduction in floating point operations per second (FLOPs) with a negligible performance drop of less than 1% compared to Transformers using sparse attention (Sparse Atten). Plotting FLOPs of model inference against token lengths reveals that SparseCoder scales linearly, whereas other methods, including the current state-of-the-art model CodeT5, scale quadratically. Moreover, SparseCoder enhances interpretability by visualizing non-trivial tokens layer-wise.
title SparseCoder: Advancing Source Code Analysis with Sparse Attention and Learned Token Pruning
topic Software Engineering
url https://arxiv.org/abs/2310.07109