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

一种面向源代码摘要的提示学习框架

A Prompt Learning Framework for Source Code Summarization

College of Computing and Data Science, Nanyang Technological University(南洋理工大学计算与数据科学学院);State Key Laboratory for Novel Software Technology, Nanjing University(南京大学计算机软件新技术国家重点实验室);Faculty of Data Science, City University of Macau(澳门城市大学数据科学学院)

Tingting Xu, Yun Miao, Chunrong Fang, Hanwei Qian, Xia Feng, Zhenpeng Chen, Chong Wang, Jian Zhang, Weisong Sun, Zhenyu Chen, Yang Liu

AI总结:

针对现有代码摘要LLM适配方案存在的提示设计难、训练成本高、缺乏定制化PEFT方法的问题,提出非侵入式提示学习框架PromptCS,通过训练提示智能体生成连续提示,在低资源消耗下实现媲美甚至超越全参数微调的效果。

摘要:

(源代码)代码摘要任务是为给定代码片段自动生成自然语言摘要(也称为注释)。近年来,随着大语言模型(LLMs)在众多领域的成功应用,软件工程领域的研究者也尝试适配LLMs来解决代码摘要任务。主要的适配方案包括指令提示、面向任务的(全参数)微调以及参数高效微调(PEFT)。然而,指令提示需要设计精心打磨的提示词,且要求用户具备专业领域知识;面向任务的微调则需要高昂的训练成本,同时目前仍缺乏针对代码摘要的有效、定制化的PEFT方法。\n 本文提出了一种名为PromptCS的高效代码摘要提示学习框架。它不再需要用户绞尽脑汁设计有效提示,而是训练一个提示智能体,该智能体能够生成连续提示,以释放LLMs在代码摘要任务中的潜力。与人工编写的离散提示相比,连续提示是在LLMs的引导下生成的,因此更容易被LLMs理解。PromptCS对LLMs是非侵入式的,在训练提示智能体时会冻结LLMs的参数,这能大幅降低对训练资源的要求。我们的综合实验结果表明,PromptCS在四个广泛使用的指标上均显著优于指令提示方案(包括零样本学习和少样本学习),且性能与面向任务的微调方案相当。在一些基础LLMs(例如StarCoderBase-1B和-3B)中,PromptCS的表现甚至优于面向任务的微调方案。更重要的是,PromptCS的训练效率比面向任务的微调方案更高,且在更大规模的LLMs上优势更为明显。

英文摘要:

(Source) code summarization is the task of automatically generating natural language summaries (also called comments) for given code snippets. Recently, with the successful application of large language models (LLMs) in numerous fields, software engineering researchers have also attempted to adapt LLMs to solve code summarization tasks. The main adaptation schemes include instruction prompting, task-oriented (full-parameter) fine-tuning, and parameter-efficient fine-tuning (PEFT). However, instruction prompting involves designing crafted prompts and requires users to have professional domain knowledge, while task-oriented fine-tuning requires high training costs, and effective, tailored PEFT methods for code summarization are still lacking. This paper proposes an effective prompt learning framework for code summarization called PromptCS. It no longer requires users to rack their brains to design effective prompts. Instead, PromptCS trains a prompt agent that can generate continuous prompts to unleash the potential for LLMs in code summarization. Compared to the human-written discrete prompt, the continuous prompts are produced under the guidance of LLMs and are therefore easier to understand by LLMs. PromptCS is non-invasive to LLMs and freezes the parameters of LLMs when training the prompt agent, which can greatly reduce the requirements for training resources. Our comprehensive experimental results show that PromptCS significantly outperforms instruction prompting schemes (including zero-shot learning and few-shot learning) on all four widely used metrics, and is comparable to the task-oriented fine-tuning scheme. In some base LLMs, e.g., StarCoderBase-1B and -3B, PromptCS even outperforms the task-oriented fine-tuning scheme. More importantly, the training efficiency of PromptCS is faster than the task-oriented fine-tuning scheme, with a more pronounced advantage on larger LLMs.

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

↑