look-ahead optimizer
**Lookahead Optimizer** is a **meta-optimizer that wraps around any base optimizer (SGD, Adam)** — maintaining two sets of weights: "fast weights" updated by the inner optimizer for $k$ steps, and "slow weights" that interpolate toward the fast weights, providing smoother convergence and better generalization.
**How Does Lookahead Work?**
- **Inner Loop**: Run the base optimizer for $k$ steps (typically $k = 5-10$), updating fast weights $phi$.
- **Outer Update**: Slow weights $ heta leftarrow heta + alpha (phi - heta)$ where $alpha approx 0.5$.
- **Reset**: Fast weights are reset to slow weights: $phi leftarrow heta$.
- **Effect**: The slow weights "look ahead" at where the fast optimizer is going, then take a cautious step.
**Why It Matters**
- **Variance Reduction**: The slow weight interpolation smooths out noisy oscillations from the inner optimizer.
- **Exploration**: Fast weights explore aggressively; slow weights move conservatively — the best of both worlds.
- **Drop-In**: Works with any base optimizer. No hyperparameter tuning of the inner optimizer needed.
**Lookahead** is **the cautious co-pilot** — letting a fast optimizer explore freely while taking measured, conservative steps toward the best direction.