Accelerating Code Search with Deep Hashing and Code Classification
39196Authors
nan
Abstract
AbstractCode search is to search reusable code snippets from source code corpus based on natural languages queries. Deep learning-based methods on code search have shown promising results. However, previous methods focus on retrieval accuracy, but lacked attention to the efficiency of the retrieval process. We propose a novel method CoSHC to accelerate code search with deep hashing and code classification, aiming to perform efficient code search without sacrificing too much accuracy. To evaluate the effectiveness of CoSHC, we apply our methodon five code search models. Extensive experimental results indicate that compared with previous code search baselines, CoSHC can save more than 90% of retrieval time meanwhile preserving at least 99% of retrieval accuracy.
Keywords
Full Content
Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics Volume 1: Long Papers, pages 2534 - 2544 May 22-27, 2022 c⃝2022 Association for Computational Linguistics Accelerating Code Search with Deep Hashing and Code Classification Wenchao Gu1∗, Yanlin Wang2,†, Lun Du2, Hongyu Zhang3, Shi Han2, Dongmei Zhang2, and Michael R. Lyu1 1 Department of Computer Science and Engineering, The Chinese University of Hong Kong, China. 2 Microsoft Research Asia, Beijing, China 3 The University of Newcastle, Australia Abstract Code search is to search reusable code snippets from source code corpus based on natural lan- guages queries. Deep learning-based methods on code search have shown promising results. However, previous methods focus on retrieval accuracy, but lacked attention to the efficiency of the retrieval process. We propose a novel method CoSHC to accelerate code search with deep hashing and code classification, aiming to perform efficient code search without sacri- ficing too much accuracy. To evaluate the ef- fectiveness of CoSHC, we apply our method on five code search models. Extensive experi- mental results indicate that compared with pre- vious code search baselines, CoSHC can save more than 90% of retrieval time meanwhile preserving at least 99% of retrieval accuracy. 1 Introduction Code reuse is a common practice during software development process. It improves programming productivity as developers’ time and energy can be saved by reusing existing code. According to pre- vious studies (Brandt et al., 2009; Lv et al., 2015), many developers tend to use natural language to describe the functionality of desired code snippets and search the Internet/code corpus for code reuse. Many code search approaches (Brandt et al., 2009; McMillan et al., 2011; Lv et al., 2015; Du et al., 2021) have been proposed over the years. With the rapid growth of open source code bases and the development of deep learning technology, recently deep learning based approaches have be- come popular for tackling the code search prob- lem (Gu et al., 2018; Husain et al., 2019; Gu et al., 2021). Some of these approaches adopt neural network models to encode source code and query descriptions into representation vectors in the same ∗ Work done while this author was an intern at Microsoft Research. Wenchao Gu (wcgu@cse.cuhk.edu.hk). † Yanlin Wang is the corresponding author (yanl- wang@microsoft.com). embedding space. The distance between the repre- sentation vectors whose original code or descrip- tion are semantically similar should be small. Other approaches (Feng et al., 2020; Guo et al., 2021; Du et al., 2021) regard the code search task as a binary classification task, and calculate the probability of code matching the query. In the past, deep learning-based methods focused on retrieval accuracy, but lacked attention to the efficiency of retrieval on large-scale code corpus. However, both types of these deep learning-based approaches directly rank all the source code snip- pets in the corpus during searching, which will incur a large amount of computational cost. For the approaches that separately encode code and de- scription representation vectors, the similarity of the …
Content truncated to 500 words
Labeled Text
AbstractCode search is to search reusable code snippets from source code corpus based on natural languages queries. Deep learning-based methods on code search have shown promising results. However, previous methods focus on retrieval accuracy, but lacked attention to the efficiency of the retrieval process. We propose a novel method CoSHC to accelerate code search with deep hashing and code classification, aiming to perform efficient code search without sacrificing too much accuracy. To evaluate the effectiveness of CoSHC, we apply our methodon five code search models. Extensive experimental results indicate that compared with previous code search baselines, CoSHC can save more than 90% of retrieval time meanwhile preserving at least 99% of retrieval accuracy.
Publication Details
- Paper ID:
- 39196
- Year:
- 2022
- Publication:
- TIPSTER
- Publication Type:
- conf
- DOI:
- nan