Home › Courses › Transformers & LLMs from Scratch
Pre-train a real 124M parameter GPT: tokenizer, data pipeline, training and evaluation
5 phases. 40 lessons. 40 labs. 1 capstone. The transformer architecture from the ground up — self-attention from scratch, multi-head attention, positional encoding, the full encoder-decoder, BERT and GPT families, and then building a real LLM: tokenizer from scratch, data pipeline, pre-training a 124M parameter GPT, instruction tuning, RLHF, DPO, and modern architecture innovations (MoE, KV cache, flash attention, speculative decoding, quantization). You pre-train a real LLM, not just fine-tune one.
5 phases · 40 lessons · 40 labs · 1 capstone
Take Deep Learning from Scratch first — this course builds on it.
Self-Attention & Multi-Head Attention · Positional Encoding (Sinusoidal, RoPE, ALiBi) · BERT & GPT Architecture · BPE Tokenization from Scratch · LLM Pre-Training (124M GPT) · Instruction Tuning (SFT) · RLHF & DPO Alignment · KV Cache, Flash Attention & Speculative Decoding · Quantization (INT8, GPTQ, AWQ, GGUF) · Mixture of Experts (MoE)
PyTorch · Hugging Face Transformers · NumPy · tiktoken · Weights & Biases
It's building the transformer architecture from the ground up — self-attention, multi-head attention, positional encoding, encoder-decoder — and then using that understanding to pre-train a real 124M parameter GPT model. You build the tokenizer, the data pipeline, the training loop, the instruction tuning, and the alignment. By the end, you've built a complete LLM, not just used one.
You build LLM systems — fine-tuning, inference, evaluation. But you understand every component at the implementation level. When generation quality drops, you know whether it's the tokenizer, the model architecture, the training data, or the inference setup. When a new architecture is released, you can read the paper and understand what changed.
Every company wants to use LLMs, but most engineers treat them as APIs. The engineer who pre-trained a GPT from scratch is the one who can build custom fine-tuning pipelines, optimize inference, and implement novel architectures from papers. That's the engineer companies pay top dollar for.
It is not a prompt engineering course. It is not a LangChain tutorial. It is not about using the OpenAI API. This course is about building the model itself — the architecture, the training, the alignment — from scratch. If you want to use LLMs as a black box, take ML & AI Engineering instead.
Yes — this course uses PyTorch, autograd, backpropagation, and training loops throughout. Deep Learning from Scratch builds those foundations; this course applies them to the transformer architecture and LLM pre-training.
Yes — a 124M parameter model is small enough to train on a single GPU (or even a good CPU with patience). The course is designed so the capstone is achievable on consumer hardware, while teaching you the same pipeline used for billion-parameter models.
ML & AI Engineering covers transformers in 6 lessons — enough to fine-tune a pre-trained model. This course spends 20 lessons building attention from scratch, implementing BPE tokenization, pre-training a GPT model, implementing RLHF/DPO, and covering modern architecture innovations. It's the difference between using an LLM and building one.
A pre-trained 124M parameter GPT model with your own tokenizer, data pipeline, training loop, instruction tuning, and evaluation — plus a complete LLM pipeline you can extend for any future LLM project. And the ability to read any LLM paper and understand the architecture.
RLHF · KV Cache · Mixture of Experts (MoE) · Quantization · Transformer · DPO (Direct Preference Optimization) · Encoder-Decoder · Fine-Tuning
Deep Learning from Scratch · Multimodal AI Systems · NLP & Speech Processing · ML & AI Engineering
Create a free account — the opening phases of 24 of 30 courses are free, no credit card. Or see Pro pricing.
All courses · Pricing · About · FAQ · Glossary