COSEA: Convolutional Code Search with Layer-wise Attention

10/19/2020
by   Hao Wang, et al.
16

Semantic code search, which aims to retrieve code snippets relevant to a given natural language query, has attracted many research efforts with the purpose of accelerating software development. The huge amount of online publicly available code repositories has prompted the employment of deep learning techniques to build state-of-the-art code search models. Particularly, they leverage deep neural networks to embed codes and queries into a unified semantic vector space and then use the similarity between code's and query's vectors to approximate the semantic correlation between code and the query. However, most existing studies overlook the code's intrinsic structural logic, which indeed contains a wealth of semantic information, and fails to capture intrinsic features of codes. In this paper, we propose a new deep learning architecture, COSEA, which leverages convolutional neural networks with layer-wise attention to capture the valuable code's intrinsic structural logic. To further increase the learning efficiency of COSEA, we propose a variant of contrastive loss for training the code search model, where the ground-truth code should be distinguished from the most similar negative sample. We have implemented a prototype of COSEA. Extensive experiments over existing public datasets of Python and SQL have demonstrated that COSEA can achieve significant improvements over state-of-the-art methods on code search tasks.

READ FULL TEXT

page 1

page 9

research
10/24/2020

Deep Graph Matching and Searching for Semantic Code Retrieval

Code retrieval is to find the code snippet from a large corpus of source...
research
03/15/2022

CSRS: Code Search with Relevance Matching and Semantic Matching

Developers often search and reuse existing code snippets in the process ...
research
08/08/2022

CSSAM:Code Search via Attention Matching of Code Semantics and Structures

Despite the continuous efforts in improving both the effectiveness and e...
research
07/10/2021

Is a Single Model Enough? MuCoS: A Multi-Model Ensemble Learning for Semantic Code Search

Recently, deep learning methods have become mainstream in code search si...
research
05/09/2019

When Deep Learning Met Code Search

There have been multiple recent proposals on using deep neural networks ...
research
04/16/2021

BERT2Code: Can Pretrained Language Models be Leveraged for Code Search?

Millions of repetitive code snippets are submitted to code repositories ...
research
11/04/2020

Opportunities and Challenges in Code Search Tools

Code search is a core software engineering task. Effective code search t...

Please sign up or login with your details

Forgot password? Click here to reset