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

PassSum:利用抽象语法树路径与自监督学习的代码摘要生成方法

PassSum: Leveraging Paths of Abstract Syntax Trees and Self-Supervision for Code Summarization

Software Institute, Nanjing University(南京大学软件学院)

Changan Niu, Chuanyi Li, Vincent Ng, Jidong Ge, Liguo Huang, Bin Luo

AI总结:

PassSum是利用高效AST编码与自监督预训练的代码摘要生成方法,在Java、Python、Ruby数据集上性能优于现有方法,可减少标注数据依赖并加快收敛。

摘要:

代码摘要生成是为代码片段提供高层次注释,通常描述给定代码的功能与意图。近年来,数据驱动的代码摘要生成已成功应用,众多方法采用抽象语法树(Abstract Syntax Tree,AST)表示代码的结构信息,多数研究者认为这是代码区别于自然语言的核心因素。这类数据驱动方法在大规模标注数据集上训练,以获得具备强泛化能力、可应用于新样本的模型。然而,我们发现现有最先进方法存在两大关键缺陷:(1)AST编码效率低下;(2)依赖大量标注语料库进行模型训练。这些缺陷导致:(1)模型体积过大、训练缓慢、存在信息丢失且稳定性不足;(2)无法应用于仅有少量标注数据的编程语言。针对上述缺陷,我们提出PassSum,一种代码摘要生成方法,通过以下两点解决问题:(1)包含高效AST编码方法的新型输入表示;(2)引入三个预训练目标,在自监督学习指导下利用大量易获取的未标注数据预训练模型。在Java、Python和Ruby方法的代码摘要生成实验中,结果表明PassSum优于现有最先进方法。进一步实验显示,我们使用的输入表示除性能领先外,还具备时间与空间优势;预训练还可使模型在更少标注数据下更具泛化能力,并加快模型训练时的收敛速度。

英文摘要:

Code summarization is to provide a high-level comment for a code snippet that typically describes the function and intent of the given code. Recent years have seen the successful application of data-driven code summarization. To improve the performance of the model, numerous approaches use Abstract Syntax Trees (ASTs) to represent the structural information of the code, which is considered by most researchers to be the main factor that distinguishes code from natural language. Then, such data-driven methods are trained on large-scale labeled datasets to obtain a model with strong generalization capabilities that can be applied to new examples. Nevertheless, we argue that state-of-the-art approaches suffer from two key weaknesses: (1) inefficient encoding of ASTs; (2) reliance on a large labeled corpus for model training. As a result, such drawbacks lead to (1) oversized model, slow training, information loss and instability; (2) inability to be applied to programming languages with only a small amount of labeled data. In light of these weaknesses, we propose PassSum, a code summarization approach that addresses the aforementioned weaknesses via (1) a novel input representation which contains an efficient AST encoding method; (2) introducing three pre-training objectives and pre-training our model with a large amount of (easy-to-obtain) unlabeled data under the guidance of self-supervised learning. Experimental results on code summarization for Java, Python and Ruby methods demonstrate the superiority of PassSum to state-of-the-art methods. Further experiments demonstrate that the input representation we use has both temporal and spatial advantages in addition to performance leadership. In addition, pre-training is also shown to make the model more generalizable with less labeled data, and also to speed up the convergence of the model during training.

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

↑