LLM 全栈学习
第 22 章

全课总结 Grand Summary

整门课的收束。我们回到最初的问题:当你在 ChatGPT 里敲下一句话、点击发送,屏幕背后到底发生了什么?把整条流水线串成一条线:预训练(互联网 → token → 下一个 token 预测 → base 模型,知识从互联网内化进网络参数)→ 后训练。后训练又分三步:SFT(用人类标注员撰写的理想对话做模仿学习,模型的「人格」就来自这里)→ 在可验证领域里的强化学习(RL,让模型在大量练习题上自己摸索出好的思考策略)→ 面向不可验证领域的 RLHF(用人类偏好排序训出一个奖励模型来引导)。于是你在 ChatGPT 里对话的对象,本质是一个 token 模拟器:它先模仿人类标注员,再被 RL 塑形。它强大但并不完美,带着锋利的边缘——会幻觉、有「瑞士奶酪」式的参差智能、连数字符也会出错。所以把它当工具:核对它的产出,保留「人在回路」。这是 22 章课程的终点,以鼓励作结。 The close of the whole course. We return to the opening question: when you type into ChatGPT and hit go, what is actually happening behind the screen? We string the whole pipeline into one line: pretraining (internet -> tokens -> next-token prediction -> base model, with knowledge internalized from the internet into the network's parameters) -> post-training. Post-training has three steps: SFT (imitation learning on ideal conversations written by human labelers — this is where the model's 'personality' comes from) -> reinforcement learning in verifiable domains (RL, where the model practices on many problems and discovers good thinking strategies on its own) -> RLHF for unverifiable domains (training a reward model from human preference rankings to guide it). So what you talk to in ChatGPT is essentially a token simulator: it first imitates a human labeler, then is shaped by RL. It is powerful but imperfect, with sharp edges — it hallucinates, has 'Swiss-cheese' jagged intelligence, and even miscounts characters. So treat it as a tool: verify its work and keep a human in the loop. This is the end of the 22-chapter course, and we close on encouragement.

我们回到一开始提出的那个问题:当你打开 ChatGPT,敲下一句话,点击发送——屏幕背后究竟发生了什么?你看到的、你正在对话的那个东西,到底是什么,它是怎么工作的?走到这里,我们已经有能力把它从头到尾讲清楚了。 Let's loop back to the question we started with: when you open ChatGPT, type a query, and hit go — what is actually happening behind the screen? What is the thing you're seeing, the thing you're talking to, and how does it work? Having come this far, we can now explain it end to end.

首先,你的查询会被切成 token,按对话协议(conversation protocol)的格式插进一个对话对象里;在底层,这一切最终只是一串一维的 token 序列。当你点「发送」,模型就开始往这串序列后面不断追加 token——它的行为就像一个「token 自动补全」:一个一个地续写,直到给出回应。问题随之而来:为什么续写出来的偏偏是这些 token?它们从哪儿来?我们到底在跟什么对话? First, your query is chopped into tokens and inserted into a conversation object following the conversation protocol format; under the hood, all of this is ultimately just a one-dimensional token sequence. When you hit go, the model starts appending tokens to that sequence — it behaves like a 'token autocomplete,' continuing one token at a time until it produces a response. Which raises the question: why exactly these tokens? Where do they come from? What are we actually talking to?

答案是这整门课讲过的三个阶段。第一个阶段是预训练(pretraining):本质上就是从互联网获取知识、把它内化进神经网络的参数里。你可以把它想成:互联网 → 切成 token → 反复做「下一个 token 预测」→ 得到一个 base 模型。网络由此内化了大量来自互联网的知识——但请记住,真正的「人格」还不在这里。 The answer is the three stages this course has covered. The first is pretraining: fundamentally, acquiring knowledge from the internet and internalizing it into the neural network's parameters. Picture it as: internet -> chopped into tokens -> repeated next-token prediction -> a base model. The network thereby internalizes a great deal of knowledge from the internet — but remember, the actual 'personality' isn't here yet.

