TL;DR
By fine-tuning Code Llama using Low-Rank Adaptation (LoRA), researchers have demonstrated that large language models can perform hyperparameter optimization (HPO) in a "one-shot" inference step. This approach achieves competitive or superior accuracy compared to traditional iterative frameworks like Optuna while drastically reducing the massive computational overhead typically required by trial-and-error search algorithms.
What Problem Does This Paper Address?
Finding the right hyperparameters (like learning rate, batch size, and momentum) can make or break a deep learning model. Traditionally, engineers rely on automated HPO frameworks like Optuna, which use Bayesian Optimization or Evolutionary Strategies to systematically guess, train, evaluate, and repeat.
While effective, this iterative process is incredibly slow and computationally expensive, often requiring dozens or hundreds of full training runs just to find a single optimal configuration. This paper explores whether a fine-tuned Large Language Model (LLM) can bypass this tedious loop entirely by predicting optimal hyperparameters in a single, one-shot inference step based on the model's architecture code and target accuracy.
Methods
The authors leverage Code Llama-Python as their base model and apply parameter-efficient fine-tuning via Low-Rank Adaptation (LoRA) with a rank of 32, alpha of 16, and a dropout rate of 0.05.
Instead of relying on the LLM's zero-shot capabilities, they implement a structured, two-cycle feedback loop:
- Initial HPO Generation: They use Optuna’s Tree-structured Parzen Estimator (TPE) to generate baseline hyperparameter-accuracy pairs.
- Prompt Engineering: They format the data into prompts containing a system instruction, the model's implementation code, the desired target accuracy, and the corresponding optimal hyperparameters.
- Fine-Tuning & Verification: Code Llama is fine-tuned on these prompts. The model's predictions are then validated by running actual training cycles, and the successful configurations are fed back into the dataset to further refine the model in a second cycle.
The complete generation and evaluation pipeline is outlined below:
Datasets
- LEMUR Neural Network Dataset: A newly introduced open-source benchmark dataset created by the authors for HPO research. It initially contained 3,700 entries of hyperparameter-accuracy pairs and expanded to 7,107 entries after the second fine-tuning cycle.
- Training Models: 14 computer vision architectures (including ResNet, MobileNetV2/V3, SwinTransformer, SqueezeNet, VGG, ConvNeXt, GoogLeNet, AlexNet, DenseNet, MNASNet, ShuffleNet, and RegNet) trained on the CIFAR-10 dataset, alongside text generation models (RNN, LSTM, Llama 3) trained on Salesforce/WikiText.
- Test Models (Unseen Architectures): To evaluate zero-shot generalization to completely unfamiliar codebases, the authors tested the model on InceptionV3, VisionTransformer (ViT), and MaxViT.
Key Insights and Ideas
- Vanilla LLMs are terrible at HPO: Out of the box, pre-trained Code Llama yielded a measly 33.77% relevance rate, frequently suggesting physically impossible configurations like a batch size of 0 or failing to provide numerical values entirely. Fine-tuning is mandatory.
- Shifting from Search to Inference: Once fine-tuned, the LLM successfully internalizes the relationship between network architecture code and training dynamics, turning a massive search problem into a near-instantaneous inference task.
- True Architectural Generalization: Remarkably, the fine-tuned LLM didn't just memorize configurations; it successfully generalized to complex, completely unseen architectures in the test set (like VisionTransformer), significantly outperforming Optuna's average baselines.
Key Results
- Lower Error Rates: The fine-tuned Code Llama consistently achieved lower Root Mean Square Error (RMSE) values than Optuna across most architectures. Code Llama achieved a best overall RMSE of 0.404, outperforming Optuna's best baseline of 0.416.
- Strong One-Shot Performance: Even in pure one-shot mode (predicting instantly without any iterative refinement loops), Code Llama hit an RMSE of 0.533, offering an excellent shortcut to high-performing configurations.
- Stability Gains: As shown in the performance distribution across the 14 vision models, the confidence intervals for Code Llama narrowed significantly by the second fine-tuning cycle, indicating highly stable and reproducible hyperparameter recommendations.
Limitations and Future Work
Despite the strong results, the authors noted that performance varies depending on architectural similarity. For instance, the model struggled with InceptionV3, where its predictions actually led to a decline in accuracy compared to Optuna. This indicates that if a target architecture deviates too drastically from what the LLM saw during fine-tuning, its recommendations degrade.
Additionally, the study was constrained by local hardware resource limitations. Future work will focus on refining prompt design, exploring alternative parameter initializations, and extending fine-tuning schedules to better accommodate highly complex or unique neural network architectures.
Summary updated