Lune

NeurIPS2021Top-tier venue

Integrating Tree Path in Transformer for Code Representation

Han Peng, Ge Li, Wenhan Wang, Yunfei Zhao, Zhi Jin

Abstract

Learning distributed representation of source code requires modelling its syntax and semantics. Recent state-of-the-art models leverage highly structured source code representations, such as the syntax trees and paths therein. In this paper, we investigate two representative path encoding methods shown in previous research work and integrate them into the attention module of Transformer. We draw inspiration from the ideas of positional encoding and modify them to incorporate these path encoding. Specifically, we encode both the pairwise path between tokens of source code and the path from the leaf node to the tree root for each token in the syntax tree. We explore the interaction between these two kinds of paths by integrating them into the unified Transformer framework. The detailed empirical study for path encoding methods also leads to our novel state-of-theart representation model TPTrans, which finally outperforms strong baselines. Extensive experiments and ablation studies on code summarization across four different languages demonstrate the effectiveness of our approaches. We release our code at https://github.com/AwdHanPeng/TPTrans .

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.

15 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

  • Syntax and Domain Aware Model for Unsupervised Program Translation cites Language-Agnostic Representation Learning of Source Code from Structure and Context
  • Code Prediction by Feeding Trees to Transformers cites Structural Language Models of Code
  • Code Prediction by Feeding Trees to Transformers cites Global Relational Models of Source Code
  • Language-Agnostic Representation Learning of Source Code from Structure and Context cites Global Relational Models of Source Code
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers15

  1. Code Graph Model (CGM): A Graph-Integrated Large Language Model for Repository-Level Software Engineering TasksHongyuan Tao, Ying Zhang, Zhenhao Tang, Hongen Peng et al.NeurIPS 2025 · 41 citations
  2. Learning to Recommend Method Names with Global ContextFang Liu, Ge Li, Zhiyi Fu, Shuai Lu et al.ICSE 2022 · 32 citations
  3. Syntax and Domain Aware Model for Unsupervised Program TranslationFang Liu, Jia Li, Li ZhangICSE 2023 · 25 citations
  4. TreeMoCo: Contrastive Neuron Morphology Representation LearningHanbo Chen, Jiawei Yang, Daniel Maxim Iascone, Lijuan Liu et al.NeurIPS 2022 · 23 citations
  5. VGX: Large-Scale Sample Generation for Boosting Learning-Based Software Vulnerability AnalysesYu Nong, Richard Fang, Guangbei Yi, Kunsong Zhao et al.ICSE 2024 · 23 citations

Builds on4

  1. Global Relational Models of Source CodeVincent J. Hellendoorn, Charles Sutton, Rishabh Singh, Petros Maniatis et al.ICLR 2020 · 252 citations
  2. Code Prediction by Feeding Trees to TransformersSeohyun Kim, Jinman Zhao, Yuchi Tian, Satish ChandraICSE 2021 · 179 citations
  3. Language-Agnostic Representation Learning of Source Code from Structure and ContextDaniel Zügner, Tobias Kirschstein, Michele Catasta, Jure Leskovec et al.ICLR 2021 · 131 citations
  4. Structural Language Models of CodeUri Alon, Roy Sadaka, Omer Levy, Eran YahavICML 2020 · 115 citations

Related papers

  1. Rethinking Positional Encoding in Tree Transformer for Code RepresentationHan Peng, Ge Li, Yunfei Zhao, Zhi JinEMNLP 2022 · 10 citations
  2. AST-Trans: Code Summarization with Efficient Tree-Structured AttentionZe Tang, Xiaoyu Shen, Chuanyi Li, Jidong Ge et al.ICSE 2022 · 57 citations
  3. Learning Sequential and Structural Information for Source Code SummarizationYunSeok Choi, JinYeong Bak, CheolWon Na, Jee-Hyong LeeACL Findings 2021 · 34 citations
  4. Code Summarization with Structure-induced TransformerHongqiu Wu, Hai Zhao, Min ZhangACL Findings 2021 · 70 citations
  5. What Do They Capture? - A Structural Analysis of Pre-Trained Language Models for Source CodeYao Wan, Wei Zhao, Hongyu Zhang, Yulei Sui et al.ICSE 2022 · 66 citations
Dusk over the sea between two cliffs drawn in fine vertical lines