Capstone: train, evaluate and explain your own small GPT
A project brief for the Build an LLM course: choose a dataset, train your model with a proper train/validation split, run controlled experiments, generate with and without a KV cache, map your code to PyTorch, and deliver a short report. Includes deliverables, a four-step plan, a rubric and a checklist.
By Sandip Maity, Applied AI Engineer
You have built a tokenizer, attention, a transformer block, an autograd engine, a training loop and a sampler, and you have seen how each maps to PyTorch and to modern upgrades. The capstone turns that knowledge into a small, finished project that shows you understand what you built, not only that you ran it.
#The brief
Train a small character-level or byte-pair GPT on a text you choose, evaluate it properly, and explain what you found. The model can be tiny. The quality of the evidence is what counts.
Good choices of text: a book from Project Gutenberg, your own writing (with permission for anyone quoted), a list of names or place names, song titles, recipe titles, or code in one language. Avoid anything you do not have the right to use, and avoid text with personal data.
- 1Step 1: data and baselinesplit, uniform baseline, character statistics
- 2Step 2: trainfirst model, loss curve, samples
- 3Step 3: experimentsone change at a time, fixed seed
- 4Step 4: generation and mappingcache check, PyTorch version
- 5Step 5: reportfindings, failures, next steps
#Deliverables
- Data note (half a page): the source, its licence, its size, how you cleaned it, and the train and validation split (hold out at least 10 percent, cut at a boundary such as a chapter, not randomly inside it).
- Baselines: the loss of a uniform guess ( for vocabulary size ) and, if you like, a simple frequency model, so you can say how much your model learned.
- Training run: your script, settings, seed, hardware and time, with training and validation loss plotted together (the training lab).
- Experiments: at least three controlled changes, each changing exactly one thing, for example width, number of heads, context length, learning rate or dropout, with results in a table.
- Generation: samples at several temperatures and with top-k and top-p, plus a test that generation with and without the KV cache gives identical tokens at temperature zero (generation lesson).
- The PyTorch mapping: a table (or a short port) that names the PyTorch equivalent of each part of your code (scaling and the PyTorch mapping).
- Report (2 to 3 pages): what you did, what the numbers show, what failed, and what you would try next.
Pro content
Keep reading with Inference Academy Pro
Unlock the rest of this lesson, plus every advanced lesson, hands-on lab, the larger playground models and completion certificates.
Still to come in this lesson
- A plan
- Reading your results
- Rubric (100 points)
- Common mistakes
- Checklist before you finish
- Exercise
- Where to go next
You will be able to answer
- Why must the validation text be held out before you train?
- You change the learning rate and the number of heads in one run and the loss improves. What do you know?
- Which result would show your KV-cache implementation is correct?
- A loss of 2.2 on a 27-character vocabulary should be compared with what baseline?
- What is the strongest sign that a report is honest?