Build a Reasoning Model (From Scratch)

you own this product
  • June 2026
  • ISBN 9781633434677
  • 440 pages
  • printed in color
print book available Jul 2, 2026
  • 电子书 pdf, ePub, 在线阅读
  • 印刷版 包含电子书
  • 在线+音频 阅读和收听
  • 订阅可用 免费或 50% 折扣
Look inside
"An exceptional deep dive into the next frontier of AI.”
—Aman Chadha, Google


Build a Reasoning Model (From Scratch) is a practical guide to understanding how modern reasoning-oriented LLMs work by building their core methods step by step. The book tells a clear engineering story: start with a conventional pre-trained LLM, learn how text generation works, build reliable evaluation tools, improve reasoning through inference-time methods, then move into training-based approaches such as reinforcement learning and distillation.

The progression is deliberate. Early chapters establish the baseline model and explain text generation, KV caching, and evaluation with math verifiers. The middle chapters show how reasoning can be improved without changing model weights, using chain-of-thought prompting, sampling, self-consistency, response scoring, and self-refinement. Later chapters move to changing the model itself through reinforcement learning with verifiable rewards, GRPO improvements, format rewards, and finally distillation from stronger reasoning models into smaller ones.

The book is especially useful because it implements the core methods from scratch rather than treating them as black-box library calls. Readers see how self-consistency, self-refinement, Best-of-N, and training-based methods actually work, including their cost and latency trade-offs. It also discusses common failure modes, including cases where refinement can make answers worse. Difficult concepts such as softmax, temperature, and top-p sampling are clarified with code-linked explanations and diagrams, and visual workflows make pipelines and scoring methods easier to follow.

Reading the book feels like following a guided technical build rather than a loose survey of AI topics. Each concept is introduced because the project now needs it. Diagrams, roadmaps, code listings, exercises, and repeated workflow summaries help readers stay oriented through advanced material. This structure reflects Sebastian Raschka’s professional strength: explaining complex machine learning topics by making every detail concrete and showing exactly where each section fits in the larger story. He does not treat mechanisms like evaluation, log-probabilities, KL regularization, or distillation as isolated abstractions; he connects them to the goal of making reasoning models understandable and implementable.

Physically and organizationally, the book has eight chapters and seven substantial appendixes. That design keeps the main narrative focused while moving supporting material like references, exercise solutions, model source code, larger models, batching, evaluation alternatives, and chat interfaces into ordered appendixes. The result is a logically flowing book that remains hands-on, navigable, and technically deep without constantly interrupting the central build.
“对人工智能的下一个前沿领域进行了非凡的深入探讨。” —Aman Chadha, Google 从零开始构建推理模型(Build a Reasoning Model (From Scratch))是一本实用的指南,通过逐步构建现代推理导向的大型语言模型(LLM)的核心方法来理解其工作原理。本书讲述了一个清晰的工程故事:从一个传统的预训练 LLM 开始,学习文本生成的工作原理,构建可靠的评估工具,通过推理时方法改进推理能力,然后转向基于训练的方法,如强化学习和蒸馏。 进展是循序渐进的。早期章节建立基线模型并解释文本生成、KV 缓存和使用数学验证器进行评估。中间章节展示了如何在不改变模型权重的情况下改进推理,使用思维链提示、采样、自一致性、响应评分和自我完善。后期章节则通过具有可验证奖励的强化学习、GRPO 改进、格式奖励以及最终从更强的推理模型蒸馏到更小的模型来改变模型本身。 本书特别有用,因为它从头开始实现了核心方法,而不是将它们视为黑盒库调用。读者可以看到自一致性、自我完善、Best-of-N 和基于训练的方法是如何实际工作的,包括它们的成本和延迟权衡。它还讨论了常见的失败模式,包括有时自我完善会使答案变得更糟的情况。像 softmax、temperature 和 top-p 采样这样的困难概念通过代码链接的解释和图表得到了澄清,而可视化工作流程使管道和评分方法更容易理解。 阅读本书感觉就像跟随一个指导性的技术构建过程,而不是对人工智能主题进行松散的调查。每个概念的引入都是因为项目现在需要它。图表、路线图、代码列表、练习和重复的工作流程摘要帮助读者在高级材料中保持方向感。这种结构反映了 Sebastian Raschka 的专业优势:通过使每个细节具体化并确切地展示每个部分在更大的故事中扮演的角色来解释复杂的机器学习主题。他并不将评估、对数概率、KL 正则化或蒸馏等机制视为孤立的抽象概念;他将它们与使推理模型可理解和可实现的这一目标联系起来。 在物理和组织结构上,本书有八章和七个实质性的附录。这种设计使主叙事保持专注,同时将参考资料、练习答案、模型源代码、更大的模型、批处理、评估替代方案和聊天界面等支持材料移至有序的附录中。结果是一本逻辑流畅的书,它保持了实践性、可导航性和技术深度,而不会不断地打断核心构建过程。

what's inside内容概览

  • From-scratch implementations of core LLM reasoning improvements核心 LLM 推理改进的从零开始实现
  • Verifier-based evaluation methods基于验证器的评估方法
  • RL with automatic verifiers for mathematics tasks用于数学任务的带自动验证器的强化学习

