Lune

ICSE2022Top-tier venue

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

Abstract

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.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

20 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Graph Neural Networks for Vulnerability Detection: A Counterfactual Explanation cites GraphCodeBERT: Pre-training Code Representations with Data Flow
  • Diet code is healthy: simplifying programs for pre-trained models of code cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Diet code is healthy: simplifying programs for pre-trained models of code cites ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
  • AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • AST-Probe: Recovering abstract syntax trees from hidden representations of pre-trained language models cites GraphCodeBERT: Pre-training Code Representations with Data Flow
  • CodeBERT: A Pre-Trained Model for Programming and Natural Languages cites ELECTRA: Pre-training Text Encoders as Discriminators Rather Than Generators
  • CodeBERT: A Pre-Trained Model for Programming and Natural Languages cites Learning and Evaluating Contextual Embedding of Source Code
  • Learning and Evaluating Contextual Embedding of Source Code cites 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 cites 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 cites Learning and Evaluating Contextual Embedding of Source Code
  • Towards Efficient Fine-Tuning of Pre-trained Code Models: An Experimental Study and Beyond cites 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 cites CodeBERT: A Pre-Trained Model for Programming and Natural Languages
  • Towards Efficient Fine-Tuning of Pre-trained Code Models: An Experimental Study and Beyond cites GraphCodeBERT: Pre-training Code Representations with Data Flow
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers20

  1. 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 et al.ASE 2022 · 40 citations
  2. Diet code is healthy: simplifying programs for pre-trained models of codeZhaowei Zhang, Hongyu Zhang, Beijun Shen, Xiaodong GuFSE 2022 · 39 citations
  3. Towards Efficient Fine-Tuning of Pre-trained Code Models: An Experimental Study and BeyondEnsheng Shi, Yanlin Wang, Hongyu Zhang, Lun Du et al.ISSTA 2023 · 37 citations
  4. Graph Neural Networks for Vulnerability Detection: A Counterfactual ExplanationZhaoyang Chu, Yao Wan, Qian Li, Yang Wu et al.ISSTA 2024 · 19 citations
  5. 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 citations

Builds on9

  1. CodeBERT: A Pre-Trained Model for Programming and Natural LanguagesZhangyin Feng, Daya Guo, Duyu Tang, Nan Duan et al.EMNLP Findings 2020 · 2,828 citations
  2. GraphCodeBERT: Pre-training Code Representations with Data FlowDaya Guo, Shuo Ren, Shuai Lu, Zhangyin Feng et al.ICLR 2021 · 1,644 citations
  3. ELECTRA: Pre-training Text Encoders as Discriminators Rather Than GeneratorsKevin Clark, Minh-Thang Luong, Quoc V. Le, Christopher D. ManningICLR 2020 · 541 citations
  4. Learning and Evaluating Contextual Embedding of Source CodeAditya Kanade, Petros Maniatis, Gogul Balakrishnan, Kensen ShiICML 2020 · 438 citations
  5. BERTology Meets Biology: Interpreting Attention in Protein Language ModelsJesse Vig, Ali Madani, Lav R. Varshney, Caiming Xiong et al.ICLR 2021 · 357 citations

Related papers

  1. Benchmarking Language Models for Code Syntax UnderstandingDa Shen, Xinyun Chen, Chenguang Wang, Koushik Sen et al.EMNLP Findings 2022 · 16 citations
  2. GrammarT5: Grammar-Integrated Pretrained Encoder-Decoder Neural Model for CodeQihao Zhu, Qingyuan Liang, Zeyu Sun, Yingfei Xiong et al.ICSE 2024 · 10 citations
  3. No more fine-tuning? an experimental evaluation of prompt tuning in code intelligenceChaozheng Wang, Yuanhang Yang, Cuiyun Gao, Yun Peng et al.FSE 2022 · 148 citations
  4. 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 et al.EMNLP Findings 2022 · 5 citations
  5. Code Summarization with Structure-induced TransformerHongqiu Wu, Hai Zhao, Min ZhangACL Findings 2021 · 70 citations
Dusk over the sea between two cliffs drawn in fine vertical lines