Automatically generating human-readable text describing the functionality of a program is the intent of source code summarization. Although neural language models achieve significant performance in this field, they are limited by their inability to access external knowledge. To address this limitation, an emerging trend is combining neural models with external knowledge through retrieval methods. Previous methods have relied on the sentence-level retrieval paradigm on the encoder side. However, this paradigm is coarse-grained, noise-filled and cannot directly take advantage of the high-quality retrieved summary tokens on the decoder side. In this paper, we propose a fine-grained Token-level retrieval-augmented mechanism (Tram) on the decoder side rather than the encoder side to enhance the performance of neural models and produce more low-frequency tokens in generating summaries. Furthermore, to overcome the challenge of token-level retrieval in capturing contextual code semantics, we also propose integrating code semantics into individual summary tokens. The results of extensive experiments and human evaluation show that our token-level retrieval-augmented approach significantly improves performance and is more interpretable.
翻译:论文摘要:自动生成描述程序功能的可读文本是源代码摘要的目标。尽管神经语言模型在该领域取得了显著性能,但由于无法访问外部知识而受到限制。为解决这一局限,新兴趋势是通过检索方法将神经模型与外部知识相结合。以往方法依赖编码器端的句子级检索范式,然而该范式粒度粗、噪声多,且无法直接利用解码器端高质量检索到的摘要令牌。本文提出一种细粒度的解码器端令牌级检索增强机制(Tram),通过在解码端而非编码端引入检索增强来提升神经模型性能,并在生成摘要时产生更多低频令牌。此外,为克服令牌级检索在捕获上下文代码语义方面的挑战,本文还提出将代码语义整合到单个摘要令牌中。大量实验与人工评估结果表明,我们的令牌级检索增强方法显著提升了性能,并具有更强的可解释性。