Turn the transformer block into a GPT: the autoregressive next-token objective, the causal mask that stops a position from seeing the future, the decoder-only stack, and the language-modeling head and loss — assembling a complete mini-GPT in NumPy, forward and backward.
Welcome to Causal Masking & GPT, the sixth module — where all the parts click together into a real language model. You have attention, multi-head attention, positional embeddings, and the transformer block. The one thing standing between that and a GPT is a rule about time: to predict the next token, a position must never be allowed to peek at the tokens that come after it.
You’ll start with the autoregressive idea — that language modeling is just next-token prediction, done at every position in parallel. Then you’ll implement the causal mask that enforces it, setting the attention scores above the diagonal to negative infinity so each position attends only to itself and the past. You’ll stack causal transformer blocks into the decoder-only architecture that GPT uses, and add the language-modeling head — a projection to vocabulary logits — with the softmax cross-entropy next-token loss whose gradient you’ll derive and check. The guided project assembles the whole thing into a mini-GPT: token and position embeddings, a stack of causal blocks, a final layer norm, and the output head — a complete model, forward and backward, ready for the training loop in Module 7.
Start with Lesson 1, where predicting the next character becomes the only objective that matters.
Complete all 5 lessons to finish the Causal Masking & GPT module.