mlsanityData to 14 Oct 2026

Seamlessly Integrating Tree-Based Positional Embeddings into Transformer Models for Source Code Representation

arXiv 2507.04003 ↗First posted 5 Jul 2025cs.LGcited by 1

Not on the map. Why?

Abstract (arXiv)

Transformer-based models have demonstrated significant success in various source code representation tasks. Nonetheless, traditional positional embeddings employed by these models inadequately capture the hierarchical structure intrinsic to source code, typically represented as Abstract Syntax Trees (ASTs). To address this, we propose a novel tree-based positional embedding approach that explicitly encodes hierarchical relationships derived from ASTs, including node depth and sibling indices. These hierarchical embeddings are integrated into the transformer architecture, specifically enhancing the CodeBERTa model. We thoroughly evaluate our proposed model through masked language modeling (MLM) pretraining and clone detection fine-tuning tasks. Experimental results indicate that our Tree-Enhanced CodeBERTa consistently surpasses the baseline model in terms of loss, accuracy, F1 score, precision, and recall, emphasizing the importance of incorporating explicit structural information into transformer-based representations of source code.

Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 16 of its 22 references that are in the map. First posted on arXiv 5 Jul 2025.

Builds on

16 of 22 references.

References · 16

  1. 2017Attention Is All You Needcited by 60,361
  2. 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
  3. 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,372
  4. 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,703
  5. 2020CodeBERT: A Pre-Trained Model for Programming and Natural Languagescited by 1,310
  6. 2018Self-Attention with Relative Position Representationscited by 1,120
  7. 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,103
  8. 2019CodeSearchNet Challenge: Evaluating the State of Semantic Code Searchcited by 654
  9. 2015Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networkscited by 306
  10. 2017Learning to Represent Programs with Graphscited by 220
  11. 2018code2seq: Generating Sequences from Structured Representations of Codecited by 179
  12. 2020A Transformer-based Approach for Source Code Summarizationcited by 133
4 more
  1. 2018Generative Code Modeling with Graphscited by 60
  2. 2019TreeGen: A Tree-Based Transformer Architecture for Code Generationcited by 58
  3. 2019AMR Parsing as Sequence-to-Graph Transductioncited by 50
  4. 2024CSA-Trans: Code Structure Aware Transformer for ASTcited by 3

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 1.

1 paper.