AI Hints
Home›Fine-Tuning LLMs Tutorial›Results, Loss and Hyperparameters
Fine-Tuning LLMs · Lesson 54 of 120

Hyperparameters That Matter

What to tune first.

⏱ 2 min read▶ Video at 1:24:48🎓 Free
Watch this lesson in the Fine-Tuning LLMs courseWatch on YouTube ↗Full Fine-Tuning LLMs course

Settings you choose before training are called hyperparameters. There are many. But a few matter far more than the rest. Here they are, in order.

  • Settings chosen before training
  • Called hyperparameters
  • A few matter most

Tune these, in this order

First, the learning rate. It has the biggest effect. Try two times ten to the minus four, then half, or double. Second, the number of epochs. One to three, watching the eval loss. Third, the LoRA rank. Eight to sixty four. Fourth, the target modules. All linear usually wins. And fifth, the batch size, which mostly affects speed and memory.

#HyperparameterTypical range
1learning_rate1e-4 to 4e-4
2num_train_epochs1 to 3
3r (rank)8 to 64
4target_modules"all-linear"
5batch size4 to 32, memory permitting

Change one thing at a time

A golden rule. Change one setting at a time, and keep notes. If you change three things, and the result improves, you won't know why. And always compare on the same test set. Later, we'll build a proper way to compare runs.

keyvalue
Changeone setting at a time
Keepnotes for every run
Compareon the same test set
Latera proper comparison

Quick check

Let's check. Which hyperparameter usually has the biggest effect on fine-tuning? Pause, and think about it. The answer is A, the learning rate.

Quick check
Which hyperparameter usually matters most?

Summary

Let's recap. Tune the learning rate first, then epochs, then rank. Use all linear. And change one thing at a time. Next, saving our adapter.

Key takeaways
  • Learning rate first
  • Then epochs, rank
  • One change at a time
Next up: Saving Adapters — small files, big results