[论文解读] An Extractive-and-Abstractive Framework for Source Code Summarization
本文提出EACS,一种新颖的抽取式与生成式混合框架,用于源代码摘要生成,结合基于深度学习的语句抽取与生成式摘要。通过联合处理完整代码片段和提取的关键语句,EACS在六种编程语言和三个数据集上生成的摘要比当前最先进方法更自然、更丰富且事实准确,其在BLEU、METEOR和ROUGE-L指标上的表现优于现有技术,同时在人工评估中也展现出更优的质量。
(Source) Code summarization aims to automatically generate summaries/comments for a given code snippet in the form of natural language. Such summaries play a key role in helping developers understand and maintain source code. Existing code summarization techniques can be categorized into extractive methods and abstractive methods. The extractive methods extract a subset of important statements and keywords from the code snippet using retrieval techniques, and generate a summary that preserves factual details in important statements and keywords. However, such a subset may miss identifier or entity naming, and consequently, the naturalness of generated summary is usually poor. The abstractive methods can generate human-written-like summaries leveraging encoder-decoder models from the neural machine translation domain. The generated summaries however often miss important factual details. To generate human-written-like summaries with preserved factual details, we propose a novel extractive-and-abstractive framework. The extractive module in the framework performs a task of extractive code summarization, which takes in the code snippet and predicts important statements containing key factual details. The abstractive module in the framework performs a task of abstractive code summarization, which takes in the entire code snippet and important statements in parallel and generates a succinct and human-written-like natural language summary. We evaluate the effectiveness of our technique, called EACS, by conducting extensive experiments on three datasets involving six programming languages. Experimental results show that EACS significantly outperforms state-of-the-art techniques in terms of all three widely used metrics, including BLEU, METEOR, and ROUGH-L.
研究动机与目标
- 为解决现有抽取式与生成式代码摘要方法的局限性,这些方法或缺乏自然性,或遗漏事实细节。
- 通过结合抽取式方法的事实精确性与生成式方法的流畅性,提升代码摘要质量。
- 开发一种可扩展、模块化的框架,集成抽取式与生成式组件,以提升摘要质量。
- 在多种编程语言的多样化数据集上评估该框架,以确保其泛化能力与鲁棒性。
提出的方法
- 抽取模块使用基于深度学习的分类器,从输入代码片段中识别并提取包含关键事实细节的语句。
- 生成模块将完整代码片段和提取的关键语句作为并行输入,生成自然语言摘要。
- 该框架采用双编码器架构,先分别编码代码和关键语句,再进行特征融合以生成摘要。
- 生成模块利用带有注意力机制的序列到序列模型,生成流畅且类人语言的摘要。
- 该框架设计为模块化且可扩展,支持与各种预训练模型或未来的大语言模型(LLMs)集成。
- 模型采用端到端训练,使用序列生成损失进行优化,兼顾事实完整性与自然语言流畅性。

实验结果
研究问题
- RQ1与纯抽取式或生成式方法相比,混合抽取式与生成式框架是否能提升代码摘要的事实准确性和自然性?
- RQ2在多种编程语言中,联合处理完整代码与提取语句对摘要质量有何影响?
- RQ3在BLEU、METEOR和ROUGE-L等标准评估指标上,EACS相较于最先进代码摘要技术的性能提升程度如何?
- RQ4与现有方法相比,人工评估者如何评价EACS生成摘要的信息量、相关性与自然性?
主要发现
- 在六种编程语言和三个数据集上,EACS在BLEU、METEOR和ROUGE-L三项标准指标上均显著优于最先进方法。
- 人工评估确认,EACS生成的摘要比现有技术更自然、更富信息量且与输入代码片段更相关。
- 抽取模块能有效识别包含事实细节的关键语句,从而提升生成模块生成准确摘要的能力。
- 当生成模块同时接收完整代码和提取语句时,其生成的摘要比仅使用代码片段的模型更流畅、上下文更连贯。
- 该框架在多种编程语言和代码结构中表现出强大的泛化能力,表明其具有广泛的适用性。
- 结果表明,在统一框架中整合抽取式与生成式组件,比单独使用任一方法更有效。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。