SPENCER: Self-Adaptive Model Distillation for Efficient Code Retrieval
Gu, Wenchao, Lyu, Zongyi, Wang, Yanlin, Zhang, Hongyu, Gao, Cuiyun, Lyu, Michael R.
–arXiv.org Artificial Intelligence
Code retrieval aims to provide users with desired code snippets based on users' natural language queries. With the development of deep learning technologies, adopting pre-trained models for this task has become mainstream. Considering the retrieval efficiency, most of the previous approaches adopt a dual-encoder for this task, which encodes the description and code snippet into representation vectors, respectively. However, the model structure of the dual-encoder tends to limit the model's performance, since it lacks the interaction between the code snippet and description at the bottom layer of the model during training. To improve the model's effectiveness while preserving its efficiency, we propose a framework, which adopts Self-AdaPtive Model Distillation for Efficient CodE Retrieval, named SPENCER. SPENCER first adopts the dual-encoder to narrow the search space and then adopts the cross-encoder to improve accuracy. To improve the efficiency of SPENCER, we propose a novel model distillation technique, which can greatly reduce the inference time of the dual-encoder while maintaining the overall performance. We also propose a teaching assistant selection strategy for our model distillation, which can adaptively select the suitable teaching assistant models for different pre-trained models during the model distillation to ensure the model performance. Extensive experiments demonstrate that the combination of dual-encoder and cross-encoder improves overall performance compared to solely dual-encoder-based models for code retrieval. Besides, our model distillation technique retains over 98% of the overall performance while reducing the inference time of the dual-encoder by 70%.
arXiv.org Artificial Intelligence
Aug-4-2025
- Country:
- Asia
- China
- Chongqing Province > Chongqing (0.04)
- Guangdong Province
- Heilongjiang Province > Harbin (0.04)
- Hong Kong (0.04)
- Indonesia > Bali (0.04)
- Macao (0.04)
- Singapore (0.04)
- South Korea > Seoul
- Seoul (0.04)
- Thailand > Bangkok
- Bangkok (0.04)
- China
- Europe
- Estonia > Harju County
- Tallinn (0.04)
- Ireland > Leinster
- County Dublin > Dublin (0.04)
- Croatia > Dubrovnik-Neretva County
- Dubrovnik (0.04)
- Sweden
- Stockholm > Stockholm (0.04)
- Vaestra Goetaland > Gothenburg (0.04)
- Spain > Catalonia
- Barcelona Province > Barcelona (0.04)
- Portugal > Lisbon
- Lisbon (0.04)
- United Kingdom > England
- Greater London > London (0.04)
- Denmark > Capital Region
- Copenhagen (0.04)
- Austria (0.04)
- Estonia > Harju County
- North America
- Canada > Quebec
- Montreal (0.04)
- Dominican Republic (0.04)
- United States
- New York > New York County
- New York City (0.04)
- California
- Los Angeles County > Long Beach (0.04)
- Orange County > Anaheim (0.04)
- San Diego County > San Diego (0.04)
- San Francisco County > San Francisco (0.14)
- Michigan > Oakland County
- Rochester (0.04)
- Pennsylvania
- Allegheny County > Pittsburgh (0.04)
- Philadelphia County > Philadelphia (0.04)
- Washington > King County
- Seattle (0.04)
- Utah > Salt Lake County
- Salt Lake City (0.04)
- Hawaii > Honolulu County
- Honolulu (0.04)
- Massachusetts > Suffolk County
- Boston (0.04)
- Nebraska > Lancaster County
- Lincoln (0.04)
- Minnesota > Hennepin County
- Minneapolis (0.14)
- New York > New York County
- Canada > Quebec
- Oceania > Australia
- South America > Colombia
- Meta Department > Villavicencio (0.04)
- Asia
- Genre:
- Research Report
- New Finding (1.00)
- Promising Solution (0.87)
- Research Report
- Industry:
- Education (1.00)
- Information Technology (0.67)
- Technology: