Jie Cai, Qian Cai, Bin Li, Jiale Zhang, Xiaobing Sun
{"title":"利用增强代码表示的深度学习为智能合约推荐应用程序编程接口","authors":"Jie Cai, Qian Cai, Bin Li, Jiale Zhang, Xiaobing Sun","doi":"10.1002/smr.2658","DOIUrl":null,"url":null,"abstract":"<p>Application programming interface (API) recommendation plays a crucial role in facilitating smart contract development by providing developers with a ranked list of candidate APIs for specific recommendation points. Deep learning-based approaches have shown promising results in this field. However, existing approaches mainly rely on token sequences or abstract syntax trees (ASTs) for learning recommendation point-related features, which may overlook the essential knowledge implied in the relations between or within statements and may include task-irrelevant components during feature learning. To address these limitations, we propose a novel code graph called pruned and augmented AST (pa-AST). Our approach enhances the AST by incorporating additional knowledge derived from the control and data flow relations between and within statements in the smart contract code. Through this augmentation, the pa-AST can better represent the semantic features of the code. Furthermore, we conduct AST pruning to eliminate task-irrelevant components based on the identified flow relations. This step helps mitigate the interference caused by these irrelevant parts during the model feature learning process. Additionally, we extract the API sequence surrounding the recommendation point to provide supplementary knowledge for the model learning. The experimental results demonstrate our proposed approach achieving an average mean reciprocal rank (MRR) of 68.02%, outperforming the baselines' performance. Furthermore, through ablation experiments, we explore the effectiveness of our proposed code representation approach. The results indicate that combining pa-AST with the API sequence yields improved performance compared with using them individually. Moreover, our AST augmentation and pruning techniques significantly contribute to the overall results.</p>","PeriodicalId":48898,"journal":{"name":"Journal of Software-Evolution and Process","volume":"36 8","pages":""},"PeriodicalIF":1.7000,"publicationDate":"2024-03-03","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"Application programming interface recommendation for smart contract using deep learning from augmented code representation\",\"authors\":\"Jie Cai, Qian Cai, Bin Li, Jiale Zhang, Xiaobing Sun\",\"doi\":\"10.1002/smr.2658\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"<p>Application programming interface (API) recommendation plays a crucial role in facilitating smart contract development by providing developers with a ranked list of candidate APIs for specific recommendation points. Deep learning-based approaches have shown promising results in this field. However, existing approaches mainly rely on token sequences or abstract syntax trees (ASTs) for learning recommendation point-related features, which may overlook the essential knowledge implied in the relations between or within statements and may include task-irrelevant components during feature learning. To address these limitations, we propose a novel code graph called pruned and augmented AST (pa-AST). Our approach enhances the AST by incorporating additional knowledge derived from the control and data flow relations between and within statements in the smart contract code. Through this augmentation, the pa-AST can better represent the semantic features of the code. Furthermore, we conduct AST pruning to eliminate task-irrelevant components based on the identified flow relations. This step helps mitigate the interference caused by these irrelevant parts during the model feature learning process. Additionally, we extract the API sequence surrounding the recommendation point to provide supplementary knowledge for the model learning. The experimental results demonstrate our proposed approach achieving an average mean reciprocal rank (MRR) of 68.02%, outperforming the baselines' performance. Furthermore, through ablation experiments, we explore the effectiveness of our proposed code representation approach. The results indicate that combining pa-AST with the API sequence yields improved performance compared with using them individually. Moreover, our AST augmentation and pruning techniques significantly contribute to the overall results.</p>\",\"PeriodicalId\":48898,\"journal\":{\"name\":\"Journal of Software-Evolution and Process\",\"volume\":\"36 8\",\"pages\":\"\"},\"PeriodicalIF\":1.7000,\"publicationDate\":\"2024-03-03\",\"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.2658\",\"RegionNum\":4,\"RegionCategory\":\"计算机科学\",\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"Q3\",\"JCRName\":\"COMPUTER SCIENCE, SOFTWARE ENGINEERING\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Journal of Software-Evolution and Process","FirstCategoryId":"94","ListUrlMain":"https://onlinelibrary.wiley.com/doi/10.1002/smr.2658","RegionNum":4,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q3","JCRName":"COMPUTER SCIENCE, SOFTWARE ENGINEERING","Score":null,"Total":0}
引用次数: 0
摘要
应用编程接口(API)推荐通过为开发人员提供特定推荐点的候选 API 排名列表,在促进智能合约开发方面发挥着至关重要的作用。基于深度学习的方法在这一领域取得了可喜的成果。然而,现有方法主要依靠标记序列或抽象语法树(AST)来学习推荐点相关特征,这可能会忽略语句之间或语句内部关系中隐含的基本知识,并可能在特征学习过程中包含与任务无关的成分。为了解决这些局限性,我们提出了一种名为 "剪枝增强语法树"(pa-AST)的新型代码图。我们的方法通过纳入从智能合约代码中语句之间和语句内部的控制和数据流关系中获得的额外知识来增强 AST。通过这种增强,pa-AST 可以更好地表示代码的语义特征。此外,我们还根据确定的流程关系进行 AST 修剪,以消除与任务无关的组件。这一步骤有助于减轻模型特征学习过程中这些无关部分造成的干扰。此外,我们还提取了推荐点周围的 API 序列,为模型学习提供补充知识。实验结果表明,我们提出的方法实现了 68.02% 的平均倒数等级 (MRR),优于基准性能。此外,通过消融实验,我们探索了我们提出的代码表示方法的有效性。结果表明,将 pa-AST 与 API 序列相结合比单独使用它们性能更高。此外,我们的 AST 增强和剪枝技术也为整体结果做出了重大贡献。
Application programming interface recommendation for smart contract using deep learning from augmented code representation
Application programming interface (API) recommendation plays a crucial role in facilitating smart contract development by providing developers with a ranked list of candidate APIs for specific recommendation points. Deep learning-based approaches have shown promising results in this field. However, existing approaches mainly rely on token sequences or abstract syntax trees (ASTs) for learning recommendation point-related features, which may overlook the essential knowledge implied in the relations between or within statements and may include task-irrelevant components during feature learning. To address these limitations, we propose a novel code graph called pruned and augmented AST (pa-AST). Our approach enhances the AST by incorporating additional knowledge derived from the control and data flow relations between and within statements in the smart contract code. Through this augmentation, the pa-AST can better represent the semantic features of the code. Furthermore, we conduct AST pruning to eliminate task-irrelevant components based on the identified flow relations. This step helps mitigate the interference caused by these irrelevant parts during the model feature learning process. Additionally, we extract the API sequence surrounding the recommendation point to provide supplementary knowledge for the model learning. The experimental results demonstrate our proposed approach achieving an average mean reciprocal rank (MRR) of 68.02%, outperforming the baselines' performance. Furthermore, through ablation experiments, we explore the effectiveness of our proposed code representation approach. The results indicate that combining pa-AST with the API sequence yields improved performance compared with using them individually. Moreover, our AST augmentation and pruning techniques significantly contribute to the overall results.