论文标题
变压器了解源代码的知识是什么?
What does Transformer learn about source code?
论文作者
论文摘要
在源代码处理的领域中,基于变压器的表示模型表现出强大的功能,并在许多任务中都达到了最先进的(SOTA)性能。尽管变压器模型处理了顺序源代码,但证据表明,它们也可以捕获结构信息(\ eg,在语法树,数据流,控制流,\等)。我们提出了汇总的注意力评分,这是一种研究变压器学到的结构信息的方法。我们还提出了汇总的注意图,这是一种从预训练模型中提取程序图的新方法。我们从多个角度测量我们的方法。此外,根据我们的经验发现,我们使用自动提取的图形来替换可变滥用任务中那些巧妙的手动设计图。实验结果表明,我们自动提取的语义图非常有意义且有效,这为我们提供了一个新的观点,可以理解和使用模型中包含的信息。
In the field of source code processing, the transformer-based representation models have shown great powerfulness and have achieved state-of-the-art (SOTA) performance in many tasks. Although the transformer models process the sequential source code, pieces of evidence show that they may capture the structural information (\eg, in the syntax tree, data flow, control flow, \etc) as well. We propose the aggregated attention score, a method to investigate the structural information learned by the transformer. We also put forward the aggregated attention graph, a new way to extract program graphs from the pre-trained models automatically. We measure our methods from multiple perspectives. Furthermore, based on our empirical findings, we use the automatically extracted graphs to replace those ingenious manual designed graphs in the Variable Misuse task. Experimental results show that the semantic graphs we extracted automatically are greatly meaningful and effective, which provide a new perspective for us to understand and use the information contained in the model.