Learning-rate schedule
Training nudges every weight a little after each batch; the learning rate is how big that nudge is. The paper does not keep it fixed: it starts tiny, grows for a warm-up period, then shrinks slowly. Change the two settings and watch the curve.
- yours (512, 4000)
- the paper (512, 4000)
- our model (64, 800)
The rate peaks at step 4000: 0.000699.
| step | Yours | Paper (512, 4000) | Ours (64, 800) |
|---|---|---|---|
| 1 | 0.000000 | 0.000000 | 0.000006 |
| 100 | 0.000017 | 0.000017 | 0.000552 |
| 800 | 0.000140 | 0.000140 | 0.004419 |
| 4,000 | 0.000699 | 0.000699 | 0.001976 |
| 20,000 | 0.000313 | 0.000313 | 0.000884 |
Our recorded training run
Our model trained for 4000 steps with d_model 64 and warmup_steps 800, in 239 seconds on one laptop core. The loss is how surprised the model is by the right German word: it falls fastest while the rate is high. The training loss includes label smoothing, so it cannot reach 0; the plain loss shows how sure the model became.
- training loss (with label smoothing)
- plain loss
The formula, symbol by symbol
lrate = d_model−0.5 · min(step_num−0.5, step_num · warmup_steps−1.5)
step_num counts the training steps. For the first warmup_steps steps the second term is the smaller one, so the rate rises in a straight line; after that the first term takes over and the rate falls as one over the square root of the step. The peak is exactly at step warmup_steps. d_model^−0.5 scales the whole curve down for bigger models, whose weights react more to each nudge.
Why warm up? At the start the weights are random and the model's early gradients point in poor directions; big steps then would throw it off. A short, gentle start lets the optimiser (Adam) collect reliable estimates first.
In the paper (5.3)
Adam with β1 = 0.9, β2 = 0.98 and ε = 10^−9, and warmup_steps = 4000. With d_model = 512 the peak rate is about 0.0007, reached after 4,000 steps; our model's peak, with 64 and 800, is about 0.0044.