{"title":"Syn2Vec: A Semantic-Aware Initialization Method for AST Path–Based Code Representation","authors":"Xuekai Sun, Shi Dong, Xianyu Zuo","doi":"10.1002/smr.70145","DOIUrl":null,"url":null,"abstract":"<div>\n \n <p>Although abstract syntax tree (AST) path–based approaches have proven effective, the impact of node embedding initialization methods on model performance remains understudied. This work presents a comprehensive investigation of node embedding initialization for AST path–based code analysis models, proposing Syn2Vec, a semantic-aware initialization method. Our approach learns the semantic relationships between AST nodes in path contexts through a pre-training process, simultaneously capturing structural features and contextual dependencies. This generates initial embeddings that integrate both syntactic and semantic information. Syn2Vec effectively models the structural relatedness and semantic correlation between AST nodes, providing superior initialization for downstream code analysis models. Experimental results on standard code classification benchmarks demonstrate that Syn2Vec-initialized models achieve a 9.43% improvement in the F1-score compared with random initialization, conclusively establishing the importance of initialization strategies for the analysis of AST path–based code.</p>\n </div>","PeriodicalId":48898,"journal":{"name":"Journal of Software-Evolution and Process","volume":"38 6","pages":""},"PeriodicalIF":1.6000,"publicationDate":"2026-06-09","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Software-Evolution and Process","FirstCategoryId":"94","ListUrlMain":"https://onlinelibrary.wiley.com/doi/10.1002/smr.70145","RegionNum":4,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0
Abstract
Although abstract syntax tree (AST) path–based approaches have proven effective, the impact of node embedding initialization methods on model performance remains understudied. This work presents a comprehensive investigation of node embedding initialization for AST path–based code analysis models, proposing Syn2Vec, a semantic-aware initialization method. Our approach learns the semantic relationships between AST nodes in path contexts through a pre-training process, simultaneously capturing structural features and contextual dependencies. This generates initial embeddings that integrate both syntactic and semantic information. Syn2Vec effectively models the structural relatedness and semantic correlation between AST nodes, providing superior initialization for downstream code analysis models. Experimental results on standard code classification benchmarks demonstrate that Syn2Vec-initialized models achieve a 9.43% improvement in the F1-score compared with random initialization, conclusively establishing the importance of initialization strategies for the analysis of AST path–based code.