Multilayer self‐attention residual network for code search. (13th February 2023) - Hu, Haize; Liu, Jianxun; Zhang, Xiangping
Summary: Software developers usually search existing code snippets in open source code repositories to modify and reuse them. Therefore, how to get the right code snippet from the open‐source code repository quickly and accurately is the focus of current software development research. Nowadays, code search is one of the solutions. To improve the accuracy of source code feature information representation and the accuracy of code search. A multilayer self‐ attention residual network‐based code search model (MSARN‐CS) is proposed in this paper. In the MSARN‐CS model, not only the weight of each word in the code sequence unit is considered but also the effect of embedding between code sequence units is calculated. In addition, an optimization model of residuals is introduced to compensate for the loss of information in the code sequences during the model training. To verify the search effectiveness of the MSARN‐CS model, three other baseline models are compared on the basis of extensive source code data. The experimental results show that the MSARN‐CS model has better search results compared with the baseline model. For parameter Recall@1, the experimental result of MSARN‐CS model was 9.547, which as 100.90%, 73.87%, 60.37%, and 2.55% better compared to CODEnn, CRLCS, SAN‐CS‐ and SAN‐CS, respectively. For the parameter Recall@5, the results improved by 26.67%, 36.23%, 36.21%, and 1.63%, respectively, and for the parameter Recall@10, the results improved by 13.92%, 25.70%, 20.78%, and 2.23%, respectively. For the parameter mean reciprocal rank, the results improved by 52.89%, 76.17%, 63.38%, and 3.88%, respectively. For the parameter normalized discounted cumulative gain, the results improved by 54.22%, 60.55%, 50.28%, and 3.30%, respectively. The MSARN‐CS model proposed in the paper can effectively improve the accuracy of code search and enhance the programming efficiency of developers.