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

CAT探测:一种基于度量的解释程序设计语言预训练模型如何参与代码结构的方法

CAT-probing: A Metric-based Approach to Interpret How Pre-trained Models for Programming Language Attend Code Structure

East China Normal University(华东师范大学)

Nuo Chen, Qiushi Sun, Renyu Zhu, Xiang Li, Xuesong Lu, Ming Gao

摘要:

代码预训练模型(CodePTM)最近在代码智能方面取得了重大成功。为了解释这些模型,已经应用了一些探测方法。然而,这些方法未能考虑代码的固有特性。在本文中,为了解决这个问题,我们提出了一种新的探测方法CAT探测定量解释CodePTM如何参加代码结构。我们首先根据编译器预先定义的标记类型对输入的代码序列进行去噪,以过滤那些注意力分数太小的标记。在此之后,我们定义了一个新的度量CAT分数来衡量CodePTM中生成的标记级注意力分数与相应AST节点之间的成对距离之间的共性。CAT分数越高,CodePTM捕获代码结构的能力越强。我们进行了广泛的实验,以集成CAT探测与代表性的CodePTM为不同的程序设计语言。实验结果表明CAT探测在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.

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

↑