arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2310.10508cs.SE
收藏

提示工程还是微调:面向代码的大语言模型实证评估

Prompt Engineering or Fine-Tuning: An Empirical Assessment of LLMs for Code

Jiho Shin, Clark Tang, Tahmineh Mohati, Maleknaz Nayebi, Song Wang, Hadi Hemmati

AI总结:

本文实证比较 GPT-4 的三种提示策略与 17 个微调模型在代码摘要、生成和翻译任务上的表现,并结合用户研究评估人类反馈的作用。

摘要:

大语言模型(LLM)的快速发展极大拓展了自动化代码相关任务的潜力。该领域主要采用两种方法:提示工程和微调。提示工程是指运用不同策略查询 ChatGPT 等 LLM;微调则通过在任务特定数据上训练 CodeBERT 等预训练模型,使其进一步适配任务。尽管该领域不断发展,但仍缺乏针对代码模型在这两种方法之间的全面比较分析。本文使用三种提示工程策略评估 GPT-4——基础提示、上下文学习和任务特定提示——并在代码摘要、代码生成和代码翻译三项代码相关任务上将其与 17 个微调模型进行比较。结果表明,采用提示工程的 GPT-4 并不能始终优于微调模型。例如,在代码生成任务中,微调模型在 MBPP 数据集上的表现比 GPT-4 高出 28.3 个百分点。GPT-4 在代码翻译任务上的结果也好坏参半。此外,作者开展了一项包含 27 名研究生和 10 名行业从业者的用户研究。研究显示,与自动化提示相比,采用对话式提示并在交互过程中纳入人类反馈的 GPT-4 性能显著提升;参与者在这些交互中经常提供明确指令或补充上下文。这些发现表明,具备对话式提示的 GPT-4 在自动化代码相关任务方面具有显著前景,而无需人类参与的完全自动化提示工程仍需进一步研究。

英文摘要:

The rapid advancements in large language models (LLMs) have greatly expanded the potential for automated code-related tasks. Two primary methodologies are used in this domain: prompt engineering and fine-tuning. Prompt engineering involves applying different strategies to query LLMs, like ChatGPT, while fine-tuning further adapts pre-trained models, such as CodeBERT, by training them on task-specific data. Despite the growth in the area, there remains a lack of comprehensive comparative analysis between the approaches for code models. In this paper, we evaluate GPT-4 using three prompt engineering strategies -- basic prompting, in-context learning, and task-specific prompting -- and compare it against 17 fine-tuned models across three code-related tasks: code summarization, generation, and translation. Our results indicate that GPT-4 with prompt engineering does not consistently outperform fine-tuned models. For instance, in code generation, GPT-4 is outperformed by fine-tuned models by 28.3% points on the MBPP dataset. It also shows mixed results for code translation tasks. Additionally, a user study was conducted involving 27 graduate students and 10 industry practitioners. The study revealed that GPT-4 with conversational prompts, incorporating human feedback during interaction, significantly improved performance compared to automated prompting. Participants often provided explicit instructions or added context during these interactions. These findings suggest that GPT-4 with conversational prompting holds significant promise for automated code-related tasks, whereas fully automated prompt engineering without human involvement still requires further investigation.

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

↑