Ask what should change when the equation is manipulated, then let the visualization test that expectation.
Foundation Lab
Gradient Clipping & Explosion Prevention
Essential for training LLMs—without clipping, gradients explode on certain batches
\tilde{g} = \min(1, c / \|g\|) \cdot gSelected Foundation Object
Keep the equation fixed; move through the evidence.
Clipping preserves gradient direction while bounding step size—you still go the right way
\tilde{g} = \min(1, c / \|g\|) \cdot gUse the runnable panel, the key equation, and canonical papers as separate forms of evidence for the same object.
The useful learning product is the reusable mechanism you can carry into another model, paper, or engineering tradeoff.
Use prerequisites, dependents, and semantic links to repair the next gap without leaving the object behind.
Why It Matters for Modern Models
- Essential for training LLMs—without clipping, gradients explode on certain batches
- GPT-3 used gradient clipping of 1.0; it's a standard hyperparameter in all LLM training
- Explains why very deep networks (100+ layers) require careful architectural choices
What Tutorials Skip
What is still poorly explained in textbooks and papers:
- Clipping preserves gradient direction while bounding step size—you still go the right way
- Bad batches (outliers) cause gradient spikes; clipping prevents single batches from destabilizing training
- Gradient norm is a useful diagnostic: spikes often precede training instabilities
Interactive Visualization
Core Math (Optional Deep Dive)
If you want intuition first, start with the key equation and the visualization. Come back here for the full walkthrough.
Gradient norm clipping: Scale gradient if norm exceeds threshold:
Value clipping (per-coordinate):
Why gradients explode: In deep networks, gradients are products of Jacobians:
If , gradients grow exponentially with depth.