Premium
Build an LLM from Scratch
Build a small GPT-style language model step by step, from the maths and tokens to a model that follows instructions.
Last updated Estimated reading time: 52minutes
Enrolling is free and keeps track of your progress.
Some lessons need Premium
One lesson is free to start now. The remaining 18 lessons are part of Premium membership. Log in if you’re a member, or see what membership includes.
About this course
Large language models can feel like magic. This course takes the magic apart by building one yourself, one piece at a time, so you understand what happens between the text you type and the answer you get back.
You start with the maths you need, vectors and matrices, and see how models handled sequences before transformers. Then you turn text into tokens and embeddings, build attention from scratch, and assemble the blocks into a complete GPT-style transformer. Finally, you pretrain the model, generate text with it and fine-tune it to follow instructions.
Who it's for: developers who know some Python and want to understand how LLMs work from the inside, not just how to call them.
What you’ll learn
- Explain how a large language model turns text into predictions
- Build a byte-pair encoding tokenizer
- Implement self-attention and multi-head attention in PyTorch
- Assemble a GPT-style transformer model
- Pretrain the model and generate text
- Fine-tune the model to follow instructions
Course outline
7 sections · 19 lessons
Section 1
Foundations
Section 2
Intro to transformers
Section 3
Text and tokens
Section 4
Attention
Section 5
The transformer
Section 6
Pretraining
Section 7
Fine-tuning
