What Do They Capture? - A Structural Analysis of Pre-Trained Language Models for Source Code
Yao Wan, Wei Zhao, Hongyu Zhang, Yulei Sui, Guandong Xu, Hai Jin
摘要
Recently, many pre-trained language models for source code have been proposed to model the context of code and serve as a basis for downstream code intelligence tasks such as code completion, code search, and code summarization. These models leverage masked pre-training and Transformer and have achieved promising results. However, currently there is still little progress regarding interpretability of existing pre-trained code models. It is not clear why these models work and what feature correlations they can capture. In this paper, we conduct a thorough structural analysis aiming to provide an interpretation of pre-trained language models for source code (e.g., CodeBERT, and GraphCodeBERT) from three distinctive perspectives: (1) attention analysis, (2) probing on the word embedding, and (3) syntax tree induction. Through comprehensive analysis, this paper reveals several insightful findings that may inspire future studies: (1) Attention aligns strongly with the syntax structure of code. (2) Pre-training language models of code can preserve the syntax structure of code in the intermediate representations of each Transformer layer. (3) The pre-trained models of code have the ability of inducing syntax trees of code. Theses findings suggest that it may be helpful to incorporate the syntax structure of code into the process of pre-training for better code representations.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 20 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Graph Neural Networks for Vulnerability Detection: A Counterfactual Explanation 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
- Diet code is healthy: simplifying programs for pre-trained models of code 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Diet code is healthy: simplifying programs for pre-trained models of code 引用了 ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
- AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
- CodeBERT: A Pre-Trained Model for Programming and Natural Languages 引用了 ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
- CodeBERT: A Pre-Trained Model for Programming and Natural Languages 引用了 Learning and Evaluating Contextual Embedding of Source Code
- Learning and Evaluating Contextual Embedding of Source Code 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Prompt-tuned Code Language Model as a Neural Knowledge Base for Type Inference in Statically-Typed Partial Code 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Prompt-tuned Code Language Model as a Neural Knowledge Base for Type Inference in Statically-Typed Partial Code 引用了 Learning and Evaluating Contextual Embedding of Source Code
- Towards Efficient Fine-Tuning of Pre-trained Code Models: An Experimental Study and Beyond 引用了 AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models
- Towards Efficient Fine-Tuning of Pre-trained Code Models: An Experimental Study and Beyond 引用了 CodeBERT: A Pre-Trained Model for Programming and Natural Languages
- Towards Efficient Fine-Tuning of Pre-trained Code Models: An Experimental Study and Beyond 引用了 GraphCodeBERT: Pre-training Code Representations with Data Flow
引用它的顶会 Paper20
- Prompt-tuned Code Language Model as a Neural Knowledge Base for Type Inference in Statically-Typed Partial CodeQing Huang, Zhiqiang Yuan, Zhenchang Xing, Xiwei Xu 等ASE 2022 · 40 次引用
- Diet code is healthy: simplifying programs for pre-trained models of codeZhaowei Zhang, Hongyu Zhang, Beijun Shen, Xiaodong GuFSE 2022 · 39 次引用
- Towards Efficient Fine-Tuning of Pre-trained Code Models: An Experimental Study and BeyondEnsheng Shi, Yanlin Wang, Hongyu Zhang, Lun Du 等ISSTA 2023 · 37 次引用
- Graph Neural Networks for Vulnerability Detection: A Counterfactual ExplanationZhaoyang Chu, Yao Wan, Qian Li, Yang Wu 等ISSTA 2024 · 19 次引用
- AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language modelsJosé Antonio Hernández López, Martin Weyssow, Jesús Sánchez Cuadrado, Houari A. SahraouiASE 2022 · 18 次引用
它引用的 Paper9
- CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan 等EMNLP Findings 2020 · 2,828 次引用
- GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng 等ICLR 2021 · 1,644 次引用
- ELECTRA: Pre-training Text Encoders as Discriminators Rather Than GeneratorsKevin Clark, Minh-Thang Luong, Quoc V. Le, Christopher D. ManningICLR 2020 · 541 次引用
- Learning and Evaluating Contextual Embedding of Source CodeAditya Kanade, Petros Maniatis, Gogul Balakrishnan, Kensen ShiICML 2020 · 438 次引用
- BERTology Meets Biology: Interpreting Attention in Protein Language ModelsJesse Vig, Ali Madani, Lav R. Varshney, Caiming Xiong 等ICLR 2021 · 357 次引用
相关 Paper
- Benchmarking Language Models for Code Syntax UnderstandingDa Shen, Xinyun Chen, Chenguang Wang, Koushik Sen 等EMNLP Findings 2022 · 16 次引用
- GrammarT5: Grammar-Integrated Pretrained Encoder-Decoder Neural Model for CodeQihao Zhu, Qingyuan Liang, Zeyu Sun, Yingfei Xiong 等ICSE 2024 · 10 次引用
- No more fine-tuning? an experimental evaluation of prompt tuning in code intelligenceChaozheng Wang, Yuanhang Yang, Cuiyun Gao, Yun Peng 等FSE 2022 · 148 次引用
- CAT-probing: A Metric-based Approach to Interpret How Pre-trained Models for Programming Language Attend Code StructureNuo Chen, Qiushi Sun, Renyu Zhu, Xiang Li 等EMNLP Findings 2022 · 5 次引用
- Code Summarization with Structure-induced TransformerHongqiu Wu, Hai Zhao, Min ZhangACL Findings 2021 · 70 次引用
