一句话:提出 SECRET,将长深度哈希码迭代训练为多段短码,用哈希表查表召回,大幅提升大规模代码检索效率。
代码检索根据自然语言描述返回代码片段,在软件开发中应用广泛。深度学习模型虽能提升检索效果,但大规模代码库管理仍面临挑战;已有深度哈希方法虽可用汉明距离快速召回,却需线性扫描整个代码库,扩展性受限。为此,论文提出 SECRET,通过迭代训练策略将现有深度哈希方法生成的长哈希码转换为若干短哈希码段;训练后,SECRET 对每个码段分别查哈希表以召回候选代码,从而显著降低召回时间复杂度。大量实验表明,SECRET 在检索性能与已有深度哈希方法相当甚至更高的情况下,至少减少 95% 的检索时间;在相同哈希表数量下,也优于经典 LSH 方法。
Code retrieval, which retrieves code snippets based on users' natural language descriptions, is widely used by devel-opers 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 represen-tations, 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.
DOI 原文 ·
@inproceedings{paperbot8727,
title = {SECRET: Towards Scalable and Efficient Code Retrieval via Segmented Deep Hashing},
author = {Wenchao Gu and Ensheng Shi and Yanlin Wang and Lun Du and Shi Han and Hongyu Zhang and Dongmei Zhang and Michael R. Lyu},
booktitle = {ICSE},
year = {2025},
doi = {10.1109/icse55347.2025.00154}
}