Weight Decay › Summary

Michael BrenndoerferJanuary 27, 20262 min read
Language AI HandbookAll chapters
Part 32 of 67Training Optimization
Chapter 235Weight Decay › Summary
Reading section 10 of 11 · Summary · 2 minSection 10 of 11 · 2 min

Book contents

Section 10 of 11 · 2 min read

Weight Decay › SummaryOne section · Sections in this chapter10 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Weight decay adds a penalty proportional to the squared magnitude of model weights to the training loss, discouraging large weights and encouraging solutions that generalize better. The key ideas from this chapter are:

  • L2 regularization adds λ2∥θ∥22\frac{\lambda}{2} \|\theta\|_2^2 to the loss, producing a (1−ηλ)(1 - \eta\lambda) shrinkage factor on weights at each update step. This is mathematically equivalent to weight decay for SGD but not for adaptive optimizers.
  • Decoupled weight decay (AdamW) applies the weight decay term directly to parameters rather than through the loss gradient, making sure uniform regularization across all parameters regardless of their gradient history. This outperforms standard Adam with L2 regularization for most large-scale training setups.
  • Selective application matters: bias terms and layer normalization parameters are typically excluded from weight decay to preserve training stability. The standard heuristic excludes all one-dimensional parameters.
  • Coefficient selection typically starts around λ=0.01\lambda = 0.01 for transformer training and is tuned based on dataset size and model capacity, with larger values for smaller datasets. Published configurations from BERT (0.010.01), GPT-3 (0.10.1), and LLaMA (0.10.1) provide useful starting points.
  • The learning rate coupling means effective regularization per step scales with both λ\lambda and the learning rate, which is worth considering when using aggressive learning rate schedules.
  • Fine-tuning requires care: standard weight decay pulls weights toward zero, not toward the pretrained initialization, which can hurt fine-tuning on small datasets. Use smaller λ\lambda or L2-SP regularization when adapting pretrained models.

The next chapter covers gradient accumulation, another training optimization technique that addresses the practical constraint of GPU memory limits by simulating large batch training through accumulated gradient updates.