arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2602.06671cs.SE
收藏

代码与序列化AST输入在基于LLM的代码摘要中的比较:一项实证研究

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

University of Glasgow(格拉斯哥大学)

Shijia Dong, Haoruo Zhao, Paul Harvey

AI总结:

本文提出AST(NIT)方法,通过序列化AST提升基于LLM的代码摘要效果,实验表明其在输入长度、训练时间和摘要质量上均优于传统方法。

摘要:

将源代码摘要为自然语言描述(代码摘要)有助于开发人员更好地理解程序功能并减少软件维护的负担。抽象语法树(ASTs)与源代码相比,在传统编码器-解码器基于的代码摘要模型中已被证明可以提高摘要质量。然而,大多数基于大型语言模型(LLM)的代码摘要方法依赖于原始代码或仅整合部分AST信号,意味着对于LLM而言,完整AST表示的潜力尚未被充分探索。本文提出了AST(NIT),一种AST增强和序列化方法,该方法保留了词法细节并将结构信息编码为LLM兼容的序列。在CodeXGLUE Python数据集上使用LLaMA-3.1-8B模型进行的实验表明,所提出的序列化ASTs减少了LLM输入的长度,需要更短的训练时间,并且在摘要质量上与现有方法相当。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