What does Transformer learn about source code?
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 9 papers in the map (data through 7 Oct 2026). Builds on 21 of its 38 references that are in the map. First posted on arXiv 18 Jul 2022.
Builds on
21 of 38 references.
References · 21
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 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
- 2019Attention is not Explanationcited by 916
- 2020A Primer in BERTology: What we know about how BERT workscited by 807
- 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
- 2019Is Attention Interpretable?cited by 387
- 2019Revealing the Dark Secrets of BERTcited by 300
- 2017Learning to Represent Programs with Graphscited by 219
9 more
- 2019Visualizing and Measuring the Geometry of BERTcited by 215
- 2020Self-Attention Attribution: Interpreting Information Interactions Inside Transformercited by 124
- 2019Open Sesame: Getting Inside BERT's Linguistic Knowledgecited by 119
- 2019On Identifiability in Transformerscited by 115
- 2020Perturbed Masking: Parameter-free Probing for Analyzing and Interpreting BERTcited by 109
- 2019Do Attention Heads in BERT Track Syntactic Dependencies?cited by 87
- 2019Neural Program Repair by Jointly Learning to Localize and Repaircited by 39
- 2019From Balustrades to Pierre Vinken: Looking for Syntax in Transformer Self-Attentionscited by 22
- 2019Inducing Syntactic Trees from BERT Representationscited by 11
Built on by
Citing papers per year: 2022: 1; 2023: 3; 2024: 4; 2025: 1.
9 papers.
- 2024Do Machines and Humans Focus on Similar Code? Exploring Explainability of Large Language Models in Code Summarizationcited by 16
- 2024Selective Prompt Anchoring for Code Generationcited by 16
- 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?cited by 13
- 2022Follow-up Attention: An Empirical Study of Developer and Neural Model Code Explorationcited by 5
- 2024A Critical Study of What Code-LLMs (Do Not) Learncited by 4
- 2023ZC3: Zero-Shot Cross-Language Code Clone Detectioncited by 3
- 2025Neuron-Guided Interpretation of Code LLMs: Where, Why, and How?cited by 3
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformerscited by 2
- 2024Generating Equivalent Representations of Code By A Self-Reflection Approachcited by 0
- 2025Neuron-Guided Interpretation of Code LLMs: Where, Why, and How?23 Dec 2025
- 2024Generating Equivalent Representations of Code By A Self-Reflection Approach4 Oct 2024
- 2024Selective Prompt Anchoring for Code Generation17 Aug 2024
- 2024A Critical Study of What Code-LLMs (Do Not) Learn17 Jun 2024
- 2024Do Machines and Humans Focus on Similar Code? Exploring Explainability of Large Language Models in Code Summarization22 Feb 2024
- 2023INSPECT: Intrinsic and Systematic Probing Evaluation for Code Transformers8 Dec 2023
- 2023ZC3: Zero-Shot Cross-Language Code Clone Detection26 Aug 2023
- 2023Do Large Language Models Pay Similar Attention Like Human Programmers When Generating Code?2 Jun 2023
- 2022Follow-up Attention: An Empirical Study of Developer and Neural Model Code Exploration11 Oct 2022