XSearch: Explainable Code Search via Concept-to-Code Alignment
Not on the map. Why?
Abstract (arXiv)
Semantic code search has been widely adopted in both academia and industry. These approaches embed natural-language queries and code snippets into a shared embedding space and retrieve results based on vector similarity. Despit strong performance on benchmark datasets, they often suffer from poor explainability and generalization. Retrieved code may appear semantically similar yet miss critical functional requirements of the query, while providing no explanation of why the result was retrieved. Moreover, such failures become more severe under distribution shift, where models struggle to generalize to unseen benchmarks. In this work, we propose XSearch, an intrinsically explainable code search framework. Our key insight is that by relying on global embedding similarity, existing retrievers inherently take an inductive view. They learn statistical patterns rather than truly understanding the query's functional requirements. We address this problem by reformulating code search as a deductive concept alignment problem. XSearch (i) identifies functional concepts in the query and (ii) explicitly aligns them with corresponding code statements. This explain-then-predict design produces inherent concept-level explanations and mitigates shortcut learning that harms out-of-distribution generalization. We train an encoder with explicit concept-alignment objectives and perform retrieval through explicit matching between query concepts and code statements. Experiments show that, trained on CodeSearchNet using GraphCodeBERT (125M parameters), XSearch improves performance on out-of-distribution benchmarks from 0.02 to 0.33 (15x) over eight state-of-the-art retrievers, and consistently outperforms both encoder- and decoder-based baselines with up to 7B parameters. A user study demonstrates that concept-alignment explanations enable users to evaluate retrieved results faster and more accurately.
Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 62 of its 100 references that are in the map. First posted on arXiv 15 May 2026.
Builds on
62 of 100 references.
References · 62
- 2018Representation Learning with Contrastive Predictive Codingcited by 7,777
- 2023Code Llama: Open Foundation Models for Codecited by 2,139
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2020MPNet: Masked and Permuted Pre-training for Language Understandingcited by 981
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 906
- 2023StarCoder: may the source be with you!cited by 799
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
- 2023RepoCoder: Repository-Level Code Completion Through Iterative Retrieval and Generationcited by 367
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 361
- 2023CodeT5+: Open Code Large Language Models for Code Understanding and Generationcited by 333
38 more
- 2020Pretrained Transformers Improve Out-of-Distribution Robustnesscited by 294
- 2020Unsupervised Translation of Programming Languagescited by 263
- 2023LEVER: Learning to Verify Language-to-Code Generation with Executioncited by 239
- 2020A Transformer-based Approach for Source Code Summarizationcited by 133
- 2018Tree-to-tree Neural Networks for Program Translationcited by 93
- 2018SySeVR: A Framework for Using Deep Learning to Detect Software Vulnerabilitiescited by 92
- 2021Leveraging Automated Unit Tests for Unsupervised Code Translationcited by 82
- 2021Break-It-Fix-It: Unsupervised Learning for Program Repaircited by 71
- 2022Automated Repair of Programs from Large Language Modelscited by 71
- 2021SynCoBERT: Syntax-Guided Multi-Modal Contrastive Pre-Training for Code Representationcited by 63
- 2022Using Pre-Trained Models to Boost Code Review Automationcited by 63
- 2022An Empirical Study of Deep Learning Models for Vulnerability Detectioncited by 46
- 2023Enhancing Large Language Models in Coding Through Multi-Perspective Self-Consistencycited by 46
- 2022Code Translation with Compiler Representationscited by 42
- 2024GraphCoder: Enhancing Repository-Level Code Completion via Code Context Graph-based Retrieval and Language Modelcited by 40
- 2024ReGAL: Refactoring Programs to Discover Generalizable Abstractionscited by 36
- 2024CodeAgent: Autonomous Communicative Agents for Code Reviewcited by 34
- 2022Fault-Aware Neural Code Rankerscited by 33
- 2023Distilled GPT for Source Code Summarizationcited by 31
- 2024Is Programming by Example solved by LLMs?cited by 27
- 2022AUGER: Automatically Generating Review Comments with Pre-training Modelscited by 23
- 2020Opportunities and Challenges in Code Search Toolscited by 22
- 2022CoCoSoDa: Effective Contrastive Learning for Code Searchcited by 22
- 2023Domain Knowledge Matters: Improving Prompts with Fix Templates for Repairing Python Type Errorscited by 22
- 2022CodeRetriever: Unimodal and Bimodal Contrastive Learning for Code Searchcited by 21
- 2024CodeRosetta: Pushing the Boundaries of Unsupervised Code Translation for Parallel Programmingcited by 19
- 2017Query Expansion Based on Crowd Knowledge for Code Searchcited by 18
- 2018EXS: Explainable Search Using Local Model Agnostic Interpretabilitycited by 18
- 2022Code Search: A Survey of Techniques for Finding Codecited by 18
- 2021CommitBERT: Commit Message Generation Using Pre-Trained Programming Language Modelcited by 16
- 2023From Commit Message Generation to History-Aware Commit Message Completioncited by 16
- 2020Review4Repair: Code Review Aided Automatic Program Repairingcited by 13
- 2024MPCODER: Multi-user Personalized Code Generator with Explicit and Implicit Style Representation Learningcited by 12
- 2015SWIM: Synthesizing What I Meancited by 10
- 2022Accelerating Code Search with Deep Hashing and Code Classificationcited by 10
- 2023Program Translation via Code Distillationcited by 10
- 2024Automated Commit Message Generation with Large Language Models: An Empirical Study and Beyondcited by 10
- 2022Exploring Representation-Level Augmentation for Code Searchcited by 8
50 most cited of 62 All 62 (JSON)
Built on by
Not cited yet.