{'fraction_non_alphanumeric': 0.03464146543524286, 'fraction_numerical': 0.00966524500629008, 'mean_word_length': 4.583690251841699, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
CSRS: Code Search with Relevance Matching and Semantic Matching

Developers often search and reuse existing code snippets in the process of software development. Code search aims to retrieve relevant code snippets from a codebase according to natural language queries entered by the developer. Up to now, researchers have already proposed information retrieval (IR) based methods and deep learning (DL) based methods. The IR-based methods focus on keyword matching, that is to rank codes by relevance between queries and code snippets, while DL-based methods focus on capturing the semantic correlations. However, the existing methods do not consider capturing two matching signals simultaneously. Therefore, in this paper, we propose CSRS, a code search model with relevance matching and semantic matching. CSRS comprises (1) an embedding module containing convolution kernels of different sizes which can extract n-gram embeddings of queries and codes, (2) a relevance matching module that measures lexical matching signals, and (3) a co-attention based semantic matching module to capture the semantic correlation. We train and evaluate CSRS on a dataset with 18.22M and 10k code snippets. The experimental results demonstrate that CSRS achieves an MRR of 0.614, which outperforms two state-of-the-art models DeepCS and CARLCS-CNN by 33.77% and 18.53% respectively. In addition, we also conducted several experiments to prove the effectiveness of each component of CSRS.


INTRODUCTION
In modern society, software systems have already been applied in various fields. Similar functions may exist in different software systems, and their implementation codes are similar to each other. When developing or maintaining software systems, in order to improve the development efficiency, developers tend to search or reuse for existing code in search engines or open source repositories such as Google and GitHub, rather than wasting time redeveloping the function. Therefore, code search has become one of the most frequent activities in software development, and it is necessary to develop a code search tool [29].
Many code search methods have been proposed in the past few years to advance the code search task. The existing researches can be divided into two categories: information retrieval (IR) based and deep learning (DL) based [4]. Earlier code search approaches are mostly based on IR techniques, which focus on keyword matching to calculate the relevant score between a query and a code snippet. For example, Lv et al. [20] proposed CodeHow, which expands the query with the APIs and performs code retrieval by applying the extended boolean model. Lu et al. [18] propose an approach that extends a query with synonyms generated from WordNet [22].
Obviously, the IR-based methods cannot capture the semantic relationship between the query and the code. To tackle this issue, many DL-based methods have been proposed, which can bridge the semantic gaps between programming language in code and natural language in query. Gu et al. [5] proposed DeepCS (Deep Code Search), which uses two different LSTM (Long Short-Term Memory) [9] to jointly embed code snippets and natural language queries into a high-dimensional vector space, and then calculates the cosine similarity between code snippets and queries. Shuai et al. [25] proposed CARLCS-CNN that leverages convolutional neural network (CNN) [13] and co-attention mechanism to learn the semantic relationship between code and query. However, the above two types of methods have different concerns. The characteristic of the IR-based model is that the relevance between queries and code snippets can be determined by the keyword matching signals, and the DL-based model performs well in obtaining the semantic relationship between the query and code. Due to the early IR-based methods being mostly rule-based or heuristic, it can not be well combined with the DL-based model. However, with the development of deep learning, some studies use neural networks to build IR models and apply it to document retrieval [6,10,23,24,30], while this kind of IR method is called neural information retrieval (i.e. neural IR). Therefore, it is possible to obtain the relevance and semantic correlations between queries and code snippets.
As shown in Fig.1, the common keywords "array", "new", and "size" are shared in the query and the code, which indicates that the code snippet has relevance to the query. In addition, the query in Fig.1 is semantically correlated with the code. Therefore, in this work, we propose a code search model CSRS (Code Search with Relevance Matching and Semantic Matching) to learn the relevance and semantic relationship between query and code. Specifically, CSRS contains a CNN-based encoding module to extract n-gram embedding from query and code, a neural IR based relevance matching module that measures keyword matches using n-gram embedding to generate an interaction matrix, and a semantic matching module that learns the semantic relationship between query and code by the co-attention mechanism.
To evaluate the effectiveness of CSRS, we conduct a series of experiments on the dataset shared by Gu et al. [5] which contains 18.22M and 10k query-code pairs for the training set and testing set separately. We compare CSRS with two DL-based baseline models DeepCS and CARLCS-CNN. Experimental results show that CSRS achieves an MRR (mean reciprocal rank) of 0.614, outperforming DeepCS and CARLCS-CNN by 33.77% and 18.53% respectively.
In summary, this paper makes the following contributions: • We introduce the neural IR method into code retrieval and design a relevance matching module based on neural IR that captures keyword matching signals (e.g. words, terms, and phrases) between query-code pairs. • We design a semantic matching module based on the coattention mechanism which can learn the semantic representation of queries and code snippets. • We propose a novel code search model CSRS that combines our neural IR based relevance matching module and the semantic matching module. CSRS can simultaneously capture keyword matching signals and semantic correlations between queries and codes. • We evaluate CSRS on a large-scale dataset. The experimental results demonstrate that our model can advance code search tasks compared to two state-of-the-art models DeepCS and CARLCS-CNN. The rest of the paper is organized as follows. Section 2 discusses the related work about code search and neural IR. Section 3 provides some background knowledge on code representation and attention mechanism. Then, we introduce the details of our proposed model CSRS in Section 4. Section 5 and 6 describe the experiment settings, the evaluation results and give some illustrative examples to show the performance of CSRS. Section 7 discusses threats to validity. Finally, Section 8 concludes the paper and illustrates future work.

RELATED WORK
The purpose of code search task is to search for relevant code snippets in the code base according to the query statements entered by the user, while the neural IR models are usually used to retrieve relevant documents, which is similar to code search. Thus, we will introduce the related work of code search (Sec.2.1) and neural IR (Sec.2.2) in the next two subsections.

Code Search
In recent years, a lot of studies have emerged to improve the performance of code search. The prior studies are mostly based on information retrieval techniques, which focus on query reformulation and keyword matching between natural language queries and code snippets. For instance, McMillan et al. [21] proposed Portfolio, which returns a series of code fragments through keyword matching and PageRank. Haiduc et al. [7] proposed a machining learning model Refoqus to recommend a reformulation strategy based on the properties of the query to improve its performance. Sourcerer [17] is an infrastructure for large-scale code search based on Lucene 1 .
In recent years, with the rapid development of deep learning, many researchers use deep learning techniques to implement code search models. Gu et al. [5] first designed a deep learning model DeepCS, which uses the LSTMs to embed codes and queries into the unified semantic space. Based on DeepCS, Shuai et al. [25] proposed a co-attentive representation learning model to capture the correlations between query and code. Xu et al. [31] introduced a two-stage attention-based model to learn the semantic correlation effectively and efficiently.
In addition, many deep learning models use the structure information of the code. Wan et al. [28] developed a multimodal representation method to represent the unstructured and structured features of source code, in which LSTM, tree LSTM, and GGNN (Gating Graph Neural Network) [15] are used to represent the tokens, the AST (Abstract Syntax Tree) and the CFG (Control Flow Graph) of the code. Sun et al. [26] proposed PSCS that encodes both the semantics and structures of code represented by AST paths. Ling et al. [16] represented both queries and code snippets with the unified graph-structured data, and then match two graphs to retrieve the best code snippet.
Furthermore, some studies improve the performance of code search by introducing other code-related tasks. Yao et al. [32] proposed a code annotation model to generate code comments of the given code snippets that can be leveraged by the code retrieval model, which can distinguish relevant codes better from others. Ye et al. [33] utilized the code generation model to improve code retrieval via dual learning. Bui et al. [2] introduced a self-supervised contrastive learning framework to alleviate the need of labeled data for code retrieval.
In general, although DL-based models have achieved considerable results in the code search task, most of the above methods convert the query and code into a vector representation, which only retains the semantic information of queries and codes. While the IR-based models can only obtain the lexical correlations between queries and code snippets, which lack the support of semantic information. We believe that the combination of the two categories of models can enrich the matching information and improve the ability of the code search model.

Neural Information Retrieval
In general, the aim of IR is to retrieve the relevant documents according to the queries. The IR methods represent queries and documents by words. The final ranking is based on the lexical matching between query words and document words, and the matching features are manually defined, which can be incomplete and timeconsuming. Recently, with the successes of deep learning in many related areas, neural IR methods have the ability to improve the performance of traditional IR.
Existing neural IR models can be divided into two categories: representation based and interaction based [6]. The early studies mainly focus on representation based models, which try to construct representations of queries and documents, and the ranking is to match the similarity of the representations. For example, DSSM [10] projects queries and documents into a low-dimensional space where the distance is computed as the relevance between them. Based on the DSSM, Shen et al. [24] used a convolutional-pooling structure to improve the performance. These methods directly learn the representation of queries and documents without considering the interactions between them.
The interaction based models learn word-level matching signals by building the translation matrix from word pairs between queries and documents, then summarizing it into a ranking score. Guo et al. [6] utilized the pyramid pooling technique to summarize the translation matrix. Xiong et al. [30] proposed K-NRM that uses kernel-based pooling to obtain matching signals at different levels. Mitra et al. [23] combined representation based and interaction based models to improve the performance.
In the document retrieval task, compared with traditional IR methods, neural IR methods can capture lexical matching signals through neural networks without manually defining matching features. Inspired by this, we use the neural IR based method to construct the relevance matching module for queries and codes.

PRELIMINARIES
In this section, we briefly introduce some background knowledge of CSRS. We first discuss the code representation using deep learning techniques for the code search task in subsection 3.1. Then we illustrate the preliminary of attention mechanism in subsection 3.2.

Code Representation
In the code search task, code representation is a basic step toward understanding the code. Like the neural language, a code snippet should be mapped into a vector space so that it can be fed to the deep neural network for subsequent calculations.
We can extract three features from the code snippet shown in Fig.1: (1) method name, a sequence of tokens split by camel case; (2) API sequence, a list of API words called in the code snippet; (3) code tokens, a list of words used in the method body. First, a vocabulary is employed to encode the words of the three features. Then the words in three features are converted into vectors with the same dimension. Each feature can be represented by a vector matrix. Finally, the three original vector matrices are fed into neural networks to obtain the embedded three feature matrices.
In the existing researches, DeepCS embeds the API sequence s api and method name s name by LSTM, while the code tokens s tok are embedded by a multilayer perceptron (MLP) [3]. The final code representation c for DeepCS is computed in Eq.(1). As shown in Eq. (2), CARLCS-CNN uses LSTM to embed the API sequence, and the method name and code tokens are embedded by CNN. Recently, TabCS proposes to use the attention mechanism to encode three code features, as shown in Eq. (3).

Attention Mechanism
Encoder-decoder models have achieved a lot of success in tasks like machine translation and text summarization. As the sentence length increases, the performance of the basic encoder-decoder model will decline sharply. To tackle this issue, the attention mechanism was proposed by Bahdanau et al. [1], which allows the model to focus on the relevant parts of the long input sequence. The basic attention mechanism takes the input sequence as three matrices: query matrix ( ), key matrix ( ), and value matrix ( ), and each matrix consists of word vectors. The aim of the attention mechanism is to weigh the value vector by calculating the attention score through the query vector and key vector. Formally, the attention score can be computed as follows: where is the activation function, and is the attention score function which can be a multi-layer perceptron [1], dot product function [19], and scaled dot product [27]. After the calculation of the attention score, we obtain the final attention by weighing the value vector using the attention scores: where is the -th attention score, and , , are the -th element in query, key and value vector matrix respectively.

PROPOSED MODEL
In this section, we present the design and implementation details of our proposed model CSRS.

Embedding Module
Code Embedding. Each code snippet consists of three parts: method name, API sequence, and tokens. Firstly, for each feature of the code, we use an embedding layer to convert each word into a vector. However, using this kind of embedding is equivalent to treating each word as a unigram. In this way, it is difficult to express the information of specific terms composed of multiple words in the code, such as "quickSort", "HashMap" and so on. We hope to match these terms as n-grams instead of splitting them into unigrams for matching. Therefore, we employ CNN to compose adjacent words' embeddings to n-gram embeddings. We implement the n-gram embeddings of description and code through the following steps.  Firstly, code token is a list of words extracted from the method body, in which duplicate words, stop words, and Java keywords are not included.
The implementation of n-gram embeddings for code tokens is shown in Fig.3. Let e T i ∈ R be a -dimensional word initial vector corresponding to the -th word in code tokens. A code tokens sequence with length can be represented by an embedding matrix ∈ R × as shown in Eq.(6).
= [e T 1 , e T 2 , . . . , e T n t ] Then the convolutional layer applies convolution filters to compose n-grams from the code tokens. We use different convolution filters 1 , . . . , ∈ R ℎ× slide over the code tokens embedding matrix like a sliding window, where ℎ from 1 to 3 denotes the width of convolution kernels. For each window of ℎ words, the filter sums up all elements in the ℎ words' embeddings : +ℎ−1 , and produces a feature score as follows: where ∈ {1, 2, . . . , }, b ∈ R is a bias term, * is the convolution operator and is a non-linear function such as the hyperbolic tangent. The filters produce feature scores, so that we can obtain a -dimensional code tokens embedding for the h-gram: Thus, the convolution layer converts the code tokens embedding matrix into h-gram embedding matrix ℎ ∈ R ( −ℎ+1)× .
Specifically, the window size ℎ ranges from 1 to 3, which means we can get three ℎ-gram embedding matrices: 1 for unigram, 2 for bigram, and 3 for trigram. Then, three h-gram embedding matrices are concatenated into the final code tokens matrix : where ⊕ is the concatenation operator. For a given method name, such as "getValue", we split it into a sequence of words according to the camal-case naming convention. Given a method name sequence of length , its original embedding matrix is = [e M 1 , . . . , e M n m ] ∈ R × , where e M i denotes the -th word embedding in method name sequence. The n-gram embedding matrix for the method name are generated using the same way as code token embedding.
Given an API sequence of length , such as "getThemeImage, Map, put", its original embedding matrix is = [e A 1 , . . . , e A n a ] ∈ R × , where e A i denotes the -th word embedding in the API sequence. We use the same method to obtain the final API feature matrix .
After converting the three parts of the code into n-gram embeddings, we get three code feature matrices, we eventually concatenate them into the final code feature matrix ∈ R × .
Description Embedding. The description indicates the user's query intention, which also contains special terms. Therefore, for the given description = [e D 1 , . . . , e D m ] ∈ R × , where e D i denotes the -th word embedding in the description. As shown in Eq.(12)-(13), we use different convolution kernels 1 , . . . , ∈ R ℎ× for convolution operation, and the feature scores generated by each convolution kernel are considered as n-gram embedding vectors ℎ .

Relevance Matching Module
This section describes our efforts to capture keyword matching signals for relevance matching, which measures soft term matches between description-query pairs. We build the interaction matrix by multiplying the description feature matrix ∈ R × and the code feature matrix ∈ R × , which aims to calculate the relevance score between the description and the code: where , can be considered the similarity score by matching the description n-gram vector [ ] with the code n-gram vector [ ].
Since in the description and code, similar n-grams will have closer embedding vectors, their product will produce larger scores. Next, we obtain a normalized relevance matching matrix^by applying a softmax function over the code columns of to normalize the similarity scores into the [0, 1] range. For each description ngram , the softmax function normalizes its matching scores over all n-grams in the code and makes the similar n-grams have a score closer to 1.0. Then we leverage and pooling to obtain two relevance matching feature vectors for the matrix^:

Semantic Matching Module
In addition to relevance matching, the semantic matching module aims to capture semantic correlations via co-attention mechanisms on the description and code feature matrices. Unlike the basic attention mechanism, the co-attention mechanism can focus on the description attention and the code attention simultaneously, and learn the semantic vector representation of both. In detail, we take the description feature matrix ∈ R × and code feature matrix ∈ R × as the query matrix and the key matrix of the attention mechanism. The attention matrix ∈ R × can be calculated by , and a parameter matrix ∈ R × learned by the neural networks. We use the ℎ activation function to scale each element in between -1 and 1.
The attention matrix can focus on the semantic correlation between descriptions and codes. , represents the semantic matching score between the description n-gram feature vector [ ] and the code n-gram feature vector [ ]. Specifically, the -th row in denotes the semantic correlations of the -th n-gram in description to each n-gram in code. Similarly, the -th column in denotes the semantic correlations of the -th n-gram in code to each n-gram in the description.
Then, we employ pooling along rows and columns over as follows, which denotes that we can focus on the description attention and the code attention: where the -th element of u ∈ R represents a semantic score between the -th n-gram in description and its most semantically similar n-gram in code , and the -th element of u ∈ R represents a semantic score between the -th n-gram in code and its most semantically similar n-gram in description . Next, we obtain the description attention weight vector and the code attention weight vector by transforming u and u into a and a using softmax function.

Prediction
After all the computation of the relevance matching module and the semantic matching module, we obtain the matching features Then we concatenate all features to the final feature vector o, and feed o to a two-layer perceptron followed by a ReLU activation. We express the output of the two-layer perceptron as the matching score, and divide the scores into two categories. The first class indicates that the input natural language description is related to the code, and the output value is closer to 1, while the second class indicates that the input natural language description is not related to the code, and the output value is closer

Training
During training, we let each training data be a triple < D, C, L >, where D is the description, C is the code and L represents the ground truth class. We use Adam algorithm [12] to minimizing cross-entropy loss in the training process: where denotes the ground truth class, is the matching score computed by CSRS.

Implementation Details
To conduct our experiment, we set the word embedding size to 100, and the batch size is set as 128. In order to avoid overfitting, we use the dropout technique [8] and set the drop rate to 0.25. We initialize the Adam optimizer [12] with the learning rate 0.0001. All the experiments are implemented using the Keras 2.3.1 framework

EXPERIMENT SETUP
In this section, we first report several research questions (RQs) and experiment results. Then we describe the dataset, evaluation metrics, and several baselines.

Research Questions
Our work aims to answer the following four research questions: • RQ1: How does our proposed model perform?
To answer this question, we conduct an experiment to investigate whether our proposed model performs better than two state-of-the-art baseline models DeepCS [5] and CARLCS-CNN [25]. • RQ2: What is the contribution of each module in CSRS?
In RQ2, we focus on exploring the contribution of the relevance matching module and semantic matching module to CSRS. Specifically, we start with the complete model and then remove each module in turn to understand its effectiveness. • RQ3: How do the three code features affect the model?
We use three code features (i.e. method name, API sequence, and code tokens) to represent a whole code method. In order to understand the impact of these three code features on CSRS, we train CSRS using individual features separately, and then compare with the complete model to analyze the impact of each feature. • RQ4: How does the window size affect the model effectiveness?
In the embedding module, we let the window size be 1, 2, and 3 to capture unigram, bigram, and trigram respectively. This RQ mainly focuses on the choice of window size. Due to analyzing the effectiveness of the choice of window size, we run CSRS with individual window size so that the model can only generate one n-gram embedding.

Dataset
We evaluate our approach on Gu's [5] dataset. The dataset for training contains 18,223,872 commented Java code methods collected from GitHub repositories with at least one star from August 2008 to June 2016. The testing dataset contains 10,000 code-query pairs. As shown in Table 1, we also count the average tokens of the description and the three features of code snippets in the training and testing dataset.

Evaluation Metrics
We evaluate the performance of CSRS by using three common metrics: recall, MRR (Mean Reciprocal Rank) and NDCG (Normalized Discounted Cumulative Gain) [11]. The three metrics are defined as follows: • Recall@k calculates the proportion of queries that the relevant code could be found in the top-ranked list. @ is computed as follows: where Q is the 10,000 queries in testing dataset, is the indicator function that returns 1 if the code related toth query Q is in the top-k list, otherwise it returns 0. We evaluate @ when 's value equals 1, 5 and 10. These values reflect the typical lengths of ranked list that users would focus [14].
• MRR counts the average of the reciprocal ranks of all queries Q. The MRR is computed as follows: where Q is the 10,000 queries in testing dataset, Q denotes the rank of the ground truth code related to the -th query Q in the top-ranked list. Following Gu et al. [5], We let equal to 10. If the ground truth code is not in the ranked list, we set the 1 Q equal to 0.
• NDCG measures the correlation between the ranking result of code snippets and the query. The idea of is that the results of high correlation affect the final score more than the results of general correlation, and when the results with high correlation appear in the front position, the score will be higher. We calculate as follows: where Q denotes the 10k queries in testing dataset, equals to 10, and is the relevance score of the top-results at position .

Baselines
DeepCS. The first model uses the deep learning method proposed by Gu et al. [5], which embeds query and code features separately with two different LSTM models. We reproduce the DeepCS by the open source code shared on GitHub 2 . CARLCS-CNN. A code search model based on CNN, which uses co-attention mechanism to construct the semantic relationship between code snippets and their queries. We also reproduce the source code shared by Shuai et al. 3 [25].

RESULTS
In this section, we first report our experimental results and answer research questions described in Sec 5.1 respectively. Then, we provide several illustrative examples to show the effect of CSRS.

RQ1: Model Effectiveness
We compare CSRS with two state-of-the-art models DeepCS and CARLCS-CNN under the @ , and evaluation metrics. The evaluation results are presented in Table 2. Result 1: Our proposed model outperforms two state-ofthe-art models DeepCS and CARLCS-CNN with the evaluation metrics of @ , and .

RQ2: The contribution of Two Matching Modules
To answer RQ2, we conduct the ablation experiment to investigate the contribution of two matching modules. We test by removing one matching module separately: Relevance Matching (RM): The relevance matching module focus on the lexical matching between the queries and code snippets. We remove the semantic matching module to evaluate the contribution of the relevance matching module.
Semantic Matching (SM): The semantic matching module aims to capture the semantic correlation between the queries and code snippets. Similarly, we delete the relevance matching module to figure out the contribution of the semantic matching module.  Table 3 illustrates the reduction in metrics when the module is removed. RM results in a decrease of by 13.91%, where the of SM drops by 6.97%. For the metric , RM and SM have the decrease by 11.96% and 6.31%. In addition, for the @ evaluation metric, both RM and SM have different degrees of decline. The ablation experiment shows that the complete model is superior to RM and SM, which indicates the effectiveness of the combination of two matching modules.
Result 2: Both relevance matching and semantic matching are effective, while the combination of two matching modules performs the best.

RQ3: The Impact of Different Code Features
Three code features are used in CSRS, including method name (M), API sequence (A), and code tokens (T). In order to find out the impact of these code features, we trained three models, each of which uses only M, A, or T as the input code feature. Table 4 reported the evaluation results. We can observe that only using the method name, API sequence or code tokens results in a drastic decrease of and , which denotes that all code features can improve the performance of CSRS.

RQ4: The Effects of Different Convolution Kernel Size in CNN
In the embedding module, we use three different sizes of convolution kernels to obtain n-gram embeddings. To explore the impact of using only one size of kernel on the model, we ran three models which only use kernels with sizes of 1 (Conv1), 2 (Conv2), or 3 (Conv3) respectively.  Table 5 shows that three different sizes of convolution kernels can improve the effectiveness of CSRS. As we expected, the kernel of size 1 contributes more to the complete model. Meanwhile, the best performance can be obtained by using three sizes of convolution kernels at the same time.

Result 4:
The three different sizes of convolution kernels are all necessary. The convolution kernel with width 1 is close to the effect of the complete model, while the combination achieves the best performance. Fig.4 shows the top 1 search result of CSRS and CARLCS-CNN for the query "return the value at index or null if that is out of range". It can be observed from Fig.4(a) that CSRS can retrieve the ground truth code snippet, because there are many overlaps between the query and the code, such as "value", "index" and "null", which demonstrates the effectiveness of the relevance matching module in CSRS. Meanwhile, it also illustrates that CSRS can understand the semantic of "out of range" in the query. In contrast, Fig.4(b) shows that CARLCS-CNN returns a irrelevant code. Fig.5 shows another search result for the query "get current time stamp". Obviously, from Fig.5(a), we can see that the query words can match the method name exactly in the first result of CSRS. Moreover, the query word "time" semantically correlates with the word "date" in the code snippet. However, Fig.5(b) shows that CARLCS-CNN can not retrieve the correct code.

Illustrative Examples
To sum up, the above two cases illustrate that CSRS can capture both keyword matching information and semantic matching information.

THREATS TO VALIDITY
Our proposed model may suffer from two threats to validity. The first one is the implementation of baselines, reproducing the baseline models by ourselves may cause errors. To reduce this threat, we re-ran DeepCS and CARLCS-CNN with the source code and datasets shared by the authors in GitHub.
The second threat to this work is the generalization of the proposed approach. The dataset provided by Gu et al. [5] is obtained from the open source Java project on GitHub and contains only about 10,000 testing data. Therefore, the experimental results and conclusions may be different for using other programming language datasets or larger testing sets.

CONCLUSION AND FUTURE WORK
In this paper, we propose a novel deep learning model for code search. Our approach consists of two parts, a relevance matching module to capture n-gram matching signals and a semantic matching module for capturing the semantic correlation between the queries and the codes. Our experimental results show that CSRS outperforms DeepCS and CARLCS-CNN in terms of by 33.77% and 18.53%, and by 29.12% and 16.81%, which achieves a significant improvement.
We consider two future works. First, we will try to design a more effective method to combine the relevance matching module and the semantic matching module. Second, we plan to incorporate external knowledge such as knowledge graphs or API documentation to enhance the quality of training data.