TL;DR
This paper introduces a novel approach to hyperparameter optimization (HPO) by leveraging Large Language Models (LLMs). The authors demonstrate that LLMs can effectively suggest and refine hyperparameter configurations, often matching or exceeding the performance of traditional methods like Bayesian optimization, especially within limited search budgets. A key innovation is treating model code itself as a hyperparameter that LLMs can generate, offering greater flexibility than existing HPO techniques.
What Problem Does This Paper Address?
Hyperparameter optimization is a critical but often tedious and expertise-intensive part of machine learning model development. Traditional methods, while effective, typically require practitioners to manually define search spaces, which can be challenging and time-consuming, especially for those with limited ML expertise or tight computational budgets. Furthermore, these methods can struggle in the initial stages of the search. This paper aims to make HPO more accessible and efficient by exploring the use of LLMs, which have shown emergent capabilities in various domains.
Methods
The core methodology involves an iterative process where an LLM is prompted with a description of the machine learning problem, the dataset, and the model. The LLM then suggests a set of hyperparameters. These hyperparameters are used to train the model, and the resulting performance metric (e.g., validation loss) is fed back to the LLM to suggest the next set of hyperparameters. This process continues until a predefined search budget is exhausted.
Two prompting strategies were explored:
- Chat prompting: A conversational dialogue where the LLM receives the entire history of messages, including previous suggestions and feedback.
- Single message prompting (compressed): The search history is compressed into a single message, reducing computational cost.
A significant extension is code generation, where the LLM is prompted to write PyTorch code for the model and optimizer. This treats the code itself as a hyperparameter, allowing the LLM to implicitly define and tune configurations without explicit human specification of search spaces.
Datasets
The paper evaluates its approach on several benchmarks:
- HPOBench: A collection of standard HPO benchmarks including eight datasets and four model types (neural networks, SVMs, random forests, logistic regression).
- CIFAR-10: Used for evaluating performance on deep learning tasks with Vision Transformers (ViTs) and ResNets.
- Kaggle NYC Taxi dataset: Used for the code generation experiments to minimize the risk of data leakage from LLM training data.
- 2-dimensional toy functions: Including Ackley, Branin, Himmelblau, and Rosenbrock functions, used to study LLM reasoning about optimization choices.
Key Insights and Ideas
- LLMs as effective HPO agents: LLMs can effectively navigate hyperparameter search spaces, often outperforming or matching traditional methods like random search and Bayesian optimization, especially in low-budget scenarios.
- Code generation for flexible HPO: Treating model code as a hyperparameter that LLMs can generate offers a powerful way to bypass manual search space definition and explore a wider range of configurations.
- Robustness to noisy measurements: LLMs show resilience to noisy validation metrics, which is crucial given the inherent stochasticity in training deep learning models.
- Chain-of-thought reasoning: While not always providing a significant boost, chain-of-thought prompting can elicit reasoning from LLMs that describes the effects of hyperparameter adjustments, potentially aiding human understanding.
- Synergy with existing methods: LLMs can be used to initialize Bayesian optimization, potentially improving its performance.
Key Results
- On HPOBench with a budget of 10 evaluations, GPT-4 Turbo consistently outperformed random search and was comparable to Bayesian optimization methods. For instance, GPT-4 Turbo beat random search 81.25% of the time.
- For deep learning tasks on CIFAR-10, LLM-based approaches achieved lower validation loss than random search after 30 iterations for both Vision Transformers and ResNets.
- In code generation experiments on the NYC Taxi dataset with a budget of 5 evaluations, the LLM-generated code achieved significantly lower minimum test loss than random search and config-based LLM search.
- LLMs demonstrated robustness to noisy loss measurements, with performance remaining similar even when losses were perturbed by ±10%.
- LLMs provided useful feedback for debugging errors, acting as interactive tuning assistants.
Limitations and Future Work
- Dataset Contamination: While the paper attempts to mitigate this by not revealing benchmark details, the possibility of LLMs having seen evaluation data during training remains. Future work could involve using more private or synthetic datasets.
- Reproducibility: The exact inference procedures for proprietary LLMs are not public, making exact replication challenging. The authors suggest using open-source LLMs for future benchmarking.
- Cost: While LLM-based HPO can be cost-effective for expensive experiments, running large-scale HPO with advanced LLMs can still be costly. The "compressed" prompt strategy offers significant cost savings.
- Emergent Abilities: The underlying mechanisms for LLMs' emergent capabilities in HPO are not fully understood. Future research could explore how to ground LLM suggestions in verified technical knowledge to improve reliability.
- Hallucinations and Inappropriate Suggestions: LLMs can sometimes make incorrect assumptions or suggest irrelevant strategies (e.g., suggesting regularization for underfitting models). Developing more robust dialogue systems and grounding suggestions in technical knowledge are future directions.
Summary updated