arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2307.11709cs.AI
收藏

面向神经源代码摘要的基于语句的记忆机制

Statement-based Memory for Neural Source Code Summarization

University of Notre Dame(圣母大学)

Aakash Bansal, Siyuan Jiang, Sakib Haque, Collin McMillan

AI总结:

针对现有神经源代码摘要方法将子例程视为整体、忽略语句流转逻辑的问题,提出基于语句的记忆编码器,在训练中学习代码流关键要素,无需动态分析即可生成子例程表征,显著提升了代码摘要的性能。

摘要:

源代码摘要任务是为源代码的行为生成自然语言描述,它为程序员所需的软件文档提供基础支持。代码的简短描述能帮助程序员无需阅读代码本身即可快速理解程序。近年来,神经源代码摘要已成为自动化代码摘要技术的研究前沿,目前最主流的摘要对象是程序子例程。简而言之,该方向的核心思路是利用从代码仓库中提取的大量子例程样本,训练一种编码器-解码器神经架构:编码器负责表征代码,解码器负责生成摘要。然而,当前大多数方法都将子例程视为单个整体单元,例如将整个子例程作为Transformer或基于RNN的编码器的输入。但代码的行为往往取决于语句之间的流转逻辑。通常动态分析可以揭示这种流转逻辑,但在包含数十万样本的大型数据集上执行动态分析并不现实。本文提出了一种基于语句的记忆编码器,它能在训练过程中学习代码流转的关键要素,无需动态分析即可生成基于语句的子例程表征。我们将该编码器应用于代码摘要任务,实验结果表明其性能较当前最优水平有显著提升。

英文摘要:

Source code summarization is the task of writing natural language descriptions of source code behavior. Code summarization underpins software documentation for programmers. Short descriptions of code help programmers understand the program quickly without having to read the code itself. Lately, neural source code summarization has emerged as the frontier of research into automated code summarization techniques. By far the most popular targets for summarization are program subroutines. The idea, in a nutshell, is to train an encoder-decoder neural architecture using large sets of examples of subroutines extracted from code repositories. The encoder represents the code and the decoder represents the summary. However, most current approaches attempt to treat the subroutine as a single unit. For example, by taking the entire subroutine as input to a Transformer or RNN-based encoder. But code behavior tends to depend on the flow from statement to statement. Normally dynamic analysis may shed light on this flow, but dynamic analysis on hundreds of thousands of examples in large datasets is not practical. In this paper, we present a statement-based memory encoder that learns the important elements of flow during training, leading to a statement-based subroutine representation without the need for dynamic analysis. We implement our encoder for code summarization and demonstrate a significant improvement over the state-of-the-art.

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

↑