BERT2Code: Can Pretrained Language Models be Leveraged for Code Search? Abdullah Al Ishtiaq , Masum Hasan , Md. Mahim Anjum Haque, Kazi Sajeed Mehrab, Tanveer Muttaqueen, Tahmid Hasan, Anindya Iqbal, and Rifat Shahriyar Bangladesh University of Engineering and Technology, Dhaka, Bangladesh 1505080.aai@ugrad.cse.buet.ac.bd, masum@ra.cse.buet.ac.bd, {mahimanzum, ksmehrab, tanveer.mutta}@gmail.com, {tahmidhasan, anindya, rifat}@cse.buet.ac.bd Millions of repetitive code snippets are submitted to code repositories every day. To search from these large codebases using simple natural language queries would allow programmers to ideate, prototype, and develop easier and faster. Although the existing methods have shown good performance in searching codes when the natural language description contains keywords from the code [21], they are still far behind in searching codes based on the semantic meaning of the natural language query and semantic structure of the code. In recent years, both natural language and programming language research communities have created techniques to embed them in vector spaces. In this work, we leverage the efficacy of these embedding models using a simple, lightweight 2-layer neural network in the task of semantic code search. We show that our model learns the inherent relationship between the embedding spaces and further probes into the scope of improvement by empirically analyzing the embedding methods. In this analysis, we show that the quality of the code embedding model is the bottleneck for our model’s performance, and discuss future directions of study in this area. 1 Introduction Since the inception of computers, researchers have been dreaming of program- ming them with natural language instructions only [38]. Although this problem is far from solved, a subset of this problem, ‘Semantic Code Search’, has gained overwhelming traction in recent years [8,13,17,18,21,35,41]. Semantic code search refers to searching for a source code with a natural language query by utilizing the inherent meaning of both the source code and the query. It has a significant impact on a wide range of computer science appli- cations. For example, searching for source code on websites like Stack Overflow is an integral part of modern software development [30,37]. Easily finding the relevant code snippet can remarkably reduce time, effort, and project cost. Thus, for decades, researchers have been trying to search source codes automatically [32]. These authors contributed equally to this work. arXiv:2104.08017v1 [cs.SE] 16 Apr 2021