[论文解读] Prompt Engineering or Fine-Tuning: An Empirical Assessment of LLMs for Code
本研究在注释生成、代码生成、代码翻译等方面比较 GPT-4 提示策略与微调 LLM 基线,并包含一个关于与 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.
研究动机与目标
- 在 ASE 任务中评估基于自动化提示策略(基础提示、上下文内学习、任务特定提示)下的 GPT-4 相对于微调 LLM 基线的有效性。
- 评估三项 ASE 任务:注释生成(SC 到 NL)、代码生成(NL 到 SC)以及代码翻译(SC 到 SC)。
- 探索参与者在与 GPT-4 的对话交互中对提示的感知与演化,以及其在 ASE 任务中的应用。
- 研究完全自动化的提示工程是否能优于微调,并识别人机协同提示的空白点。
提出的方法
- 使用 CodeXGLUE、HumanEval 和 MBPP 基准进行定量比较,以在三种提示策略下评估 GPT-4 相对于公开可用的微调基线。
- 三种提示策略:基础提示、带 BM25 相关示例选择的上下文学习,以及任务特定的工程化提示。
- 使用 BLEU、pass@1、ACC 和 CodeBLEU 作为任务特定评估指标。
- 进行后处理和分词调整,以确保跨任务的公平评估。
- 包含 27 名研究生和 10 名行业从业者的定性用户研究,用以分析对话式提示与提示演化模式。
实验结果
研究问题
- RQ1RQ1:在三个 ASE 任务中,不同的提示策略下的 GPT-4 相对于微调基线的有效性如何。
- RQ2RQ2:参与者如何看待在 ASE 任务中使用基础提示的 GPT-4 的有用性。
- RQ3RQ3:参与者在与 GPT-4 互动进行 ASE 任务时如何改进提示。
- RQ4RQ4:不同的提示演化模式对 GPT-4 的 ASE 任务性能有什么影响。
主要发现
- 通过最佳提示策略的 GPT-4 在注释生成任务上平均比第一名的微调模型高出 8.33 BLEU 点。
- 在代码生成任务中,第一名的微调模型平均比使用最佳提示的 GPT-4 高出 16.61 和 28.3 BLEU 点(两者的对比)。
- 在代码翻译任务中,GPT-4 与微调基线并列领先;在不同的翻译任务中各自超越对方。
- 与自动化提示策略相比,基于对话式提示的 GPT-4 在所有三项 ASE 任务中均取得显著性能提升(分别在相应任务中提升了 15.8%、11.83% 和 16.1%)。
- 定性结果表明人类提供的反馈、上下文和指令能显著提升 GPT-4 的输出,凸显了人机协同提示的潜力。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。