English

A Closer Look into Transformer-Based Code Intelligence Through Code Transformation: Challenges and Opportunities

Software Engineering 2025-06-10 v2

Abstract

Transformer-based models have demonstrated state-of-the-art performance in many intelligent coding tasks such as code comment generation and code completion. Previous studies show that deep learning models are sensitive to the input variations, but few studies have systematically studied the robustness of Transformer under perturbed input code. In this work, we empirically study the effect of semantic-preserving code transformation on the performance of Transformer. Specifically, 24 and 27 code transformation strategies are implemented for two popular programming languages, Java and Python, respectively. For facilitating analysis, the strategies are grouped into five categories: block transformation, insertion/deletion transformation, grammatical statement transformation, grammatical token transformation, and identifier transformation. Experiments on three popular code intelligence tasks, including code completion, code summarization and code search, demonstrate insertion/deletion transformation and identifier transformation show the greatest impact on the performance of Transformer. Our results also suggest that Transformer based on abstract syntax trees (ASTs) shows more robust performance than the model based on only code sequence under most code transformations. Besides, the design of positional encoding can impact the robustness of Transformer under code transformation. Based on our findings, we distill some insights about the challenges and opportunities for Transformer-based code intelligence.

Keywords

Cite

@article{arxiv.2207.04285,
  title  = {A Closer Look into Transformer-Based Code Intelligence Through Code Transformation: Challenges and Opportunities},
  author = {Yaoxian Li and Shiyi Qi and Cuiyun Gao and Yun Peng and David Lo and Zenglin Xu and Michael R. Lyu},
  journal= {arXiv preprint arXiv:2207.04285},
  year   = {2025}
}

Comments

This paper was accepted by TSE (https://ieeexplore.ieee.org/document/10843180/). It incorporates substantial enhancements, deeper analysis, and more detailed discussions resulting from the peer review process (major and minor revisions) compared to the initial arXiv preprint, which had limitations and shallower discussions

R2 v1 2026-06-25T00:46:59.111Z