A Prompt Learning Framework for Source Code Summarization

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Xu, Tingting, Miao, Yun, Fang, Chunrong, Qian, Hanwei, Feng, Xia, Chen, Zhenpeng, Wang, Chong, Zhang, Jian, Sun, Weisong, Chen, Zhenyu, Liu, Yang
Format: Preprint
Veröffentlicht: 2023
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866917860237901824
author Xu, Tingting
Miao, Yun
Fang, Chunrong
Qian, Hanwei
Feng, Xia
Chen, Zhenpeng
Wang, Chong
Zhang, Jian
Sun, Weisong
Chen, Zhenyu
Liu, Yang
author_facet Xu, Tingting
Miao, Yun
Fang, Chunrong
Qian, Hanwei
Feng, Xia
Chen, Zhenpeng
Wang, Chong
Zhang, Jian
Sun, Weisong
Chen, Zhenyu
Liu, Yang
contents (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.
format Preprint
id arxiv_https___arxiv_org_abs_2312_16066
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle A Prompt Learning Framework for Source Code Summarization
Xu, Tingting
Miao, Yun
Fang, Chunrong
Qian, Hanwei
Feng, Xia
Chen, Zhenpeng
Wang, Chong
Zhang, Jian
Sun, Weisong
Chen, Zhenyu
Liu, Yang
Software Engineering
Artificial Intelligence
68-04, 68T30
D.2.3; I.2.2; I.2.4
(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.
title A Prompt Learning Framework for Source Code Summarization
topic Software Engineering
Artificial Intelligence
68-04, 68T30
D.2.3; I.2.2; I.2.4
url https://arxiv.org/abs/2312.16066