arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2412.11728cs.SE
收藏

SECRET:基于分段深度哈希的可扩展高效代码检索

SECRET: Towards Scalable and Efficient Code Retrieval via Segmented Deep Hashing

Wenchao Gu, Ensheng Shi, Yanlin Wang, Lun Du, Shi Han, Hongyu Zhang, Dongmei Zhang, Michael R. Lyu

AI总结:

针对大规模代码检索效率低的问题,提出基于分段深度哈希的SECRET方法,将长哈希码分段并查表召回,减少95%以上检索时间且性能不降。

摘要:

代码检索根据用户的自然语言描述检索代码片段,被开发者广泛使用,并在实际软件开发中发挥着关键作用。深度学习的出现将检索范式从基于词汇的匹配转变为利用深度学习模型将源代码和查询编码为向量表示,从而根据向量相似性促进代码检索。尽管这些模型有效,但管理大规模代码数据库仍面临重大挑战。先前的研究提出了基于深度哈希的方法,为查询和代码片段生成哈希码,并使用汉明距离快速召回代码候选。然而,该方法依赖对整个代码库进行线性扫描,限制了其可扩展性。为了进一步提高大规模代码检索的效率,我们提出了一种新方法SECRET(通过分段深度哈希实现可扩展高效代码检索)。SECRET通过迭代训练策略,将现有深度哈希方法计算出的长哈希码转换为几个短哈希码段。训练后,SECRET通过查找每个段的哈希表来召回代码候选,从而大大降低了召回的时间复杂度。大量实验结果表明,SECRET可以将检索时间大幅减少至少95%,同时达到与现有深度哈希方法相当甚至更高的性能。此外,在相同数量的哈希表下,SECRET相比经典的基于哈希表的方法LSH也表现出更优的性能和效率。

英文摘要:

Code retrieval, which retrieves code snippets based on users' natural language descriptions, is widely used by developers and plays a pivotal role in real-world software development. The advent of deep learning has shifted the retrieval paradigm from lexical-based matching towards leveraging deep learning models to encode source code and queries into vector representations, facilitating code retrieval according to vector similarity. Despite the effectiveness of these models, managing large-scale code database presents significant challenges. Previous research proposes deep hashing-based methods, which generate hash codes for queries and code snippets and use Hamming distance for rapid recall of code candidates. However, this approach's reliance on linear scanning of the entire code base limits its scalability. To further improve the efficiency of large-scale code retrieval, we propose a novel approach SECRET (Scalable and Efficient Code Retrieval via SegmEnTed deep hashing). SECRET converts long hash codes calculated by existing deep hashing approaches into several short hash code segments through an iterative training strategy. After training, SECRET recalls code candidates by looking up the hash tables for each segment, the time complexity of recall can thus be greatly reduced. Extensive experimental results demonstrate that SECRET can drastically reduce the retrieval time by at least 95% while achieving comparable or even higher performance of existing deep hashing approaches. Besides, SECRET also exhibits superior performance and efficiency compared to the classical hash table-based approach known as LSH under the same number of hash tables.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