Optimizing Large Language Model Hyperparameters for Code Generation
Not on the map. Why?
Abstract (arXiv)
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.
Key facts. Cited by 10 papers in the map (data through 7 Oct 2026). First posted on arXiv 20 Aug 2024.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2025: 7; 2026: 3.
10 papers.
- 2025A Sober Look at Progress in Language Model Reasoning: Pitfalls and Paths to Reproducibilitycited by 89
- 2025Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inferencecited by 47
- 2025Strategic Tradeoffs Between Humans and AI in Multi-Agent Bargainingcited by 11
- 2025Leak@k: Unlearning Does Not Make LLMs Forget Under Probabilistic Decodingcited by 9
- 2025Autonomous Radiotherapy Treatment Planning Using DOLA: A Privacy-Preserving, LLM-Based Optimization Agentcited by 4
- 2025Toward Robust Legal Text Formalization into Defeasible Deontic Logic using LLMscited by 2
- 2026Dataset-Level Metrics Attenuate Non-Determinism: A Fine-Grained Non-Determinism Evaluation in Diffusion Language Modelscited by 2
- 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learningcited by 1
- 2026How LLMs Might Thinkcited by 0
- 2026Large Language Models for Code Generation from Multilingual Prompts: A Curated Benchmark and a Study on Code Qualitycited by 0
- 2026Large Language Models for Code Generation from Multilingual Prompts: A Curated Benchmark and a Study on Code Quality16 Jul 2026
- 2026Dataset-Level Metrics Attenuate Non-Determinism: A Fine-Grained Non-Determinism Evaluation in Diffusion Language Models15 Apr 2026
- 2026How LLMs Might Think2 Apr 2026
- 2025Leak@k: Unlearning Does Not Make LLMs Forget Under Probabilistic Decoding7 Nov 2025
- 2025Strategic Tradeoffs Between Humans and AI in Multi-Agent Bargaining11 Sep 2025
- 2025Understanding and Mitigating Numerical Sources of Nondeterminism in LLM Inference11 Jun 2025
- 2025Toward Robust Legal Text Formalization into Defeasible Deontic Logic using LLMs10 Jun 2025
- 2025A Sober Look at Progress in Language Model Reasoning: Pitfalls and Paths to Reproducibility9 Apr 2025
- 2025Autonomous Radiotherapy Treatment Planning Using DOLA: A Privacy-Preserving, LLM-Based Optimization Agent21 Mar 2025
- 2025Enhancing the Non-Functional Quality Compliance of LLM-Generated Code through Quality-Aware Preference Learning12 Mar 2025