预训练 Pretraining 15 万亿 token 互联网文本 数千台 GPU · 约 3 个月 → base model(token 模拟器) 后训练 Post-training 对话数据 · SFT / RLHF 算力小得多 · 约数小时 → assistant(会对话的助手) 构建大模型的两个顺序阶段
首尾呼应:预训练产出 base 模型(知识),后训练注入人格与行为——这正是全课的主轴 A bookend: pretraining yields the base model (knowledge); post-training injects personality and behavior — the spine of the whole course

人格真正出现的地方,是后训练里的第一步:监督微调(SFT)。像 OpenAI 这样的公司会精心策划一个庞大的对话数据集——比如上百万段、横跨各种话题的「人类与助手」对话。尽管这一过程也大量借助合成数据和 LLM 辅助,但它本质上是一项以人为主的数据策划工作:由公司雇来的数据标注员(data labelers),按照他们学习过的标注规范,为各种各样的提问撰写「理想的助手回答」。换句话说,他们是在用例子手把手教神经网络:面对一个提问,该怎么回应。 Personality truly appears in the first step of post-training: supervised fine-tuning (SFT). A company like OpenAI curates a large dataset of conversations — say a million conversations spanning all sorts of topics, each between a human and an assistant. Although the process leans heavily on synthetic data and LLM assistance, it is fundamentally a human-driven data-curation task: data labelers hired by the company, following labeling instructions they've learned, write 'ideal assistant responses' to all kinds of prompts. In other words, they teach the neural network by example how to respond to a prompt.

💡 于是有了理解 ChatGPT 回应的最佳心智模型:你拿到的,是「一个 OpenAI 数据标注员的神经网络模拟」。就好像你把这个问题丢给一位标注员,他先读完所有标注规范,再花两个小时写出理想回答交给你——只不过我们没真的等两小时,我们拿到的是这个过程的一个模拟。而且要记住:神经网络的运作方式和人脑不同,对它容易或困难的事,和对人不一样。每个 token 背后只是一份固定、有限的计算,所以这是一种「有损的」人类模拟。 This gives the best mental model for understanding a ChatGPT response: what you get is 'a neural-network simulation of an OpenAI data labeler.' It's as if you handed the question to a labeler who first reads all the labeling instructions, then spends two hours writing the ideal answer and hands it to you — except we didn't actually wait two hours; what we get is a simulation of that process. And remember: neural networks don't work like human brains; what's easy or hard for them differs from what's easy or hard for us. Behind every token is just a fixed, finite amount of compute, so this is a 'lossy' simulation of a human.

后训练的另外两步,负责进一步打磨这个模拟器。在可验证的领域(比如数学、代码),我们用强化学习(RL):让模型在大量练习题上反复尝试,自己摸索、发现好的思考策略——那些看起来很像你脑海里内心独白的、解决问题的链路。这一步不是模仿人类标注员,而是在模拟中「涌现」出的思考能力,原则上甚至可能产生连人都没想到过的新解法。而在不可验证的领域(比如创意写作),没有干净的对错可以打分,于是改用 RLHF:先让人类对模型的若干回答做偏好排序,据此训练出一个奖励模型(reward model)来近似人类的喜好,再用它去引导模型。 The other two steps of post-training refine this simulator further. In verifiable domains (e.g. math, code), we use reinforcement learning (RL): the model practices on many problems, trying repeatedly and discovering good thinking strategies on its own — problem-solving chains that look a lot like the internal monologue in your head. This step doesn't imitate a human labeler; it's a thinking ability that 'emerges' in simulation, and in principle could even produce solutions no human has thought of. In unverifiable domains (e.g. creative writing), there's no clean right-or-wrong to score, so we use RLHF instead: have humans rank their preferences among several model answers, train a reward model to approximate human taste from those rankings, then use it to guide the model.

