arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2312.00413cs.SEcs.AIcs.CLcs.PL
收藏

用于编程语言理解与表示的抽象语法树:我们离目标还有多远?

Abstract Syntax Tree for Programming Language Understanding and Representation: How Far Are We?

Nanjing University(南京大学);Nanyang Technological University(南洋理工大学)

Weisong Sun, Chunrong Fang, Yun Miao, Yudu You, Mengzhe Yuan, Yuchen Chen, Quanjun Zhang, An Guo, Xiang Chen, Yang Liu, Zhenyu Chen

AI总结:

本文通过实证研究系统评估了基于AST与基于Token的代码表示在多项代码任务上的效果,发现AST整体表现较弱但在特定子集上有优势,并分析了AST各处理阶段的影响,为后续研究提供指导。

摘要:

编程语言理解与表示(又称代码表示学习)一直是软件工程中一个热门且具有挑战性的任务。其目标在于应用深度学习技术生成源代码特征的数值表示,同时保留其语义。这些表示可用于促进后续的代码相关任务。抽象语法树(AST)作为一种基本的代码特征,展示了源代码的语法信息,并已被广泛应用于代码表示学习。然而,目前仍缺乏对基于AST的代码表示在多大程度上能够促进后续代码相关任务的系统性和定量评估。在本文中,我们首先进行了一项全面的实证研究,以探索基于AST的代码表示在促进后续代码相关任务方面的有效性。为此,我们在三种流行的代码相关任务类型上,比较了使用基于代码令牌序列(简称Token)的代码表示训练的模型与使用基于AST的代码表示训练的模型的性能。令人惊讶的是,整体定量统计结果表明,与使用基于Token的代码表示训练的模型相比,使用基于AST的代码表示训练的模型在所有三项任务上的表现始终较差。我们进一步的定量分析揭示,在所有三项任务的某些样本子集上,使用基于AST的代码表示训练的模型优于使用基于Token的代码表示训练的模型。我们还进行了全面的实验,以评估并揭示AST解析/预处理/编码方法的选择对基于AST的代码表示及后续代码相关任务的影响。我们的研究为未来的研究人员提供了详细的指导,说明如何在每个阶段选择解决方案以充分利用AST。

英文摘要:

Programming language understanding and representation (a.k.a code representation learning) has always been a hot and challenging task in software engineering. It aims to apply deep learning techniques to produce numerical representations of the source code features while preserving its semantics. These representations can be used for facilitating subsequent code-related tasks. The abstract syntax tree (AST), a fundamental code feature, illustrates the syntactic information of the source code and has been widely used in code representation learning. However, there is still a lack of systematic and quantitative evaluation of how well AST-based code representation facilitates subsequent code-related tasks. In this paper, we first conduct a comprehensive empirical study to explore the effectiveness of the AST-based code representation in facilitating follow-up code-related tasks. To do so, we compare the performance of models trained with code token sequence (Token for short) based code representation and AST-based code representation on three popular types of code-related tasks. Surprisingly, the overall quantitative statistical results demonstrate that models trained with AST-based code representation consistently perform worse across all three tasks compared to models trained with Token-based code representation. Our further quantitative analysis reveals that models trained with AST-based code representation outperform models trained with Token-based code representation in certain subsets of samples across all three tasks. We also conduct comprehensive experiments to evaluate and reveal the impact of the choice of AST parsing/preprocessing/encoding methods on AST-based code representation and subsequent code-related tasks. Our study provides future researchers with detailed guidance on how to select solutions at each stage to fully exploit AST.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