论文标题
猫销售:一种基于公制的方法,用于解释预先培训的编程模型如何参与代码结构
CAT-probing: A Metric-based Approach to Interpret How Pre-trained Models for Programming Language Attend Code Structure
论文作者
论文摘要
代码预训练的模型(CODEPTM)最近在代码智能上表现出了巨大的成功。为了解释这些模型,已经应用了一些探测方法。但是,这些方法无法考虑代码的固有特征。在本文中,为了解决这个问题,我们提出了一种新颖的探测方法猫制作,以定量解释CODEPTM如何参与代码结构。我们首先根据编译器预先定义的令牌类型来确定输入代码序列,以过滤那些注意分数太小的令牌。之后,我们定义了一个新的公制猫评分,以测量在CODEPTM中产生的令牌级别的注意分数与相应AST节点之间的成对距离之间的共同点。猫评分越高,CODEPTM捕获代码结构的能力越强。我们进行了广泛的实验,以将猫播种与不同编程语言的代表性CODEPT集成。实验结果表明,猫播在CodEptm解释中的有效性。我们的代码和数据可在https://github.com/nchen909/codeattention上公开获取。
Code pre-trained models (CodePTMs) have recently demonstrated significant success in code intelligence. To interpret these models, some probing methods have been applied. However, these methods fail to consider the inherent characteristics of codes. In this paper, to address the problem, we propose a novel probing method CAT-probing to quantitatively interpret how CodePTMs attend code structure. We first denoise the input code sequences based on the token types pre-defined by the compilers to filter those tokens whose attention scores are too small. After that, we define a new metric CAT-score to measure the commonality between the token-level attention scores generated in CodePTMs and the pair-wise distances between corresponding AST nodes. The higher the CAT-score, the stronger the ability of CodePTMs to capture code structure. We conduct extensive experiments to integrate CAT-probing with representative CodePTMs for different programming languages. Experimental results show the effectiveness of CAT-probing in CodePTM interpretation. Our codes and data are publicly available at https://github.com/nchen909/CodeAttention.