I teach AI/ML at S30 and made a runnable Kaggle notebook for people who want to see next-token training rather than call a model API. It uses NumPy, a four-line embedded corpus, and randomly initialized weights. No external dataset, GPU, internet access, or pretrained checkpoint is needed.
What is in the notebook:
- character IDs and shifted input/target windows (teacher forcing)
- single-head causal self-attention, including a check that future-token attention is zero
- cross-entropy and manual backpropagation through attention
- 150 SGD updates, a loss curve, and token-by-token sampling
The Kaggle CPU run completed successfully in 21 seconds. Batch training loss went from 3.367 to 3.177. The generated characters are still rough: there are only 157 training characters, no positional embeddings, and no held-out evaluation. This is a mechanics exercise, not ChatGPT or a useful chatbot.
Notebook: https://www.kaggle.com/code/jaspindersingh83/tiny-gpt-style-lm-from-scratch-numpy
There is an optional video walkthrough linked inside. I created both the notebook and the video. If you fork this, I would be interested in which change helps most: a larger corpus, learned positions, or a validation split.