SPENCER: Self-Adaptive Model Distillation for Efficient Code Retrieval
Not on the map. Why?
Abstract (arXiv)
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%.
Key facts. Cited by 5 papers in the map (data through 7 Oct 2026). Builds on 46 of its 66 references that are in the map. First posted on arXiv 1 Aug 2025.
Builds on
46 of 66 references.
References · 46
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2014Adam: A Method for Stochastic Optimizationcited by 36,960
- 2015Distilling the Knowledge in a Neural Networkcited by 10,076
- 2018Representation Learning with Contrastive Predictive Codingcited by 7,662
- 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,482
- 2017Billion-scale similarity search with GPUscited by 2,477
- 2021SimCSE: Simple Contrastive Learning of Sentence Embeddingscited by 2,168
- 2018Unsupervised Feature Learning via Non-Parametric Instance-level Discriminationcited by 1,838
- 2014FitNets: Hints for Thin Deep Netscited by 1,619
- 2016Enriching Word Vectors with Subword Informationcited by 1,578
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2020ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERTcited by 1,160
34 more
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2019Relational Knowledge Distillationcited by 873
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
- 2017Deep Mutual Learningcited by 621
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2018Born Again Neural Networkscited by 539
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 417
- 2021Unified Pre-training for Program Understanding and Generationcited by 361
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 357
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 186
- 2019Distilling Task-Specific Knowledge from BERT into Simple Neural Networkscited by 152
- 2022Lost at C: A User Study on the Security Implications of Large Language Model Code Assistantscited by 87
- 2020Densely Guided Knowledge Distillation using Multiple Teacher Assistantscited by 82
- 2020Contrastive Code Representation Learningcited by 76
- 2021SynCoBERT: Syntax-Guided Multi-Modal Contrastive Pre-Training for Code Representationcited by 63
- 2018Ranking Distillation: Learning Compact Ranking Models With High Performance for Recommender Systemcited by 60
- 2021Online Knowledge Distillation for Efficient Pose Estimationcited by 55
- 2020Self-Supervised Contrastive Learning for Code Retrieval and Summarization via Semantic-Preserving Transformationscited by 49
- 2019When Deep Learning Met Code Searchcited by 45
- 2022SPT-Code: Sequence-to-Sequence Pre-Training for Learning Source Code Representationscited by 35
- 2024REPOFUSE: Repository-Level Code Completion with Fused Dual Contextcited by 32
- 2017Neural Models for Information Retrievalcited by 29
- 2019CoaCor: Code Annotation for Code Retrieval with Reinforcement Learningcited by 22
- 2022CoCoSoDa: Effective Contrastive Learning for Code Searchcited by 21
- 2022Compressing Pre-trained Models of Code into 3 MBcited by 21
- 2020A Multi-Perspective Architecture for Semantic Code Searchcited by 20
- 2024Rewriting the Code: A Simple Method for Large Language Model Augmented Code Searchcited by 17
- 2020Neural Code Search Revisited: Enhancing Code Snippet Retrieval through Natural Language Intentcited by 16
- 2021GraphSearchNet: Enhancing GNNs via Capturing Global Dependencies for Semantic Code Searchcited by 15
- 2020CRaDLe: Deep Code Retrieval Based on Semantic Dependency Learningcited by 12
- 2019The Pupil Has Become the Master: Teacher-Student Model-Based Word Embedding Distillation with Ensemble Learningcited by 5
- 2024Code Hallucinationcited by 5
- 2024"You still have to study" -- On the Security of LLM generated codecited by 3
Built on by
Citing papers per year: 2025: 1; 2026: 4.
5 papers.
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completioncited by 7
- 2025SpecAgent: A Speculative Retrieval and Forecasting Agent for Code Completioncited by 3
- 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoningcited by 3
- 2026PhoenixRepair: Rethinking Repair Strategy Exploration in Software Agentscited by 2
- 2026XSearch: Explainable Code Search via Concept-to-Code Alignmentcited by 0
- 2026PhoenixRepair: Rethinking Repair Strategy Exploration in Software Agents21 Jul 2026
- 2026XSearch: Explainable Code Search via Concept-to-Code Alignment15 May 2026
- 2026DRAINCODE: Stealthy Energy Consumption Attacks on Retrieval-Augmented Code Generation via Context Poisoning28 Jan 2026
- 2026AlignCoder: Aligning Retrieval with Target Intent for Repository-Level Code Completion27 Jan 2026
- 2025SpecAgent: A Speculative Retrieval and Forecasting Agent for Code Completion20 Oct 2025