[Paper Review] Using Large Language Models for Hyperparameter Optimization
This paper proposes using large language models (LLMs) as decision-makers in hyperparameter optimization (HPO), prompting them to suggest hyperparameter configurations or even full training code based on model and dataset descriptions. Empirically, LLMs achieve performance comparable or superior to random search and Bayesian optimization, especially under low-budget settings, and can generate effective code to automate HPO beyond fixed hyperparameter spaces.
This paper explores the use of foundational large language models (LLMs) in hyperparameter optimization (HPO). Hyperparameters are critical in determining the effectiveness of machine learning models, yet their optimization often relies on manual approaches in limited-budget settings. By prompting LLMs with dataset and model descriptions, we develop a methodology where LLMs suggest hyperparameter configurations, which are iteratively refined based on model performance. Our empirical evaluations on standard benchmarks reveal that within constrained search budgets, LLMs can match or outperform traditional HPO methods like Bayesian optimization across different models on standard benchmarks. Furthermore, we propose to treat the code specifying our model as a hyperparameter, which the LLM outputs and affords greater flexibility than existing HPO approaches.
Motivation & Objective
- To investigate whether foundational LLMs can effectively guide hyperparameter optimization (HPO) in place of traditional methods.
- To evaluate LLMs' performance in constrained search budget scenarios, particularly in early-phase exploration.
- To extend HPO beyond fixed hyperparameter spaces by prompting LLMs to generate full training code.
- To assess the impact of chain-of-thought reasoning on LLM-based HPO performance over multiple iterations.
- To demonstrate that LLMs can serve as general-purpose assistants for automating and improving hyperparameter tuning.
Proposed method
- The LLM is prompted with a description of the dataset, model architecture, and a defined search space of hyperparameters (e.g., learning rate, batch size, width, depth, L2 regularization).
- The model outputs a hyperparameter configuration in JSON format, which is then evaluated via training and validation to obtain a metric (e.g., validation loss).
- The LLM uses the observed metric and prior history to iteratively suggest new configurations in a chain-of-thought reasoning setup.
- The method treats model training code as a hyperparameter, prompting the LLM to generate executable PyTorch code to improve generalization and reduce human-defined search space constraints.
- The approach is evaluated using standard HPO benchmarks (e.g., HPOBench) with neural networks, logistic regression, SVMs, and random forests.
- Performance is compared against random search and Bayesian optimization using Gaussian process and random forest surrogate models.
![Figure 2 : Minimum validation error achieved after $10$ function evaluations from different hyperparameter optimizers on datasets from HPOBench [ 17 ] . The benchmark defines a configuration search space on neural networks for learning rates, $\ell_{2}$ regularization, width, depth, and batch size.](https://ar5iv.labs.arxiv.org/html/2312.04528/assets/x1.png)
Experimental results
Research questions
- RQ1Can LLMs effectively optimize hyperparameters in low-budget settings, outperforming traditional HPO baselines?
- RQ2How does chain-of-thought reasoning influence the LLM’s ability to navigate complex hyperparameter search spaces over multiple iterations?
- RQ3To what extent can LLMs generate valid and performant training code that improves HPO beyond fixed hyperparameter configurations?
- RQ4Does the LLM’s ability to reason about hyperparameter performance generalize across diverse model types and datasets?
- RQ5Can LLMs identify optimal configurations without explicit search space definitions, reducing human engineering effort?
Key findings
- On standard HPO benchmarks, LLMs achieved performance comparable or better than random search and Bayesian optimization with only 10 evaluations.
- With a 5-evaluation budget, LLM-based code generation outperformed random search in hyperparameter tuning, demonstrating automation potential.
- The use of chain-of-thought reasoning enabled LLMs to maintain strong performance over 30 evaluation steps, indicating robustness in sequential decision-making.
- LLMs successfully identified optimal configurations in 2D toy optimization problems, effectively exploring and exploiting loss landscapes.
- The LLM-generated code provided a strong initialization, reducing the need for manual specification of hyperparameter search spaces.
- In multiple experiments, the initial configuration with alpha=0.001, batch_size=32, depth=3, learning_rate_init=0.001, and width=64 achieved the lowest loss (0.058537), which the LLM correctly identified as optimal through iterative analysis.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.