AST-T5: Structure-Aware Pretraining for Code Generation and Understanding

Linyuan Gong, Mostafa Elhoushi, Alvin Cheung
2/12/2026

No official code found. Best implementation: gonglinyuan/ast_t5 (86 stars, last commit 2024-05-10).

Abstract

Large language models (LLMs) have made significant advancements in code-related tasks, yet many LLMs treat code as simple sequences, neglecting its structured nature. We introduce AST-T5, a novel pretraining paradigm that leverages the Abstract Syntax Tree (AST) for enhanced code generation, transpilation, and understanding. Using dynamic programming, our AST-Aware Segmentation retains code structure, while our AST-Aware Span Corruption objective equips the model to reconstruct various code structures. Unlike other models, AST-T5 avoids intricate program analyses or architectural changes, so it integrates seamlessly with any encoder-decoder Transformer. Evaluations show that AST-T5 consistently outperforms similar-sized LMs across various code-related tasks. Structure-awareness makes AST-T5 particularly powerful in code-to-code tasks, surpassing CodeT5 by 2 points in exact match score for the Bugs2Fix task and by 3 points in exact match score for Java-C# Transpilation in CodeXGLUE. Our code and model are publicly available at https://github.com/gonglinyuan/ast_t5.

View on arXivView PDF

Code Implementations(1)

gonglinyuan/ast_t5Community100%
868C++, LuaJan 5, 20242 years ago

Similar Papers

Cite this paper

@article{gong2026astt,
  title  = {AST-T5: Structure-Aware Pretraining for Code Generation and Understanding},
  author = {Linyuan Gong and Mostafa Elhoushi and Alvin Cheung},
  year   = {2026},
  eprint = {2401.03003},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2401.03003},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2401.03003.svg)](https://codeofpaper.com/paper/2401.03003)

Discussion