Zubnet AIAprenderWiki › Hyperparameter Tuning
Training

Hyperparameter Tuning

HPO, Hyperparameter Optimization, Grid Search
Buscar sistematicamente os melhores hiperparâmetros — as escolhas de configuração que não são aprendidas durante o treinamento mas devem ser definidas antes dele começar. Learning rate, batch size, número de camadas, taxa de dropout e rank LoRA são todos hiperparâmetros. Métodos de tuning incluem grid search (tentar todas as combinações), random search (tentar combinações aleatórias) e otimização bayesiana (usar resultados passados para guiar a busca).

Por que importa

A diferença entre um bom e mau conjunto de hiperparâmetros pode ser enorme — um learning rate errado pode fazer o treinamento divergir ou convergir para uma solução ruim. Tuning de hiperparâmetros é como você tira o máximo da sua arquitetura de modelo e dados. Para fine-tuning de LLMs, learning rate e número de epochs são tipicamente os hiperparâmetros de maior impacto para ajustar.

Deep Dive

Grid search evaluates every combination of specified hyperparameter values: learning rates [1e-3, 1e-4, 1e-5] × batch sizes [16, 32, 64] = 9 experiments. It's exhaustive but exponentially expensive as more hyperparameters are added. Random search samples random combinations from specified ranges — surprisingly, it often finds better configurations than grid search because it explores the space more evenly (Bergstra & Bengio, 2012).

Bayesian Optimization

Bayesian optimization uses a probabilistic model (typically a Gaussian process or tree-based model) to predict which hyperparameters are likely to perform well based on past experiments, then prioritizes those regions. Libraries like Optuna, Ray Tune, and W&B Sweeps implement this. For expensive experiments (training a model takes hours), Bayesian optimization's efficiency advantage over random search is significant — it typically finds good configurations in 3–5x fewer experiments.

Practical Tips

Start with established defaults for your architecture (published learning rates, batch sizes, etc.), then tune the most impactful parameters first. For LLM fine-tuning, learning rate is almost always the most important (try 1e-5 to 5e-4). For LoRA, rank (4–64) and alpha (typically 2× rank) matter most. Use early stopping to cut unpromising experiments short. Log everything to W&B or similar — you'll want to compare runs and understand what worked.

Conceitos relacionados

← Todos os termos
ESC