Build a DeepSeek Model (From Scratch)

you own this product
Raj Abhijit Dandekar, Rajat Dandekar, Sreedath Panat, Naman Dwivedi
  • November 2026
  • ISBN 9781633434325
  • 320 pages
  • printed in black & white
print book available Dec 1, 2026

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


Build a DeepSeek Model (From Scratch)
Look inside
"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."

what's inside

  • Build all the key DeepSeek innovations—from scratch!
  • Improve inference with Multi-Head Latent Attention and RoPE
  • Effectively train a Mixture-of-Experts model
  • GRPO reinforcement learning for reasoning

about the reader

For intermediate-to-advanced ML engineers, AI researchers, and graduate students comfortable with PyTorch and deep learning fundamentals.

about the authors

Raj Abhijit Dandekar (MIT), Rajat Dandekar (Purdue), and Sreedath Panat (MIT) co-founded Vizuara Labs, which offers dozens of training courses on AI agents and applications that make AI research and development accessible and practical. Naman Dwivedi is an AI researcher.

Builds a mental model that will make you a better LLM builder and user.

Andrew R. Freed, IBM

Demystifies DeepSeek’s efficiency and makes advanced model training accessible to anyone.

Nimrita Koul, REVA University Bangalore Karnataka

A unique book that actually builds DeepSeek’s innovations from first principles instead of just describing them.

Yun Jin, Fireworks.AI

Derives modern LLM architecture instead of portraying it: each technique arrives as a naive version that gets broken and rebuilt, so you learn why Multi-Head Latent Attention and DeepSeek-MoE look the way they do. It all runs on a laptop, which makes the DeepSeek stack something you can build rather than only read about.

Andrey Lukyanenko, Meta
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build a DeepSeek Model (From Scratch) Build a DeepSeek Model (From Scratch) ebook for free
Close
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Build a DeepSeek Model (From Scratch) Build a DeepSeek Model (From Scratch) ebook for free