CAT-probing: A Metric-based Approach to Interpret How Pre-trained Models for Programming Language Attend Code Structure
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 6 papers in the map (data through 7 Oct 2026). Builds on 25 of its 32 references that are in the map. First posted on arXiv 7 Oct 2022.
Builds on
25 of 32 references.
References · 25
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
- 2020Informer: Beyond Efficient Transformer for Long Sequence Time-Series Forecastingcited by 2,141
- 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,286
- 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 994
- 2021CodeT5: Identifier-aware Unified Pre-trained Encoder-Decoder Models for Code Understanding and Generationcited by 890
- 2021CodeXGLUE: A Machine Learning Benchmark Dataset for Code Understanding and Generationcited by 732
- 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 638
- 2020GraphCodeBERT: Pre-training Code Representations with Data Flowcited by 600
- 2021Unified Pre-training for Program Understanding and Generationcited by 361
- 2022UniXcoder: Unified Cross-Modal Pre-training for Code Representationcited by 355
13 more
- 2019Analyzing the Structure of Attention in a Transformer Language Modelcited by 241
- 2020IntelliCode Compose: Code Generation Using Transformercited by 225
- 2017A Survey of Machine Learning for Big Code and Naturalnesscited by 220
- 2020Detecting Code Clones with Graph Neural Networkand Flow-Augmented Abstract Syntax Treecited by 68
- 2021Language-Agnostic Representation Learning of Source Code from Structure and Contextcited by 63
- 2021SynCoBERT: Syntax-Guided Multi-Modal Contrastive Pre-Training for Code Representationcited by 63
- 2022What Do They Capture? -- A Structural Analysis of Pre-Trained Language Models for Source Codecited by 50
- 2020Are Pre-trained Language Models Aware of Phrases? Simple but Strong Baselines for Grammar Inductioncited by 47
- 2021What do pre-trained code models know about code?cited by 36
- 2021Code Completion by Modeling Flattened Abstract Syntax Trees as Graphscited by 30
- 2022Probing Pretrained Models of Source Codecited by 26
- 2022Deep Learning Meets Software Engineering: A Survey on Pre-Trained Models of Source Codecited by 20
- 2022A Neural Network Architecture for Program Understanding Inspired by Human Behaviorscited by 5
Built on by
Citing papers per year: 2023: 2; 2024: 3; 2025: 1.
6 papers.
- 2023Representational Strengths and Limitations of Transformerscited by 132
- 2024MPCODER: Multi-user Personalized Code Generator with Explicit and Implicit Style Representation Learningcited by 12
- 2024A Critical Study of What Code-LLMs (Do Not) Learncited by 4
- 2024Structure-aware Fine-tuning for Code Pre-trained Modelscited by 3
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformerscited by 2
- 2025Toward Neurosymbolic Program Comprehensioncited by 0
- 2025Toward Neurosymbolic Program Comprehension3 Feb 2025
- 2024MPCODER: Multi-user Personalized Code Generator with Explicit and Implicit Style Representation Learning25 Jun 2024
- 2024A Critical Study of What Code-LLMs (Do Not) Learn17 Jun 2024
- 2024Structure-aware Fine-tuning for Code Pre-trained Models11 Apr 2024
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformers8 Dec 2023
- 2023Representational Strengths and Limitations of Transformers5 Jun 2023