Tackling Long Code Search with Splitting, Encoding, and Aggregating

Fuente: arXiv
Salvato in:
Dettagli Bibliografici
Autori principali: Hu, Fan, Wang, Yanlin, Du, Lun, Zhang, Hongyu, Han, Shi, Zhang, Dongmei, Li, Xirong
Natura: Preprint
Pubblicazione: 2022
Soggetti:
Accesso online:
Tags: Aggiungi Tag
Nessun Tag, puoi essere il primo ad aggiungerne!!
_version_ 1866910383456911360
author Hu, Fan
Wang, Yanlin
Du, Lun
Zhang, Hongyu
Han, Shi
Zhang, Dongmei
Li, Xirong
author_facet Hu, Fan
Wang, Yanlin
Du, Lun
Zhang, Hongyu
Han, Shi
Zhang, Dongmei
Li, Xirong
contents Code search with natural language helps us reuse existing code snippets. Thanks to the Transformer-based pretraining models, the performance of code search has been improved significantly. However, due to the quadratic complexity of multi-head self-attention, there is a limit on the input token length. For efficient training on standard GPUs like V100, existing pretrained code models, including GraphCodeBERT, CodeBERT, RoBERTa (code), take the first 256 tokens by default, which makes them unable to represent the complete information of long code that is greater than 256 tokens. To tackle the long code problem, we propose a new baseline SEA (Split, Encode and Aggregate), which splits long code into code blocks, encodes these blocks into embeddings, and aggregates them to obtain a comprehensive long code representation. With SEA, we could directly use Transformer-based pretraining models to model long code without changing their internal structure and re-pretraining. We also compare SEA with sparse Trasnformer methods. With GraphCodeBERT as the encoder, SEA achieves an overall mean reciprocal ranking score of 0.785, which is 10.1% higher than GraphCodeBERT on the CodeSearchNet benchmark, justifying SEA as a strong baseline for long code search. Our source code and experimental data are available at: https://github.com/fly-dragon211/SEA.
format Preprint
id arxiv_https___arxiv_org_abs_2208_11271
institution arXiv
publishDate 2022
record_format arxiv
spellingShingle Tackling Long Code Search with Splitting, Encoding, and Aggregating
Hu, Fan
Wang, Yanlin
Du, Lun
Zhang, Hongyu
Han, Shi
Zhang, Dongmei
Li, Xirong
Software Engineering
Code search with natural language helps us reuse existing code snippets. Thanks to the Transformer-based pretraining models, the performance of code search has been improved significantly. However, due to the quadratic complexity of multi-head self-attention, there is a limit on the input token length. For efficient training on standard GPUs like V100, existing pretrained code models, including GraphCodeBERT, CodeBERT, RoBERTa (code), take the first 256 tokens by default, which makes them unable to represent the complete information of long code that is greater than 256 tokens. To tackle the long code problem, we propose a new baseline SEA (Split, Encode and Aggregate), which splits long code into code blocks, encodes these blocks into embeddings, and aggregates them to obtain a comprehensive long code representation. With SEA, we could directly use Transformer-based pretraining models to model long code without changing their internal structure and re-pretraining. We also compare SEA with sparse Trasnformer methods. With GraphCodeBERT as the encoder, SEA achieves an overall mean reciprocal ranking score of 0.785, which is 10.1% higher than GraphCodeBERT on the CodeSearchNet benchmark, justifying SEA as a strong baseline for long code search. Our source code and experimental data are available at: https://github.com/fly-dragon211/SEA.
title Tackling Long Code Search with Splitting, Encoding, and Aggregating
topic Software Engineering
url https://arxiv.org/abs/2208.11271