Build Large Language Models (LLMs) from Scratch
51 lessons10 topics30h 35mself-paced
About this course
Build a GPT-style large language model from an empty Python file, the same way the frontier labs do it. Vizuara's most popular course walks through all five stages: data preprocessing, attention, architecture, pretraining and finetuning, and by the end you have trained and finetuned your own 124 million parameter GPT-2.
What you will learn
- Tokenisation and byte-pair encoding, input-target pairs, token and positional embeddings
- Simplified, causal and multi-head attention, coded step by step
- The full transformer block with layer normalisation, GeLU and shortcut connections
- The pretraining loop, loss evaluation, temperature scaling and top-k sampling
- Finetuning twice: a spam classifier and an instruction-following assistant
What is included
- 51 lessons with about 31 hours of video
- All Google Colab notebooks
- Seven parts of lecture notes and a 20-minute summary
- Course end test
Who it is for
Anyone comfortable with Python and basic neural networks who wants to understand LLMs from the inside rather than only through an API.
Course curriculum
10 topics • 51 lessons
30h 35mLLM Basics6 items
- Course Introduction
- What are LLMs?
- Pretraining vs Finetuning LLMs
- What are transformers?
- How does GPT-3 really work?
- Stages of building an LLM from scratch
LLM Attention Mechanism6 items
- Introduction to the Attention Mechanism
- Simplified Attention Mechanism - Code from Scratch
- The self attention mechanism with keys, query and values: coded form scratch
- Causal Self Attention - Coded from scratch
- Multi-head Attention - Part 1
- Multi-head Attention - Part 2
LLM Architecture7 items
- Birds-eye view of the LLM architecture
- Layer normalization in the LLM architecture
- GeLU Activation function in the LLM architecture
- Shortcut connections in the LLM architecture
- Coding the entire LLM transformer block
- Coding the 124 million parameter GPT-2 model
- Coding GPT-2 to predict the next token
LLM Pretraining7 items
- Measuring the LLM loss function
- Evaluating LLM performance on real dataset
- Coding the entire LLM pretraining loop
- Temperature scaling in Large Language Models
- Top-k sampling in Large Language Models (LLMs)
- Weight saving and loading
- Pretrained weights from OpenAI
LLM Finetuning10 items
- Introduction to LLM Finetuning
- Dataloaders in LLM Classification finetuning
- Coding model architecture for LLM classification finetuning
- Coding a finetuned LLM Spam Classifier
- LLM Instruction Finetuning introduction
- Data batching in LLM Instruction Finetuning
- Data Loaders in LLM Instruction Finetuning
- Instruction finetuning: Loading pretrained LLM weights
- LLM instruction finetuning training loop: Coded from scratch
- Evaluating finetuned LLMs using Ollama
Build your own GPT1 items
- 20 minutes summary
LLM Data Pre-processing6 items
- Code an LLM Tokenizer
- The GPT Tokenizer: Byte Pair Encoder
- Creating Input-Target Pairs
- What are token embeddings?
- The importance of positional embeddings
- The entire LLM data preprocessing pipeline
Lectures Notes7 items
- Part 1
- Part 2
- Part 3
- Part 4
- Part 5
- Part 6
- Part 7
All Google Colab Code files1 items
- Link to Code files
Course End Test1 items
- Course End Testcourse end test



