With a good code search engine, developers can reuse existing code snippets and accelerate software development process. Current code search methods can be divided into two categories: traditional information retrieval (IR) based and deep learning (DL) based approaches. DL-based approaches include the cross-encoder paradigm and the bi-encoder paradigm. However, both approaches have certain limitations. The inference of IR-based and bi-encoder models are fast, however, they are not accurate enough; while cross-encoder models can achieve higher search accuracy but consume more time. In this work, we propose TOSS, a two-stage fusion code search framework that can combine the advantages of different code search methods. TOSS first uses IR-based and bi-encoder models to efficiently recall a small number of top-k code candidates, and then uses fine-grained cross-encoders for finer ranking. Furthermore, we conduct extensive experiments on different code candidate volumes and multiple programming languages to verify the effectiveness of TOSS. We also compare TOSS with six data fusion methods. Experimental results show that TOSS is not only efficient, but also achieves state-of-the-art accuracy with an overall mean reciprocal ranking (MRR) score of 0.763, compared to the best baseline result on the CodeSearchNet benchmark of 0.713.
翻译:使用良好的代码搜索引擎,开发者可以重新使用现有的代码片断并加速软件开发进程。当前的代码搜索方法可以分为两类:传统的基于信息检索(IR)和基于深层次学习(DL)的方法。基于 DL 的方法包括跨编码模式和双编码模式。但是,这两种方法都有一定的局限性。基于IR和双编码模型的推论速度很快,但是它们不够准确;交叉编码模型可以达到更高的搜索准确度,但消耗的时间也更多。在这项工作中,我们建议采用TOSS,一个两阶段的聚合代码搜索框架,可以将不同代码搜索方法的优势结合起来。TOSS首先使用基于IR和双编码的模型,以便有效地回顾少量顶级代码候选人,然后使用精细的跨编码器和双编码模型来进行更精确的排序。此外,我们还对不同的代码候选卷和多种编程语言进行了广泛的实验,以核实TROS的有效性。我们还将TOSS与六种数据融合方法进行了比较。实验结果显示,TRS13 实验结果与最高代码排序比对最高标准,还实现了最高水平。</s>