Code vs Serialized AST Inputs for LLM-Based Code Summarization: An Empirical Study

📅 2026-02-06
📈 Citations: 0
✨ Influential: 0
📄 PDF
🤖 AI Summary
This work proposes AST(NIT), a novel approach that leverages fully serialized abstract syntax trees (ASTs) to enhance code summarization with large language models (LLMs). While existing methods typically rely on raw source code or partial AST information, AST(NIT) encodes complete structural details of the AST while preserving lexical content, producing compact input sequences tailored for LLMs. In the first systematic evaluation of its kind, the method is integrated with the LLaMA-3.1-8B model on the CodeXGLUE Python dataset, demonstrating significantly reduced input length and training time without compromising summary quality. The results confirm that fully serialized ASTs offer both effectiveness and efficiency advantages in LLM-based code summarization tasks.

Technology Category

Natural Language Processing: SummarizationMachine Learning: Large Multimodal Models (LMMs)Constraint Satisfaction and Optimization: Satisfiability Modulo Theories

Application Category

Graph Algorithms and Modeling for the Web: Foundation models and LLMs for Web-related graphsSearch and Retrieval-Augmented AI: Large language models for searchEconomics, Online Markets and Human Computation: Cost models of using LLMs in production systems
📝 Abstract
Summarizing source code into natural language descriptions (code summarization) helps developers better understand program functionality and reduce the burden of software maintenance. Abstract Syntax Trees (ASTs), as opposed to source code, have been shown to improve summarization quality in traditional encoder-decoder-based code summarization models. However, most large language model (LLM)-based code summarization methods rely on raw code or only incorporate partial AST signals, meaning that the potential of complete AST representation has not been fully explored for LLMs. This paper presents AST(NIT), an AST augmentation and serialization method that preserves lexical details and encodes structural information into LLM-compatible sequences. Experiments with the LLaMA-3.1-8B model on the CodeXGLUE Python dataset show that the proposed serialized ASTs reduce the length of LLM inputs, require shorter training times, and achieve summarization quality comparable to existing approaches.
Problem

Research questions and friction points this paper is trying to address.

code summarization
Abstract Syntax Tree
large language model
AST serialization
source code understanding
Innovation

Methods, ideas, or system contributions that make the work stand out.

serialized AST
code summarization
large language models
AST augmentation
LLM-compatible encoding
🔎 Similar Papers
2024-07-09International Conference on Software EngineeringCitations: 24
2024-03-252024 IEEE/ACM First International Conference on AI Foundation Models and Software Engineering (Forge) Conference Acronym:Citations: 22
S
Shijia Dong
University of Glasgow
H
Haoruo Zhao
University of Glasgow
P
Paul Harvey
University of Glasgow