⚠️ 正因为这些认知差异,模型会以各种方式「翻车」,使用时必须当心。它们会产生幻觉(hallucination);它们的能力像一块「瑞士奶酪」——大部分地方很厉害,却偶尔在某个洞里突然犯傻:也许是你没给够「思考的 token」,也许是心算崩了,也许是数不清一个词里有几个字母,甚至会觉得 9.11 比 9.9 大。这就是参差不齐的「锯齿状智能」(jagged intelligence)。 Precisely because of these cognitive differences, models fail in various ways, and you must be careful when using them. They hallucinate; their capability is like a block of 'Swiss cheese' — superb in most places, yet occasionally falling into a hole and doing something dumb: maybe you didn't give it enough 'tokens to think,' maybe its mental arithmetic broke, maybe it can't count the letters in a word, or it thinks 9.11 is bigger than 9.9. This is uneven, 'jagged intelligence.'

把这条线收束起来:你在 ChatGPT 里对话的,本质上是一个 token 模拟器——先由人类标注员塑形(它学会模仿理想的助手回答),再(在思考型模型里)被强化学习塑形(它练出了自己的思考策略)。不会做 RL 的模型(比如普通的 GPT-4o)给你的,更接近一份「人类标注员的直接模拟」;而思考型模型多走了 RL 这第三步,给你的回应里有了一点真正「新」的、涌现出来的东西。 Tying the line together: what you talk to in ChatGPT is essentially a token simulator — first shaped by human labelers (it learns to imitate ideal assistant responses), then (in thinking models) shaped by reinforcement learning (it has practiced its own thinking strategies). A model that doesn't do RL (e.g. plain GPT-4o) gives you something closer to a 'direct simulation of a human labeler'; a thinking model takes that third RL step, so its responses contain a bit of something genuinely 'new' and emergent.

最后是一点实用的智慧,也是整门课想留给你的态度。这是一个极其令人兴奋的时代:这些模型强大到能显著加速你的工作,很多人每天都在用它们几十上百次。但它们并不完美,带着锋利的边缘——会随机犯傻、随机幻觉、随机跳过该做的心算、随机数不清字母。所以:把它当成工具箱里的一件工具,不要全盘信任。用它找灵感、打初稿、向它提问,但永远去核对、去验证,并对最终产出负责——让「人」留在回路里。做到这一点,它会让你的工作事半功倍。 Finally, a bit of practical wisdom — the attitude this whole course wants to leave you with. This is an extremely exciting time: these models are powerful enough to dramatically accelerate your work, and many people use them dozens or hundreds of times a day. But they are imperfect, with sharp edges — they'll randomly do something dumb, randomly hallucinate, randomly skip the mental arithmetic they should have done, randomly miscount letters. So: treat it as a tool in your toolbox, and don't trust it fully. Use it for inspiration, first drafts, and questions, but always check and verify, and own the final product — keep a human in the loop. Do that, and it will make you far more effective in your work.

📝 这是这门 22 章课程的终点。我们从「ChatGPT 里到底发生了什么」出发,一路拆开了 token、神经网络、预训练、后训练、SFT、RL 与 RLHF,直到把那个最初的问题完整地回答了一遍。希望它对你有用、也有趣。带着这份理解,去自信而审慎地使用这些工具吧——祝你一路顺利。 This is the end of the 22-chapter course. We started from 'what is actually happening inside ChatGPT' and, along the way, unpacked tokens, neural networks, pretraining, post-training, SFT, RL, and RLHF, until we'd answered that opening question in full. I hope it was useful and fun. Go use these tools with confidence and care — and best of luck on your way.

📝 本章测验

整门课把「ChatGPT 背后发生了什么」总结成怎样一条流水线?How does the course summarize the pipeline of 'what happens behind ChatGPT'?

理解一个(非思考型)ChatGPT 回应,最好的心智模型是什么?What's the best mental model for understanding a (non-thinking) ChatGPT response?

为什么在可验证领域用 RL,而在不可验证领域改用 RLHF?Why use RL in verifiable domains but RLHF in unverifiable ones?

课程给出的实用使用态度是什么?What practical attitude toward usage does the course leave you with?