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

Institutions

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
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

CoSrch: Syntactic and Semantic Structure-Aware Code Representation for Effective Code Search

Yu-Cai He, Tiancheng Zhang, Hengyu Liu, Pin Lv et al.
ACM Transactions on Software Engineering and Methodology
Software Engineering Research
article

CoSrch: Syntactic and Semantic Structure-Aware Code Representation for Effective Code Search

Yu-Cai He, Tiancheng Zhang, Hengyu Liu, Pin Lv, Jia Xu, Zhihong Tian
article en

Abstract

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.

ACM Transactions on Software Engineering and Methodology
Guangxi University (CN), Guangzhou Institute of Advanced Technology (CN), Institute of Information Engineering (CN), Aalborg University (DK), Northeastern University (CN)
Industry, innovation and infrastructure
Openalex Percentile: Top 24%
Software Engineering Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.