跳到主内容
@wquguru
精选80Interconnects(RSS)技巧与观点

新书《RLHF:对齐与后训练LLM》发布,作者分享5大核心收获

5 useful things you'll learn in my new post-training textbook (shipping now!)

原文
发到 X

Housekeeping: No voiceover on another quick “launch” post. More essays soon!

家务管理:另一篇快速的“发布”帖子没有配音。更多文章即将推出!

After a few long years of finding time to document my lessons from training open models, my post-training book is done! It’s published by Manning, under the title Reinforcement Learning from Human Feedback: Aligning and Post-training LLMs.

经过几年漫长的时间,我终于找到了时间来记录我从训练开放模型中学到的经验教训,我的训练后书籍完成了!它由 Manning 出版,标题为《从人类反馈中强化学习:对齐和训练后 LLM》。

Telling the story of the book is a useful way to explain why you may want a copy.

讲述这本书的故事是解释为什么你可能想要一本的有用方式。

The book started as a website where I wanted to document key methods of post-training that had potentially no online material explaining them. If there was something, I couldn’t find it. This existed for more topics than you would expect, given post-training was already popular in 2024 (when I bought the domain), and continues to this day. Topics like rejection sampling, outcome reward models, and character training are prime examples. This has helped make the website fairly popular, as it’s still one of the few places discussing these topics at a foundational, intuitive way.

这本书最初是一个网站,我想在那里记录训练后的关键方法,这些方法可能没有在线材料解释。如果有的话,我找不到。考虑到训练后在 2024 年(我购买域名时)已经很流行,并且一直持续到今天,这个话题比你可能预期的要多。拒绝采样、结果奖励模型和角色训练等主题就是典型的例子。这帮助网站变得相当受欢迎,因为它仍然是少数几个以基础、直观的方式讨论这些主题的地方之一。

Otherwise, most of the book is about communicating intuitions and history. Much of the LLM industry is defined by core techniques that haven’t changed much in the last few years. This book was my attempt to explain in simple terms why post-training works, what trade-offs people need to make to get it right, and what misconceptions people often get stuck on. To do this, some of the older, foundational blog posts on Interconnects were reworked to stitch together the story behind key mathematical topics. For this reason, a lot of the explanatory text is likely higher voice than your average textbook.

除此之外,这本书的大部分内容是关于传达直觉和历史。LLM 行业的许多核心技术在过去的几年里变化不大。这本书是我试图用简单的术语解释为什么训练后有效,人们需要做出哪些权衡才能做好,以及人们经常陷入哪些误解。为此,Interconnects 上一些较老的基础博客文章被重新整理,以串联起关键数学主题背后的故事。因此,很多解释性文字可能比普通教科书更有声音。

This is the book I wanted to read when I was getting started a few years ago! With how many people still ask me basic post-training questions, in fact a population that’s accelerating in size, I suspect this book will be very well received. I still use the book regularly and hear from established researchers all over the industry that they do too. So, it’s not a beginner book — it’s more tailored to someone who has already finished a bachelor’s degree in CS — but if you master it you will be far ahead in your post-training worldview.

这是我在几年前刚开始时想读的书!由于仍然有很多人问我基本的训练后问题,事实上这个群体的人数还在加速增长,我怀疑这本书会非常受欢迎。我仍然经常使用这本书,并且听到整个行业的高级研究人员也说他们也在使用。所以,它不是一本入门书——它更适合已经完成计算机科学学士学位的人——但如果你掌握了它,你在训练后的世界观方面会远远领先。

Share

分享

A discount to readers!

给读者的折扣!

The book is also freely available online and comes with a full 12 hour course (slides + video on YouTube), a simple code-base with suggested exercises, and model completion comparisons. It’s 50% off until August 19th on Manning with the code PBLambert.

这本书也可以免费在线获取,并附带一个完整的 12 小时课程(YouTube 上的幻灯片和视频)、一个带有建议练习的简单代码库,以及模型完成比较。在 Manning 上使用代码 PBLambert 可享受 50% 的折扣,直到 8 月 19 日。

Buy my book from Manning

从 Manning 购买我的书

Buy my book on Amazon

在亚马逊上购买我的书

Yes, the title of this book is a little outdated — I’ve learned some lessons and fought some battles with the publishing process — but I can guarantee the content is very fresh. I regularly reference the book for my research work, and hear from friends that do the same. I added a section on on-policy distillation at the last possible moment! The book is shipping from Manning and Amazon US now, and from Amazon UK in October.

