Review

Review the residual-stream equations, normalization calculations, norm placement, position-wise MLP, activations and gates, dropout modes, stacking, parameter counts, and block audit sequence.

A Transformer block preserves a model-width residual stream while two branches update it. Under the pre-norm convention used in this subject,

u=x+Attention(N1(x)),y=u+MLP(N2(u)).u=x+\operatorname{Attention}(N_1(x)),\qquad y=u+\operatorname{MLP}(N_2(u)).

What You Should Be Able to Reconstruct

  • Residual stream: distinguish the persistent stream from temporary branch updates and calculate both additions.
  • LayerNorm: calculate per-token mean and population variance, normalize the feature axis, then apply learned gain and bias.
  • RMSNorm: scale by the root mean square without subtracting the mean.
  • Operation order: write and calculate both pre-norm and post-norm forms.
  • Position-wise MLP: derive projection shapes, parameter counts, and the independence of different sequence positions.
  • Activation or gate: name the exact nonlinear operation and compare it under a common input or parameter budget.
  • Dropout: separate training from evaluation and state probability and placement.
  • Stacking: preserve (B,T,dmodel)(B,T,d_{model}) while using distinct parameters at different depths unless sharing is explicit.

One Compact Numerical Check

For r=[1,2,3,4]r=[1,2,3,4]:

  • LayerNorm has mean 2.52.5 and population variance 1.251.25;
  • RMSNorm has root mean square 7.52.738613\sqrt{7.5}\approx2.738613;
  • the normalized outputs differ because only LayerNorm subtracts the mean.

For any residual branch FF, remember that

x+F(N(x))N(x+F(x))x+F(N(x))\ne N(x+F(x))

in general. Shape equality does not imply functional equality.

Audit Before You Trust a Block

  1. Write the equations in execution order.
  2. Label every intermediate shape.
  3. Check normalization one token record at a time.
  4. Change one position and test MLP independence.
  5. Zero one branch at a time and inspect the changed downstream input.
  6. Test dropout separately in training and evaluation modes.
  7. Count parameters from declared projection shapes and bias conventions.

The next exercises require these calculations without relying on a framework block whose internal choices remain hidden.

Pause and reflect

What can you now explain without looking back, and what should you revisit? The note stays with this review.

Review

Not marked done.