Skip to main content
QUICK REVIEW

[论文解读] A Performance Study of LLM-Generated Code on Leetcode - Code and Dataset artifacts

Jean-Baptiste Döderlein|arXiv (Cornell University)|Oct 26, 2022
Software Engineering Research被引用 6
一句话总结

本文研究了提示词变化和温度设置对Codex与GitHub Copilot在算法编程任务中性能的影响。通过在LeetCode和HumanEval上进行自动化实验,结果表明,调整这些参数可将单次生成的成功率提升至79.27%,显著优于默认设置,揭示了当前代码生成模型在性能潜力与内在脆弱性之间的显著矛盾。

ABSTRACT

Language models are promising solutions for tackling increasing complex problems. In software engineering, they recently gained attention in code assistants, which generate programs from a natural language task description (prompt). They have the potential to save time and effort but remain poorly understood, limiting their optimal use. In this article, we investigate the impact of input variations on two configurations of a language model, focusing on parameters such as task description, surrounding context, model creativity, and the number of generated solutions. We design specific operators to modify these inputs and apply them to three LLM-based code assistants (Copilot, Codex, StarCoder2) and two benchmarks representing algorithmic problems (HumanEval, LeetCode). Our study examines whether these variations significantly affect program quality and how these effects generalize across models. Our results show that varying input parameters can greatly improve performance, achieving up to 79.27% success in one-shot generation compared to 22.44% for Codex and 31.1% for Copilot in default settings. Actioning this potential in practice is challenging due to the complex interplay in our study - the optimal settings for temperature, prompt, and number of generated solutions vary by problem. Reproducing our study with StarCoder2 confirms these findings, indicating they are not model-specific. We also uncover surprising behaviors (e.g., fully removing the prompt can be effective), revealing model brittleness and areas for improvement.

研究动机与目标

  • 评估提示词变化与温度设置对Codex与GitHub Copilot生成代码质量与正确性的影响。
  • 探究系统性调优输入参数是否能显著提升算法编程问题上的代码生成性能。
  • 评估代码助手在多样化编程任务中对输入配置变更的鲁棒性与敏感性。
  • 识别出意外或反直觉的配置(如移除提示词)是否可能优于标准设置。
  • 为未来基于大语言模型的软件工程代码生成研究提供可复现的基准与数据集。

提出的方法

  • 设计自定义操作符,系统性地改变每个编程任务的提示词、温度与生成解的数量(pass@k)。
  • 在两个基准测试中应用这些操作符:HumanEval(50个任务)与LeetCode(涵盖6种编程语言的300个任务)。
  • 使用Codex与Copilot API自动化执行代码生成,控制输入变量的变化。
  • 通过自动化测试套件评估生成代码的正确性(成功率)。
  • 收集并分析多种配置下的结果,以识别性能趋势与最优设置。
  • 发布数据集与实验资产以确保可复现性,包括提示词变体与评估结果。

实验结果

研究问题

  • RQ1在算法问题上,提示词描述的变化如何影响Codex与Copilot生成代码的成功率?
  • RQ2温度超参数调优对代码生成质量与正确性有何影响?
  • RQ3是否移除或简化提示词可带来优于标准或复杂提示词的代码生成结果?
  • RQ4不同类型的算法问题中,最优配置(温度、提示词、pass@k)如何变化?
  • RQ5代码助手的性能在多大程度上对输入参数配置敏感?这对可靠性与自动化意味着什么?

主要发现

  • 通过调整提示词与温度设置,显著提升了代码生成性能,单次生成在最优配置下成功率达到79.27%。
  • Codex在默认设置下仅实现22.44%的成功率,而Copilot达到31.1%,凸显标准配置下性能差距显著。
  • 令人意外的是,某些情况下完全移除提示词反而优于使用标准或复杂提示词,表明当前模型存在潜在脆弱性。
  • 最优配置(温度、提示词、pass@k)在不同问题间差异显著,使得通用化调优极具挑战。
  • 性能提升在不同类型问题或编程语言间并不一致,表明模型行为具有显著上下文依赖性敏感性。
  • 本研究揭示当前代码助手对输入配置高度敏感,意味着手动或自动化超参数调优对实现最优性能至关重要。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。