是的,这本书的书名有点过时了——我在出版过程中学到了一些教训,也经历了一些斗争——但我可以保证内容非常新鲜。我经常在研究工作中参考这本书,也听说朋友们这样做。我在最后一刻添加了关于在线策略蒸馏的部分!这本书现在从Manning和美国亚马逊发货,英国亚马逊则要到十月份。

1. Intuitions for how RL algorithms change the outputs of models

1. 对RL算法如何改变模型输出的直觉理解

By word or page count, the book is about 25% RL. This seems appropriate. If there’s one thing the book is doing it’s teaching people how to think about various RL algorithms. This intuition, from the policy-gradient theorem to PPO to modern versions like GSPO and CISPO, are crucial to understanding if a new algorithm is fake or has potential (no new algorithm will be proven right out of the gates).

按字数或页数计算,这本书大约有25%是关于强化学习的。这似乎很合适。如果说这本书在做一件事,那就是教人们如何思考各种RL算法。这种直觉,从策略梯度定理到PPO,再到像GSPO和CISPO这样的现代版本,对于理解一个新算法是假的还是有潜力(没有新算法会一开始就被证明是正确的)至关重要。

Below is an example intuition you should be able to follow after reading.

下面是一个阅读后你应该能理解的直觉示例。

For example, here’s a fun figure that we’ve iterated on for the PPO clipping understanding. At the end of the day, PPO’s surrogate objective reduces to six regions. These can be seen as two gradients, when the advantage for a token is positive or negative, depending on the current value of the policy ratio. For an individual sample in a completion, it lives somewhere on this plot. If it was the first gradient step in the batch, it starts at 1 on the x axis (gradient always flows), then depending how the ratio updates after changing the RL policy behavior, the gradient is either the same or becomes 0 (which is what the clipping arguments are for).

例如,这里有一个我们为理解PPO裁剪而迭代的有趣图表。归根结底,PPO的替代目标可以归结为六个区域。这些可以看作是两个梯度,当某个标记的优势为正或负时,取决于策略比率的当前值。对于完成序列中的单个样本,它位于此图的某个位置。如果它是批次中的第一个梯度步骤,它从x轴上的1开始(梯度总是流动),然后根据改变RL策略行为后比率的更新方式,梯度要么保持不变,要么变为0(这就是裁剪参数的作用)。

This intuition filters very closely into how the systems are designed, in order to manage the gradients and numerical issues they tend to cause. The math-focused policy-gradient section is pretty thorough, covering all the algorithms you’ve likely heard about in the last 3 years:

这种直觉非常贴近系统设计的方式,以便管理梯度及其往往引起的数值问题。以数学为重点的策略梯度部分相当详尽,涵盖了你在过去三年中可能听说过的所有算法:

  • Deriving the Policy Gradient
  • Vanilla Policy Gradient
  • REINFORCE
  • REINFORCE Leave One Out (RLOO)
  • Proximal Policy Optimization (PPO)
  • Understanding the PPO Objective
  • Value Functions and PPO
  • Group Relative Policy Optimization (GRPO)
  • Group Sequence Policy Optimization (GSPO)
  • Clipped Importance Sampling Policy Optimization (CISPO)
  • Comparing Algorithms
  • 推导策略梯度
  • 原始策略梯度
  • REINFORCE
  • REINFORCE留一法(RLOO)
  • 近端策略优化(PPO)
  • 理解PPO目标
  • 价值函数与PPO
  • 组相对策略优化(GRPO)
  • 组序列策略优化(GSPO)
  • 裁剪重要性采样策略优化(CISPO)
  • 算法比较

2. An understanding of the crucial factors facing new RL systems and algorithms

2. 理解新RL系统和算法面临的关键因素

Most of modern RL is a systems problem balancing a few problems — how off-policy the data is, training-inference mismatch, and throughput. The core systems design, asynchronous RL with separate GPUs for the learners (the GPUs which take gradient steps) and actors (the GPUs which generate the rollouts in the environment), has been similar for a few years.

现代强化学习的大部分内容是一个系统问题,需要平衡几个问题——数据的离策略程度、训练与推理的不匹配以及吞吐量。核心系统设计,即异步强化学习,其中学习器(执行梯度步骤的GPU)和行动器(在环境中生成轨迹的GPU)使用独立的GPU,这种设计已经持续了几年。

Agentic tasks are only adding more infrastructure on top of these fundamentals. The book is designed to be the simplest resource to start from roughly 0 LLM RL knowledge and be ready to tinker with the systems. It starts with basics, such as explaining the general form of implementing an RL algorithm:

