arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.17450cs.SE
收藏

研究配置如何影响LLM中的代码生成:以ChatGPT为例

Studying How Configurations Impact Code Generation in LLMs: the Case of ChatGPT

Benedetta Donato, Leonardo Mariani, Daniela Micucci, Oliviero Riganelli

AI总结:

本文系统研究ChatGPT配置参数(温度、top-p及提示重复次数)对548个Java方法代码生成性能的影响,发现top-p影响显著而温度影响较小,并提出应对非确定性的建议。

摘要:

利用LLM进行代码生成正变得越来越普遍,因为像ChatGPT这样的工具可以通过最少的输入(如方法签名和简短描述)来建议方法实现。实证研究进一步强调了LLM在处理此类任务中的有效性,展示了在代码生成场景中的显著性能。然而,LLM本质上是非确定性的,其输出受温度(temperature)和top-p等参数的影响,其中温度调节模型的创造性水平,而top-p控制输出中应出现的令牌选择。尽管这些参数具有重要意义,但它们的作用往往被忽视。本文系统研究了这些参数以及为应对非确定性所需的提示重复次数对548个Java方法的影响。我们观察到ChatGPT在不同配置下的性能存在显著差异,其中温度的影响相对较小,而top-p参数的影响更为突出。此外,我们展示了创造性如何增强代码生成任务。最后,我们为应对模型的非确定性提供了具体建议。

英文摘要:

Leveraging LLMs for code generation is becoming increasingly common, as tools like ChatGPT can suggest method implementations with minimal input, such as a method signature and brief description. Empirical studies further highlight the effectiveness of LLMs in handling such tasks, demonstrating notable performance in code generation scenarios. However, LLMs are inherently non-deterministic, with their output influenced by parameters such as temperature, which regulates the model's level of creativity, and top-p, which controls the choice of the tokens that shall appear in the output. Despite their significance, the role of these parameters is often overlooked. This paper systematically studies the impact of these parameters, as well as the number of prompt repetitions required to account for non-determinism, in the context of 548 Java methods. We observe significantly different performances across different configurations of ChatGPT, with temperature having a marginal impact compared to the more prominent influence of the top-p parameter. Additionally, we show how creativity can enhance code generation tasks. Finally, we provide concrete recommendations for addressing the non-determinism of the model.

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

↑