AI GLOSSARY · AI CONCEPTS

Weight decay

Markdown version

Definition

Weight decay is a training technique that shrinks a model's weights toward zero as it learns, discouraging overly large weights. For plain stochastic gradient descent it matches L2 regularization, but the two differ for adaptive optimizers such as Adam.

Also called: L2 regularization, L2 regularisation, weight decay Adam.

In plain language

Weight decay is a gentle pull that keeps a model's internal numbers, called weights, from growing too large while it trains. Imagine a student told to keep every answer simple so they do not memorise quirks of the practice exam. The pull is meant to help the model do well on new data, but it is a setting someone has to choose: too little has no effect and too much stops the model learning. It is a training-time choice, so it does not matter when you only use a finished model. The name is confusing because 'weight decay' and 'L2 regularization' are sometimes used as if they were the same thing, and with some optimizers they are not.

Technical definition

Google's ML glossary defines L2 regularization as a type of regularization that penalizes weights in proportion to the sum of the squares of the weights. Loshchilov and Hutter (arXiv 1711.05101) state that L2 regularization and weight decay are equivalent for standard SGD when weight decay is rescaled by the learning rate, but not for adaptive gradient algorithms such as Adam, and propose decoupling weight decay from the loss-based gradient step. PyTorch's AdamW documentation describes a weight_decay coefficient where decay does not accumulate in the momentum or variance estimates, and refers to that paper.

Worked examples in this catalogue

Catalogue examples point at a skill, guide or coding tool listed on this site, with what to run and what you see. An example marked illustrative describes the item from its own documentation; it was not executed for this page. Platform Scores are our assessment under a published method, not a safety guarantee.

  1. Skill by Skill Almanac · Illustrative, not executed

    llm-eval-test-sets 57/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill builds and validates an eval dataset for any LLM feature, with a checker for duplicates, missing graders, imbalance and leakage.
    Why it exercises the concept
    Weight decay is judged by performance on held-out data, which needs a clean test set. The catalogue has no training skills, so this is a contrast case that does not tune weight decay.
  2. Skill by Skill Almanac · Illustrative, not executed

    split-leakage-check 53/100 · Provisional, not yet measuredScored · Method v0.2 · How we score

    What you see
    The skill checks train, validation and test files for duplicates, shared groups, time and label leakage and prints JSON.
    Why it exercises the concept
    Comparing weight-decay settings on a leaky split would give misleading results. The skill checks the split and does not set any training option.
  3. Coding tool · Illustrative, not executed

    Asking a coding agent to explain a training script

    What to try
    claude
    What you see
    Claude Code starts an interactive session in your project, where you can ask it to read a training script and point out where the optimizer and its weight_decay setting are configured.
    Why it exercises the concept
    Weight decay usually shows up as one argument to an optimizer in code. The agent can locate it. Illustrative only, and the agent's explanation should be checked against the PyTorch docs.

How it shows up when you use agents

You meet weight decay in training code, not in everyday agent use. If you ask Claude Code or Cursor to write a fine-tuning or training script, it will often include an optimizer line with a weight_decay value. That number came from the agent's defaults or examples, not from tests on your data.

What breaks when it is misunderstood: you copy a value without knowing what it does, or you switch from SGD to Adam and assume the same setting keeps its meaning. According to the AdamW paper, L2 regularization and weight decay differ under Adam, which is why AdamW exists. The safer habit is to read the optimizer's documentation, change one setting at a time, and compare runs on a held-out validation set.

Next action: ask the agent which optimizer it chose, whether the decay is decoupled, and why it picked that value. See Regularization, Overfitting and Learning rate.

Common confusions

  • Weight decay versus L2 regularization. The same for plain SGD when decay is scaled by the learning rate, not the same for Adam, according to Loshchilov and Hutter.
  • Adam versus AdamW. AdamW applies the decay separately from the loss-based update. PyTorch documents it as the variant where decay does not accumulate in the momentum or variance.
  • Training setting versus model property. Weight decay is chosen during training and is not a feature of a model you only use.
  • Myth. That more decay improves results. Too much can leave a model that fits the training data poorly.

Terms that mention Weight decay

2 terms mention this one

More in AI concepts

Next steps

  1. llm-eval-test-sets A skill that exercises it.
  2. Regularization Related term.
  3. Overfitting Related term.
  4. All glossary terms A to Z and by family.

Sources

Definitions are written by Skill Almanac from these sources. An independent review of the sources and examples is in progress. Wikipedia is never the only source.

Review record

Independent review in progress

Drafted by claude-sonnet-5-5. An independent review of its sources and examples is in progress.

This entry is still in review, so it is not listed in search engines yet.

Change log (2)
  • : First version.
  • : Verifier pass: removed AdamW alias.