智能体任务只是在这些基础之上增加了更多的基础设施。这本书旨在成为从零开始学习LLM强化学习知识并准备动手实践系统的最简单资源。它从基础开始,例如解释实现强化学习算法的一般形式:

pg_loss = -advantages * ratio

It continues with teaching you about loss aggregation — the idea that spawned DAPO and Dr. GRPO as some of the seminal, early GRPO variants — and truncated importance sampling — the technique used to make PPO work in early RL experiments.

接着,它教你损失聚合——这一思想催生了DAPO和Dr. GRPO等开创性的早期GRPO变体——以及截断重要性采样——这一技术使PPO在早期强化学习实验中得以工作。

  • Policy-Gradient Basics
  • Loss Aggregation Tradeoffs
  • Asynchronous RL Systems
  • Truncated Importance Sampling
  • Example: PPO
  • Example: GRPO
  • 策略梯度基础
  • 损失聚合的权衡
  • 异步强化学习系统
  • 截断重要性采样
  • 示例:PPO
  • 示例:GRPO

Share

分享

3. The histories that lead to modern post-training

3. 通往现代后训练的历史

Knowing how a field came to be has always been fascinating to me. As you become an expert, knowing the history of your field better than anyone is what lets you make the best predictions (Bill Gurley gives similar advice in his recent book). In a time when the foundations of deep learning were being built, like the transformer, the core of modern post-training was also born in the alignment field. The book will walk you through 3 eras, when researchers learned to do RL on preferences generally until ~2018, spent a few years learning how to apply it to language models from 2019 to 2022, and from 2023 on exploited the examples set by ChatGPT. Much like those early to scaling LLMs, the people who created this field a decade ago deserve incredible credit for how modern progress has unfolded.

了解一个领域是如何形成的对我来说一直很有吸引力。当你成为专家时,比任何人都更了解你所在领域的历史,这能让你做出最好的预测(比尔·格利在他最近的书中也给出了类似的建议)。在深度学习基础(如Transformer)被构建的时代,现代后训练的核心也在对齐领域诞生。这本书将带你走过三个时代:研究人员在约2018年前普遍学习如何对偏好进行强化学习,从2019年到2022年花了几年时间学习如何将其应用于语言模型,以及从2023年起利用ChatGPT树立的范例。与早期扩展LLM的人一样,十年前创建这个领域的人们对现代进步的展开应获得极大的赞誉。

Chapter 2 of the book is a crash course on this, but the book is littered with this type of thinking.

本书第二章是这方面的速成课程,但整本书都充满了这种思考。

4. Dispelling the magic of “distillation”

4. 揭开“蒸馏”的神秘面纱

It’s really nice to have a boring textbook chapter on distillation given the broader AI policy discussions ongoing. This one, chapter 12, explains the various industry-standard ways that outputs from an LLM are used to train downstream models. When the technique is often described in nefarious ways, and as a tool of geopolitical competition, it’s a deescalatory action to break out a 300 page textbook to explain to someone how broad the term they’re attacking is.

在更广泛的AI政策讨论正在进行之际,能有一章关于蒸馏的枯燥教科书内容真是太好了。这一章,即第12章,解释了从LLM输出用于训练下游模型的各种行业标准方式。当这项技术经常被以邪恶的方式描述,并被视为地缘政治竞争的工具时,拿出一本300页的教科书来解释他们所攻击的术语有多么宽泛,是一种缓和局势的行为。

With this, chapters 10 through 12 are all about making some opaque practices of the data industries clearer to readers.

这样一来,第10章到第12章都旨在让读者更清楚地了解数据行业中一些不透明的做法。

The distillation chapter continues the theme I outlined above, explaining the key changes that needed to be made to transition the early knowledge distillation literature of 2015 to 2-3 key insights that got us to the multi-teacher on-policy distillation (MOPD) of models like Xiaomi MiMo-V2-Flash and DeepSeek V4.

蒸馏章节延续了我上面概述的主题,解释了从2015年的早期知识蒸馏文献过渡到2-3个关键见解所需的关键变化,这些见解使我们得以实现像小米MiMo-V2-Flash和DeepSeek V4这样的模型的多教师同策略蒸馏(MOPD)。

5. A survey of all the other little headaches you encounter when trying to do post-training right

5. 对在尝试正确进行后训练时遇到的所有其他小麻烦的概述

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

关联讨论

同一事件的更多信源

相似阅读

关联信息,但可能不是同一事件