A transformer block is a wiring pattern. This lesson shows the components and the order in which data moves through them.

highlighted = computed this step

Stacking the pieces

A transformer block wires attention and an MLP together with residual connections and normalization. The flowchart shows which component feeds which.

inputattentionMLPoutput\text{input}\rightarrow\text{attention}\rightarrow\text{MLP}\rightarrow\text{output}
Transformer block wiringExact wiring with named boundary flags.Transformer block wiringExact wiring with named boundary flags.transformer block wiringwiring is exact; named components carry no numeric outputinput hexactdisplayed vector+ positional encodingnamed (sin/cos)attentionnamed (softmax)residual addexactvector additionlayernormnamed (√)MLP-ReLUexactrational ReLU wiringresidual addexactvector additionlayernormnamed (√)outputexact

The block order

The validated order is input, positional encoding, attention, residual add, layernorm, MLP-ReLU, residual add, layernorm, output.

wiring order is validated\text{wiring order is validated}
Transformer block wiringExact wiring with named boundary flags.Transformer block wiringExact wiring with named boundary flags.transformer block wiringwiring is exact; named components carry no numeric outputinput hexactdisplayed vector+ positional encodingnamed (sin/cos)attentionnamed (softmax)residual addexactvector additionlayernormnamed (√)MLP-ReLUexactrational ReLU wiringresidual addexactvector additionlayernormnamed (√)outputexact

Summary

This lesson is about wiring, not hidden arithmetic. Exact nodes and named-boundary nodes are flagged before any lesson uses the residual example.

flowchart nodes carry exact or named flags\text{flowchart nodes carry exact or named flags}
Transformer block wiringExact wiring with named boundary flags.Transformer block wiringExact wiring with named boundary flags.transformer block wiringwiring is exact; named components carry no numeric outputinput hexactdisplayed vector+ positional encodingnamed (sin/cos)attentionnamed (softmax)residual addexactvector additionlayernormnamed (√)MLP-ReLUexactrational ReLU wiringresidual addexactvector additionlayernormnamed (√)outputexact