about the reader关于读者

For readers who know Python and have some knowledge of machine learning.
关于读者 适合了解 Python 并具备一定机器学习知识的读者。

about the author关于作者

Sebastian Raschka is an LLM Research Engineer with over a decade of experience. He is the author of the bestselling book Build a Large Language Model (From Scratch).
关于作者 Sebastian Raschka 是一位拥有十多年经验的 LLM 研究工程师。他是畅销书《从零开始构建大型语言模型》(Build a Large Language Model (From Scratch))的作者。

Distills the profound ideas in the clearest, most accessible way.以最清晰、最易懂的方式提炼出深刻的思想。

Byron Hsu, LMSYS

Big. Dope. Great read, fun writing.宏大。精彩。好书,文笔有趣。

Chris Alexiuk, NVIDIA

The gold standard for developers wanting to build at the cutting edge of AI.对于希望在人工智能前沿领域进行开发的开发者来说,这是黄金标准。

Omar Sanseviero, Author of Hands-On Generative AI with Transformers and Diffusion Models

A really well-structured, hands-on introduction to reasoning models!一本结构良好、实践性强的推理模型入门读物!

Vinija Jain, Google

An excellent starting point, accessible even to readers with little or no prior working experience with LLMs.一个绝佳的起点,即使是之前几乎没有 LLM 工作经验的读者也能轻松上手。

Arun Prakash, AI4Bharat

Demystifies reasoning models by providing practical, hands-on implementations of cutting-edge techniques.通过提供前沿技术的实际动手实现,揭开了推理模型的神秘面纱。

Fabio Montagna, GraphAware

It doesn’t stay at theory—it walks you from sampling to scoring to iterative refinement with actual code.它不只停留在理论层面——它将带你通过实际代码了解从采样到评分再到迭代改进的全过程。

Toni Ramchandani, MSCI Inc.
4.64.6
Out of 5.0满分 5.0
A graph showing this site's review totals.
Overall Rating总体评分
91%91%
of customers that
buy this product give
it a 4 or 5-Star rating.
Verified Buyer已验证买家
“Great buy”“物超所值”
June 29, 2026 by Pete T. (GB)2026 年 6 月 29 日,作者 Pete T. (GB)
“I have enjoyed reading this book and following the code. The methodology and coding are easy to follow. If anyone wants a straighforward introduction to reasoning models they need look no further. An excellent text. However, at times I have found some of the text to be very repetative and in a few places the reason for taking a particular direction is missing. But these are minor criticisms. I thoroughly recommend this book.”“我喜欢阅读这本书并跟随代码。方法论和编码都很容易理解。如果有人想直接入门推理模型,他们别无选择。一本优秀的教材。然而,有时我觉得有些文字非常重复,而且在某些地方缺少采取特定方向的原因。但这些都是小批评。我强烈推荐这本书。”
Verified Buyer
“Great buy”
June 10, 2026 by Sylvain (Paris, FR)2026 年 6 月 10 日,作者 Sylvain (Paris, FR)
“Very instructive, a collection of relevant techniques to build a reasoning model. I would have expected more impact using RL. But the end to end example can be reproduced easily.”“非常有启发性,是一系列构建推理模型的相关技术。我本期望使用强化学习能产生更大的影响。但端到端的示例可以轻松复现。”
Verified Buyer
“Great deal”“很划算的交易”
May 30, 2026 by Doug M. (Ga, US)2026 年 5 月 30 日,作者 Doug M. (Ga, US)
“Sebastian Raschka books are always interesting and helpful in learning about LLMs. I just finished Build a LLM from scratch and to have the opportunity to continue along the from scratch path was exciting. Manning publications giving us and the authors the ability to read a book in progress is a fantastic idea and helps with continuing learning.”“Sebastian Raschka 的书总是很有趣,对学习 LLM 很有帮助。我刚读完《从零开始构建 LLM》,有机会继续沿着从零开始的道路前进让我很兴奋。Manning 出版社让我们和作者能够阅读正在进行中的书籍是一个绝妙的主意,有助于持续学习。”
Verified Buyer
“Great value”“物超所值”
April 28, 2026 by brian P. (WV, US)2026 年 4 月 28 日,作者 brian P. (WV, US)
“I’m currently working through chapter 6 and have learned a ton. It’s especially valuable after having completed Sebastian’s prior book on LLMs from scratch.”“我目前正在学习第六章,学到了很多东西。尤其是在完成了 Sebastian 之前关于从零开始构建 LLM 的书之后,这本书非常有价值。”
Verified Buyer
“Great buy”
March 15, 2026 by Arnaud G. (FR)2026 年 3 月 15 日,作者 Arnaud G. (FR)
“SOTA tutorial on reasoning models. A must read.”“关于推理模型的最新教程。必读。”

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 Reasoning Model (From Scratch) ebook for free
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 Reasoning Model (From Scratch) ebook for free
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 Reasoning Model (From Scratch) ebook for free
loading book ...