Learn / How LLMs Actually Work
The Transformer block
Self-attention, causal masking, multi-head, LayerNorm, and the full block.
Start free, no card
10 lessons a month on the free tier.
Lessons in this class
Self-attention from scratch
The one mechanism at the heart of every Transformer.
- See attention before you build it
- Query-key scores
- Scale it
- Softmax into weights
- Weighted sum of values
Causal masking
Stop the model from peeking at the future it's predicting.
- A lower-triangular mask
- Block the future with -inf
- Softmax respects the mask
Multi-head attention
Run several attentions in parallel and combine them.
- Split into heads
- Attention per head
- Concatenate and project
LayerNorm and the feed-forward network
The two sublayers that sit around attention.
- LayerNorm
- The GELU activation
- The feed-forward network
Assemble a Transformer block
Wire attention and the FFN together with residuals.
- A residual connection
- Pre-norm, two sublayers
- Stack it
How CodeTrain teaches this
No videos and no multiple-choice quiz at the end. Each lesson is a handful of small steps in a real editor. You type the code yourself, it runs, and the tutor reviews what you actually wrote. It will not hand you the answer, and the step doesn't advance until your code passes. What you get at the end is a record of which steps you wrote unaided, not a completion percentage.