Improving Code Search with Hard Negative Sampling Based on Fine-tuning
Pre-trained code models have emerged as the state-of-the-art paradigm for code search tasks. The paradigm involves pre-training the model on search-irrelevant tasks such as masked language modeling, followed by the fine-tuning stage, which focuses on the search-relevant task. The typical fine-tuning method is to employ a dual-encoder architecture to encode semantic embeddings of query and code separately, and then calculate their similarity based on the embeddings.
However, the typical dual-encoder architecture falls short in modeling token-level interactions between query and code, which limits the capabilities of model. To address this limitation, we introduce a cross-encoder architecture for code search that jointly encodes the concatenation of query and code. We further introduce a Retriever-Ranker (RR) framework that cascades the dual-encoder and cross-encoder to promote the efficiency of evaluation and online serving. Moreover, we present a ranking-based hard negative sampling (PS) method to improve the ability of cross-encoder to distinguish hard negative codes, which further enhances the cascaded RR framework. Experiments on four datasets using three code models demonstrate the superiority of our proposed method. We have made the code anonymously available at https://anonymous.4open.science/r/R2PS-E5AE.
Thu 5 DecDisplayed time zone: Beijing, Chongqing, Hong Kong, Urumqi change
16:00 - 17:30 | Session (14)ERA - Early Research Achievements / Technical Track at Room 3 (Xiangquan Ballroom) Chair(s): Jun Sun Singapore Management University | ||
16:00 30mTalk | Improving Code Search with Hard Negative Sampling Based on Fine-tuning Technical Track Hande Dong International Digital Economy Academy, Jiayi Lin International Digital Economy Academy, Yanlin Wang Sun Yat-sen University, Yichong Leng University of Science and Technology of China, Jiawei Chen Zhejiang University, Yutao Xie International Digital Economy Academy | ||
16:30 30mTalk | HANTracer: Leveraging Heterogeneous Graph Attention Network for Large-Scale Requirements-Code Traceability Link Recovery Technical Track Zhiyuan Zou , Bangchao Wang Wuhan Textile University, Hongyan Wan Wuhan Textile University, Huan Jin Wuhan Textile University, Xiaoxiao Li School of Computer Science and Artificial Intelligence, Wuhan Textile University, Yukun Cao School of Computer Science and Artificial Intelligence, Wuhan Textile University | ||
17:00 20mTalk | Enhancing Source Code Comment Generation via Retrieval-Augmented Generation with Design Document Term Dictionary ERA - Early Research Achievements Kazu Nishikawa Hitachi, Ltd. Research & Development Group., Genta Koreki Hitachi, Ltd. Research & Development Group., Hideyuki Kanuka Hitachi, Ltd. |