The transformer

Step 7 of 10 in NLP · Build · Hard

Self-attention lets every token look at every other token in parallel. Stacks of attention + MLP blocks with residuals and LayerNorm make the transformer.

Build it

  1. Attention & a GPT block

    Scaled dot-product attention with causal mask, multi-head attention, then a full GPT block.

    Done when: Matches PyTorch's attention given the same weights.

  2. Tiny GPT

    Train your GPT on tiny-shakespeare.

    Done when: Lower validation loss than your LSTM.

Resources

Earn this star

On the map, you log what you built. Finish the step and its star lights.

Open this step on the map