ML MATH & LINEAR ALGEBRA · INTERVIEW QUESTION
Explain learning rate scheduling strategies. Which are most effective?
🔴 advanced · Calculus & Optimization
Hint: Think about warm-up, cosine annealing, and one-cycle policy.
Answer
Learning rate schedules adjust during training:
1. Step decay: reduce by factor every epochs
2. Exponential decay:
3. Cosine annealing (most popular):
4. Warm-up: linearly increase from 0 to target over initial steps. Essential for transformers.
5. One-cycle: warm up → cosine decay below initial LR.
python
# Best practice for LLM training
optimizer = torch.optim.AdamW(model.parameters(), lr=3e-4)
scheduler = torch.optim.lr_scheduler.CosineAnnealingLR(
optimizer, T_max=total_steps, eta_min=1e-6
)
# With warmup (using transformers library)
from transformers import get_cosine_schedule_with_warmup
scheduler = get_cosine_schedule_with_warmup(
optimizer, num_warmup_steps=2000, num_training_steps=100000
)Default for LLM training: AdamW + linear warmup (2000 steps) + cosine decay.
Related questions
- Derive the gradient of the cross-entropy loss for softmax output.
- What is the difference between convex and non-convex optimization? Why does it matter in deep learning?
- What are gradients, Jacobians, and Hessians? When do you use each in ML?
- What is gradient descent? Explain the intuition behind it.
- What is the vanishing/exploding gradient problem? How do modern architectures solve it?