优化大型语言模型用于代码生成的超参数
Optimizing Large Language Model Hyperparameters for Code Generation
AI总结:
本研究系统探索了LLM超参数(温度、top_p、频率惩罚和存在惩罚)对代码生成的影响,通过详尽组合实验发现最佳性能条件,并公开数据集以促进复现。
摘要:
大型语言模型(LLMs),如GPT模型,越来越多地被用于软件工程中的各种任务,例如代码生成、需求管理和调试。虽然自动化这些任务已引起广泛关注,但关于不同超参数对代码生成结果影响的系统性研究仍未探索。本研究旨在通过详尽探索各种超参数的影响来评估LLMs的代码生成性能。LLMs的超参数是可调整的设置,影响模型的行为和性能。具体来说,我们研究了超参数温度、top概率(top_p)、频率惩罚和存在惩罚的变化如何影响代码生成结果。我们系统地同时调整所有超参数,通过每次对每个超参数进行小幅增量来探索所有可能的组合。这种详尽的方法应用于13个Python代码生成任务,每个超参数组合产生四种结果之一:LLM无输出、不可执行代码、未通过单元测试的代码或正确且功能正常的代码。我们分析了总共14,742个生成的Python代码片段的结果,重点关注正确性,以确定超参数如何影响LLM得出每个结果。通过使用相关系数和回归树分析,我们确定了哪些超参数影响LLM的哪些方面。我们的结果表明,在温度低于0.5、top概率低于0.75、频率惩罚高于-1且低于1.5、存在惩罚高于-1时,可实现最佳性能。我们公开了我们的数据集和结果,以促进复现。
英文摘要:
Large Language Models (LLMs), such as GPT models, are increasingly used in software engineering for various tasks, such as code generation, requirements management, and debugging. While automating these tasks has garnered significant attention, a systematic study on the impact of varying hyperparameters on code generation outcomes remains unexplored. This study aims to assess LLMs' code generation performance by exhaustively exploring the impact of various hyperparameters. Hyperparameters for LLMs are adjustable settings that affect the model's behaviour and performance. Specifically, we investigated how changes to the hyperparameters: temperature, top probability (top_p), frequency penalty, and presence penalty affect code generation outcomes. We systematically adjusted all hyperparameters together, exploring every possible combination by making small increments to each hyperparameter at a time. This exhaustive approach was applied to 13 Python code generation tasks, yielding one of four outcomes for each hyperparameter combination: no output from the LLM, non executable code, code that fails unit tests, or correct and functional code. We analysed these outcomes for a total of 14,742 generated Python code segments, focusing on correctness, to determine how the hyperparameters influence the LLM to arrive at each outcome. Using correlation coefficient and regression tree analyses, we ascertained which hyperparameters influence which aspect of the LLM. Our results indicate that optimal performance is achieved with a temperature below 0.5, top probability below 0.75, frequency penalty above -1 and below 1.5, and presence penalty above -1. We make our dataset and results available to facilitate replication.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。