Overview: what you’re building
You’ll build a minimal GPTModel class in PyTorch that does four things:
- Turns token ids and positions into embeddings
- Runs them through
Nstacked Transformer blocks - Maps the hidden states to vocabulary-sized logits with a final linear layer
- Supports an autoregressive forward pass and a small script to check parameter count and a dummy forward
Here’s the rough structure we’re aiming for:
Rendering diagram…
You’ll end up with a file you can actually run, something like:
bashpython gpt_model.py
that prints the number of parameters and runs a dummy forward pass without errors.
1 / 6