
Build a DeepSeek Model (From Scratch)
Raj Abhijit Dandekar, Rajat Dandekar, Sreedath Panat, Naman Dwivedi
- Publisher
- Manning
- Published
- 24 Nov 2026
- Subjects
- Computer scienceMathematics
Editions & prices
| Format | ISBN | Publisher price |
|---|---|---|
| Print + ebook | 9781633434325 | $59.99 |
| Ebook | — | $47.99 |
About this book
"An outstanding resource for anyone who wants to understand LLMs not just conceptually, but at the level where architectural details and training decisions really matter.” —Dmitry Efimov, Amazon The open-weight DeepSeek model upended the LLM world with frontier-level performance at a fraction of the training cost. This book gives you an insider’s understanding of the model’s advances and architectural breakthroughs as you build a small-scale version piece by piece. By the final chapter, you’ll have a working mini-DeepSeek running on your laptop, along with an “I built it myself” understanding of its internals. Build a DeepSeek Model (From Scratch) takes a problem-solution approach to each of DeepSeek’s major innovations. You’ll see how Multi-Head Latent Attention (MLA) compresses the memory of earlier tokens the model keeps on hand as it generates text, sharply reducing its memory needs. You’ll also explore its Mixture of Experts architecture—a collection of small specialist networks that expand the model’s capacity while activating only a fraction of the model for each token. You’ll start with a basic Mixture-of-Experts layer, then introduce DeepSeek’s improvements: smaller experts for finer specialization, shared experts for common knowledge, and better distribution of work among them. Next comes Multi-Token Prediction, which trains the model to anticipate several upcoming tokens rather than just the next one, helping it learn more from the same training text. This is followed by a deep dive into how DeepSeek’s approach to FP8 quantization trades lower numerical precision for faster computation and lower memory use, without hurting model quality. You’ll explore DeepSeek’s approach to training by building a full training pipeline and learn how it manages the communications overhead associated with training MoE models. The book closes with readable accounts of DeepSeek’s reasoning training and distillation: how Group Relative Policy Optimization (GRPO) helps the model learn from successful attempts at a problem, and how smaller models learn by comparing several of its own attempts at a problem and favoring the better ones. You’ll even find head-to-head comparisons that let you measure the gains of key features in concrete terms. Across eight substantial chapters, the story unfolds in clear, plain English and mathematical walkthroughs, illuminating diagrams, and PyTorch code you write yourself. Reviewer Sakshi Mahendru of Palo Alto Networks summarized his feelings: "An incredible pedagogical feat that captures the exact essence of the DeepSeek paper and makes it digestible by grounding architectural theory in from-scratch empirical experiments."
Source: manning · first seen 2026-11-24