用可变前缀调优让代码摘要生成更多样更准确
Variational Prefix Tuning for Diverse and Accurate Code Summarization Using Pre-trained Language Models
- 用条件变分自编码器构建可变前缀,控制生成多样摘要
- 在多个数据集上提升摘要多样性与准确率,不需重新训练大模型
- 适合需要多版本摘要的开发场景,如代码审查或文档生成
近期源码摘要研究利用基于Transformer的预训练模型(包括代码大模型LLMCs)自动化生成高质量摘要。但现有方法通常只输出单一最优摘要,难以应对摘要不理想时的替代需求。本文提出可变前缀调优(VPT),将条件变分自编码器(CVAE)作为模块集成到预训练模型中,建模目标摘要分布并采样连续嵌入作为前缀,引导解码过程生成多样且准确的摘要集合。该方法参数高效,无需对大型模型进行昂贵重训练。此外,采用双准则重排序策略筛选生成摘要,兼顾多样性与准确性。我们在多个主流数据集和当前最先进的预训练代码摘要模型上进行了广泛实验,验证了方法的有效性与跨模型适应性。
原文摘要 · Abstract (English)
Recent advancements in source code summarization have leveraged transformer-based pre-trained models, including Large Language Models of Code (LLMCs), to automate and improve the generation of code summaries. However, existing methods often focus on generating a single high-quality summary for a given source code, neglecting scenarios where the generated summary might be inadequate and alternative options are needed. In this paper, we introduce Variational Prefix Tuning (VPT), a novel approach that enhances pre-trained models' ability to generate diverse yet accurate sets of summaries, allowing the user to choose the most suitable one for the given source code. Our method integrates a Conditional Variational Autoencoder (CVAE) framework as a modular component into pre-trained models, enabling us to model the distribution of observed target summaries and sample continuous embeddings to be used as prefixes to steer the generation of diverse outputs during decoding. Importantly, we construct our method in a parameter-efficient manner, eliminating the need for expensive model retraining, especially when using LLMCs. Furthermore, we employ a bi-criteria reranking method to select a subset of generated summaries, optimizing both the diversity and the accuracy of the options presented to users. We present extensive experimental evaluations using widely used datasets and current state-of-the-art pre-trained code summarization models to demonstrate the effectiveness of our approach and its adaptability across models.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。