
Sebastian Raschka's step-by-step code for building, pretraining and fine-tuning a GPT-style model.
“Every chapter is a working notebook, so you build each piece of an LLM yourself instead of reading about it.”
The best hands-on way to really understand how an LLM works: you build one, line by line.
Builds a GPT from tokenizer and attention to pretraining and finetuning in plain PyTorch
Small notebook cells, each step explained before the next one builds on it
By Sebastian Raschka, an LLM researcher; 109k stars and an active issue tracker
Every chapter is notebooks you run yourself, with exercises and solutions
Tokenization, attention, GPT architecture, pretraining, classification and instruction finetuning, plus bonus LoRA/DPO
Maintained through 2026 with bonus material on newer architectures
Chapters follow the book in order, with setup guides for each
All code is free on GitHub; the book is optional
Pure code and notes, nothing pushed at you beyond a book link
Reviewed by the Hive editors on 30 Nov 2026 from 1 page read. High confidence.
Nobody has tagged this on X yet. Reply to a post about it and tag @resourcehivebot to be the first.
Picked by the Hive editors · Report a problem