As asked
Vanishing and exploding gradients in deep transformers: causes and solutions specific to large-scale LLM training. Explain what mathematical conditions lead to each, describe how residual connections and pre-norm placement specifically address them in a 96-layer transformer, and explain why gradient clipping is still necessary even with these architectural fixes.
Sample answer outline
Vanishing gradients occur when the gradient magnitude is repeatedly multiplied by values less than 1 during backpropagation through many layers, causing early-layer updates to effectively zero out. Exploding gradients occur when those multiplications exceed 1, causing instability. Solutions include residual connections (adding the input to the output bypasses layers whose gradients would vanish), normalization layers (LayerNorm stabilizes activation scale), careful initialization (Xavier or Kaiming scales weights to maintain variance through layers), and gradient clipping for the exploding case.
Expect these follow-ups
- Why did LSTMs address vanishing gradients in RNNs better than plain RNNs, and is that still relevant given transformers?
- What is the role of the residual stream in a transformer specifically in preventing gradient vanishing?