CoSrch: Syntactic and Semantic Structure-Aware Code Representation for Effective Code Search
Code search, which retrieves relevant code snippets from a large codebase based on natural language queries, significantly enhances software development efficiency and quality, with effective code representation being crucial for its success. While recent studies leverage both syntactic and semantic structures of code snippets to improve representation, they inadequately address two key challenges: (1) inadequate capture of long-range dependencies in these structures, and (2) ineffective fusion of syntactic and semantic information. To overcome these limitations, we propose CoSrch, a deep model for syntactic and semantic-aware code representation. CoSrch first encodes code snippets as graphs to enable structured alignment and fusion, then employs a GNN-based graph encoder to capture long-range dependencies (addressing Challenge 1), along with an overlap-aware modality decomposition and fusion framework that eliminates redundancy when fusing the syntactic and semantic information (resolving Challenge 2). Extensive experiments on prominent benchmarks demonstrate CoSrch’s superiority, achieving at least a 7.60% improvement in SuccessRate@1 and a 5.41% gain in MRR on the CSN-Java dataset compared to the best baseline, validating its effectiveness in advancing code search performance.
Authors
- Yu-Cai He (ORCID: https://orcid.org/0000-0002-7905-4217)
- Tiancheng Zhang (ORCID: https://orcid.org/0000-0001-6902-9299)
- Hengyu Liu (ORCID: https://orcid.org/0009-0007-7965-1402)
- Pin Lv
- Jia Xu
- Zhihong Tian
Institutions
- Guangxi University (CN)
- Guangzhou Institute of Advanced Technology (CN)
- Institute of Information Engineering (CN)
- Aalborg University (DK)
- Northeastern University (CN)
Publication Details
- Journal
- ACM Transactions on Software Engineering and Methodology
- Published
- 2025-12-24
- DOI
- https://doi.org/10.1145/3785469
- Primary Topic
- Software Engineering Research
- Type
- article
- Field-Weighted Citation Impact
- 0.00