先说结论:Matthew Berman 请来 Anthropic 研究员 Jeremy Berman(两人同姓但并无亲属关系;嘉宾自述自学出身、循直觉入行),用约 56 分钟把大语言模型的训练讲成一节公开课:神经网络就是一堆可自动调节的「旋钮」,PyTorch 按导数方向替你拧;语言模型把同一份数据变成「预测下一个词」;预训练得到一台无保证的互联网自动补全机,后训练用预填与指令数据「骗」出助手人格;强化学习(DeepSeek 的 GRPO)让模型在可验证环境里从试错中自己学会思考。最后回答「模型能否逃出训练分布、做出真正的新发现」时,嘉宾押注肯定,理由是「推理本质上就是把那些不太可能、但真实且有趣的东西变得更可能」。全程演示基于免费工具(Google Colab 免费 T4 + 开放权重的 Qwen 小模型),主持人结语称以此为业「不需要博士学位」。

一、神经网络:从一张纽约房价表开始的「旋钮」心智模型

Jeremy 的讲法从具体例子切入:预测纽约公寓价格,输入是位置(SoHo)、面积、卫生间数,输出是成交价。传统做法是把「面积在一千到两千之间、卫生间一到两个,价格就在这一带」之类的判断手写成代码——七条数据可以硬编码,百万条数据、上千个输入就写不动了;节目类比房产经纪人「脑子里装着几百个输入」(装修、建造年代……)做的其实是模式匹配。神经网络的路子是让计算机自己把这个函数「长」出来:每个输入乘上一个参数再求和(参数初始随机,如 0.25、0.05、0.15),这些参数就是旋钮。主持人复述确认——旋钮相当于给每个输入分配「重要度」——嘉宾认可这是好的表述。三个旋钮不够就加旋钮、加层,函数套函数,这就是神经网络;训练目标是把 loss(预测与真实值的平均偏差;例子:两百万美元的公寓预测成一百万)压到最小。嘉宾还给了一个去魅视角:语言模型「其实就是从 Hugging Face 下载的一份文件——数字就是大脑,即参数;所谓两万亿参数的模型就是两万亿个数字,外加一个描述这些数字如何接线的 Python 函数」。

二、训练:让计算机替你拧旋钮

手动逐个调旋钮不可行,嘉宾称让计算机自动完成这件事是「神经网络真正伟大的发明」:PyTorch、JAX、TensorFlow 这类 autograd 引擎记录全部参数与计算,算出 loss 后对每个参数求导(链式法则,他建议初学者直接把「PyTorch 会告诉你每个旋钮的影响」当作黑盒接受),再按学习率朝降低 loss 的方向微调每个参数——这就是反向传播(backpropagation)。主持人总结:「你刚才描述的就是今天所有 AI 的基本单元。」两个补充要点:其一是万能函数逼近器性质——层与旋钮够多即可表示任意函数,玩具示例里 loss 理论上可压到零(现场 1000 步从 8 降到约 0.07 百万美元偏差,受限于示例只是个简单线性函数);其二是训练原料只有两样——输入与真实世界答案(标签)。他顺带给出门门捷径:让 Claude 或 ChatGPT 写并逐行讲解这段 PyTorch 代码,「这些系统极其擅长此事」。

三、语言模型:同一份数据换个玩法

同一张房价表可以原样变成文本:输入是词(实际是 token,为直观先当词理解)的序列,任务从「输出一个数」变成「预测下一个词」——看到 SoHo 预测逗号,看到「SoHo,」预测 1200。模型学习数据中的模式并「成为你的数据」:只喂这类文档一百万行,它就只擅长这类文档的语言,但仍能学到足够模式把正确价格「续写」出来。主持人与嘉宾确认专用网络与语言模型的关系:数据与算力足够时两者理论上收敛到同一个正确函数;有限资源下若只求输出价格,普通神经网络性价比更高;语言空间自由度大得多,需要多得多的参数、数据与算力才能收敛到同等精度。

四、预训练的真相:一台互联网自动补全机

把任意文本——整个互联网——倒进去训练,得到 base model:它会「浸泡」进互联网的模式,做无保证的自动补全——不保证正确、连贯或有帮助,只保证更像训练数据。嘉宾用 Qwen 2.5 0.5B(5 亿参数、开放权重)现场演示:空输入让它随机续写一百词,先吐代码、再吐中文,据此可推断训练数据里这两类文本占比很高;输入「Matthew Berman said」它编造出一段「访谈名言」(「一本好书应该是有主角的好故事」),主持人指出原因——训练数据里没有他的信息,若把他的 YouTube 转写喂进去,不保证真实但「会更像你」。节目点出:ChatGPT 走红之前公众接触的多是这类 base model。后训练第一步是「预填骗术」:既然模型只会补全,就把文本预先写成「user: 1+1 等于几?assistant:」——模型顺着它见过的所有助手语料,把自己补全成一个助手;Qwen 2 用 im_start/im_end 标记规范了这种格式(转写「M start, M end」已校正)。但 base model 不知道何时停,会一直续写到 token 上限。于是造数据:人工撰写或生成约十万条「好助手回答」样本,带上格式与 stop token 再训练——用嘉宾的话说模型「开始有了自我(ego)」,学会扮演助手并适时停止,这就是 instruct 模型(「天为什么是蓝的」演示回答基本合格;嘉宾一句带过这大致就是 GPT-3 时代的水平)。平时 API 里的 role/content 消息结构本质就是同一套预填,聊天界面与模型看到的补全文本「完全等价」——用 tokenizer 就能看到模型实际收到的 token 序列。主持人特意说明:这一切都可以免费用 Google Colab(嘉宾用的就是免费 T4)加开放权重复现,链接在简介里。

五、让它思考:从一句提示词到 GRPO

助手模型仍会不假思索地抢答:演示问 398×923+2901,模型自信地答 37,000,节目称正确答案约 370,000。研究者发现只要预填「let’s think step by step」再让它续写,答案就明显变好——主持人回忆这是 ChatGPT 公开走红之后公众才普遍掌握的技巧(他早期做模型评测视频时还在手动敲这句话),嘉宾补充「实验室内部当时是否已掌握不好说,公开渠道确实是新东西」。第一个公开的思考模型是 OpenAI 的 o1,而公众真正理解其机制是在 DeepSeek R1 论文发布之后。Jeremy 解释非思考范式为何持续很久:互联网缺少「思考过程数据」——博客与代码都是思考的成品而非思考本身;即便喂思考数据,模型也只是模仿思考的样子(他补充:数据与模型足够大时原则上也能真正掌握思考模式)。突破口是强化学习:让模型自己试错。朴素做法是「答一百次只把对的收进训练集」——拒绝采样(rejection sampling),确实有效,但学不到负样本,且每次回答中大量无关 token(他举例「of、does 之类的随机词」)也被一并强化。DeepSeek 所用 GRPO(组相对策略优化)把一组回答按格式遵循与正确性打分、减去组均值得到 advantage:高于平均的回答中每个 token 变得更可能,低于平均的更不可能——既学了负样本,又在规模上抵消噪声。更关键的是 on-policy 性质:模型用自己生成的数据训练,只需轻轻拧旋钮就强化了「它本来就能给出的好答案」;模仿别人的思考时,你在放大那个人全部思维路径的同时「并不知道压低了哪些词」,更容易连带损伤既有能力。这也回答了主持人「为什么预训练与后训练要分开」:预训练吃世界的离线数据(off-policy);模型一旦有了助手人格,再拿代码语料回去训,它会「入戏」开始用代码腔说话、丢掉助手行为。已有论文尝试把 RL 融入训练全栈,两阶段未来可能合并。当下可复制的配方是:凡能构造「模型多次作答 + 对错可验证」的环境,模型就会在该任务上爬山式自我提升,对既有能力的破坏有限——「当然仍有一些退化」。

六、能逃出训练分布吗:推理=把不太可能但正确的东西变可能

最后一个问题是个老批评:模型只是训练分布上的下一词预测器,分布里没有的东西它怎么「新发现」?嘉宾立场:据他所知,语言模型迄今尚未做出改变世界的全新发现,但已开始攻克未解决的人类数学难题;他押注它们终将做到,因为「推理就是把那些不太可能、但真实且有趣的东西变得更可能的过程」——爱因斯坦提出广义相对论之前,这个想法对他自己也远非高概率选项,是长期推理逐步搭出新抽象才推导出来;模型同理,只要持续训练它们做长程推理,没有理由不能发展出新知识、逃出训练分布。这一判断与本站此前整理的 Anthropic 自主改进(RSI)相关讨论可互为参照(站内成文:METR 与 Anthropic 的 RSI 十二个月时间线)。

机制链与读者启发

  • 心智模型链:把「参数」译成「旋钮」、「训练」译成「按导数方向微调所有旋钮」之后,房价预测器与 GPT 级模型的差别只剩规模与数据形态——嘉宾整期都在示范这种去魅式科普(两万亿参数=两万亿个数字+一张 Python 接线图)。启发:遇到 AI 玄学表述,先问它在拧什么旋钮、loss 是什么。
  • 数据形态链:互联网只有思考的成品没有思考过程 → 模仿式训练只能学到思考的样子 → 可验证环境+自生成数据(RL/on-policy)让模型从试错中长出自己的推理。启发:评估一个训练故事,先看奖励信号是否可验证、数据是否模型自己生成的。
  • 人格链:base model 无人格只是补全 → 预填+指令数据骗出助手自我(ego) → 有了 ego 之后离线数据回流会破坏人格(代码腔、遗忘)。启发:对已微调模型做继续预训练要警惕灾难性遗忘;对话界面的 role 结构本质是格式化预填。
  • 学习路径链:免费算力(Colab T4)+开放权重(Qwen 0.5B)+让 Claude/ChatGPT 写讲解代码 → 自学复现全部核心实验成为可能 → 嘉宾本人就是这条路径的样本,他的建议是「找到让你着迷的部分,钻进兔子洞」。主持人结语:以此为业不需要博士学位,需要的是大量努力。

这期节目不是新闻,而是一份可反复使用的概念地图:往后任何训练相关的新闻(新 RL 算法、新 scaling 争论、新开放权重发布)都可以放回「旋钮—loss—数据—ego—试错」五个格子里检验自己是否真的理解了它。

ASR 校正表

已确认误识别(corr.json 已同步机械替换;依据列示):

原文修正为依据
Quan / Quan to 0.5B / Quan twoQwen / Qwen 2.5 0.5B / Qwen 2阿里通义千问开放权重模型官方拼写;上下文「500 million knobs」「open weights model」与其 0.5B 型号吻合
M start, M endim_start, im_endQwen 2 对话模板的特殊标记(<|im_start|>/<|im_end|>),口播被切听
group group relative policy optimizationgroup relative policy optimizationGRPO 全称 Group Relative Policy Optimization,口吃重复
So O1 was / To O1So o1 was / To o1OpenAI 模型名官方小写写法
GPT threeGPT-3官方写法

疑似但无法确认、保留原文:

  • 「something called im_start, im_end, and start」句尾残留的「and start」——疑为标记列举未转写完整,保留。
  • 「the clouds different colors and refracted options in the air」——为现场演示中 instruct 模型自己生成的不通顺回答,属模型输出原貌,保留。
  • 「a sheet of apartments」——疑指 spreadsheet(电子表格)语境,保留原文。
  • 爱因斯坦语录演示段(「The answer to this question is in the text」)转写破碎,为屏幕演示口播,正文未展开引用。
  • 口语重复(it it、you know、of of 等)为转写原貌,保留。

未采用条目

  • 爱因斯坦语录演示的具体引文内容:演示重点是「base model 不保证连贯」,引文本身无独立信息量。
  • 「mean squared error 计算细节」「activation functions 不展开」两句:嘉宾明言不深入,正文一句带过即可。
  • 片尾致谢与订阅引导:常规 CTA。
  • 其余事实账本高优先级条目(演示数字、算法名、因果判断、限定条件)均已在正文落点;账本高优先级 26 条、正文落点 26 条、未采用 3 条(如上)。

转写原文(修正版)

[0s - 120s]

This is Jeremy Berman from Anthropic. He’s a researcher there, and no, we are not related. And we sat down, and he explained exactly how large language models get built, everything from pre-training to post-training, reinforcement learning. And so, if you ever wanted to learn about this stuff, here’s the right video for you. I hope you enjoy this video. I hope you learn a lot. And of course, if you want to see other videos like this, let me know down in the comments. If you have any questions, also just drop a comment. I’ll try to answer them. My goal is really to give an intuitive, high-level overview on how we’re able to build intelligence and intelligent systems, really from just a file with numbers and a relatively small Python program. So I’m going to break this up into seven, what I hope to be intuitive parts: what are neural networks, how they’re trained, what are large language models, what is pre-training, what is post-training, how did we get them to think, and can they discover new things? And this is all the same techniques or basic versions of what the modern large language model landscape looks like. So ChatGPT, Claude, this is all kind of what they’re doing to make these incredible models. Yes, yes, exactly. I think you know there are a lot of each in each one of these sections. You could do a whole deep dive for hours. I’m going to try and stay high level and intuitive, but of course, you know, ask any questions, and maybe we could do you know a follow-up video for for the ones that are most interesting. And and I just want to give you your props for a second because you are self-taught. You are a self-taught AI researcher, and so like this is the starting point for anybody who wants to follow that same journey. Yes, I would say really just follow your intuitions. Like you know there are a few parts to training these things, and you can go as deep as you need to in each one. You know, kind of find what you get obsessed about.

【译】这位是来自 Anthropic 的 Jeremy Berman,他是那里的一名研究员——不,我们俩并没有亲戚关系。我们坐下来聊了一次,他把大语言模型到底是怎么构建出来的完整讲了一遍:从预训练到后训练、再到强化学习,全都讲到了。所以,如果你一直想弄明白这些东西,这期视频就是为你准备的。希望你喜欢这期视频,也希望你能学到很多。当然,如果你想看更多这样的视频,就在评论区告诉我;有任何问题也尽管留言,我会尽量解答。我的目标,是真的想给大家一个直观、高层次的概览:我们如何能够仅凭一个装满数字的文件和一段相对短小的 Python 程序,就构建出智能和智能系统。所以我打算把它拆成七个、但愿能讲得直观的部分:什么是神经网络、它们是怎么被训练的、什么是大语言模型、什么是预训练、什么是后训练、我们是怎么让它们思考的、以及它们能不能发现新东西?而这些全都是同样的技术,或者说只是当今大语言模型领域实际做法的基础版本。所以 ChatGPT、Claude,造出这些不可思议的模型,做的基本上就是这些。对,对,没错。我想说,这七个部分里的每一个,单独拿出来都能深挖好几个小时。我会尽量保持高层次、重直觉,不过当然,尽管提问,说不定我们可以就大家最感兴趣的几个部分再录一期后续视频。另外,我还想先给你应得的赞誉,因为你是自学出身的。你是一位自学成才的 AI 研究员,所以这期内容就是任何想走上同一条路的人的起点。是的,我的建议就是跟着你的直觉走。训练这些东西其实就分那么几个部分,每一部分你想钻多深都可以。去找到那个让你着迷的点。

[120s - 240s]

And then just follow that into a rabbit hole, and you know I think this is like very very self teachable even even today. Cool. All right, let’s do it. To start off with, what are neural networks? I want to start by giving a real world example. So let’s say we have a sheet of apartments in New York. They have inputs, and then they have the price. So an input would be the location, Soho, the square footage, and the number of baths. Very simple example, toy example. And so the idea is we need to find the pattern, the function that maps these inputs, location, square foot, and and number of baths, to the price in New York. And so as you can see, we have a set of inputs, and then we have the actual price to the right. And so a classic neural network is really like a way to build a function. So you can imagine you could build a function to do this, right? Like you could have a function that takes in the square footage, the bath, you could code it up, and then you could get pretty close to the right answer for the price. But is there a way that we could teach the computer to build this function for us? And for a toy example, this you know seems okay. Whatever, who cares? We can code up our own example. But you’ll see as we start to model really really complicated things, it’s very useful, and in fact, you know we couldn’t do it otherwise to actually have the model build the function for us. And Jeremy, when you say function, you literally mean kind of the old technique might be okay if square footage is between a thousand and two thousand, and you know if the baths is between one and two, price it around here. And so you you basically have to hardcode all of this logic yourself, which you know if we have seven examples as shown here, maybe it’s not so bad. But what if we have thousands, tens of thousands, or millions? Exactly, millions. And then what if instead of three inputs, we have a thousand inputs? Right.

【译】然后就顺着它一头钻进兔子洞。我觉得即使在今天,这个东西也完完全全可以自学。好,我们开始吧。首先,什么是神经网络?我想先从一个现实世界的例子讲起。假设我们有一张纽约公寓的清单,它们各有一些输入,然后对应一个价格。比如一个输入可以是位置——SoHo,还有面积,以及卫生间数量。非常简单的例子,一个玩具级的例子。思路在于:我们需要找出那个模式,也就是那个能把这些输入——位置、面积、卫生间数量——映射到纽约房价的函数。如你所见,我们有一组输入,右边是实际价格。经典的神经网络,其实就是一种构建函数的方式。你可以想象自己写一个函数来做这件事,对吧?比如写一个接收面积、卫生间数的函数,把它编码出来,就能得到相当接近正确答案的价格。但有没有一种办法,能教会计算机替我们把这个函数构建出来?对于玩具级的例子来说,自己写好像也无所谓——谁在乎呢,我们完全可以自己把这个例子编码出来。但你会看到,当我们开始建模真正非常复杂的东西时,让模型替我们构建函数就变得非常有用,事实上,不这样做我们根本办不到。还有 Jeremy,你说的「函数」,是不是就相当于老一套的做法,比如「如果面积在一千到两千之间,卫生间在一到两个之间,价格就大概定在这个区间」?这样一来,所有这些逻辑你都得自己硬编码进去。如果我们像这里展示的只有七个例子,也许还不算太糟。但如果我们有几千个、几万个、甚至几百万个例子呢?没错,几百万。那如果输入不是三个,而是一千个呢?是啊。

[240s - 360s]

A real estate broker has, you know, hundreds of inputs in their head, right? The finishings when it was built, and what the real estate broker is doing is they’re pattern matching, right? They’re saying, okay, I, I have a pattern match, I have, you know, general idea of what each of these mean, and so I can now map this property to how much it should cost. But what we’re trying to do is do this, have the computer build this function for us automatically in kind of a black box. So what does this really mean? Well, here you can see this is a very basic formula, and let’s just say we have inputs, you know, of the location, the size, the baths, the location, and we have our our answer. So what we can do is we can have these knobs, and the way the knobs work is you multiply the size by a certain parameter by a certain value. Let’s let’s randomize it at first. It’s randomized to 0.25, right? We multiply the bathrooms by 0.05, we multiply the location by 0.15, we do all of this, we add it up together, and we should have an output, and this output gives us a price. Now we just randomly initialized these these variables here, right? So what we get out, and you can see in these examples for Soho, it predicts 942k, 742, 860. These are all wrong because really what we’re after is the green. But we could actually adjust these dials, right? And eventually we can actually get pretty close. And can you can you explain in basic terms what the actual kind of what you’re multiplying by the knob? What does that represent? Yeah, so the knob is actually really just a random number, in this case from zero to one, and it’s like a black box. You are, you know, taking your inputs, which are you’re turning your inputs into numbers, and then you’re multiplying it by these random numbers or knobs, and there is some combination of knobs that will get you really close to always getting the right answer. Now let’s say we can’t possibly do.

【译】一个房产中介脑子里就装着几百个输入,对吧?装修档次、建造年份,等等。而房产中介在做的事情,其实就是模式匹配,对吧?他们说:好,我这里有一个模式匹配,我对其中每一项的含义都有个大概的概念,所以现在我能把这套房产映射到它应该值多少钱。而我们要做的就是这件事——让计算机以某种黑盒的方式,自动替我们把这个函数构建出来。这到底意味着什么呢?在这里你可以看到一个最基础的公式。假设我们有位置、面积、卫生间这些输入,然后有我们的答案。我们能做的,就是设置这些旋钮。旋钮的工作方式是:你把面积乘上某个参数、某个数值。一开始先把它随机化,随机成了 0.25,对吧?卫生间数乘以 0.05,位置乘以 0.15,把这些全做一遍,再加到一起,就得到一个输出,这个输出给我们一个价格。现在我们只是把这些变量随机初始化了一下,对吧?所以得到的结果——你从这些例子里能看到,对 SoHo,它预测出 94.2 万、74.2 万、86 万。这些全都是错的,因为我们真正想要的是绿色的那个数。但我们可以去调这些表盘,对吧?最终我们其实能调到相当接近。那能不能用最基础的说法解释一下:你用旋钮乘上去的那个东西,到底是什么?它代表什么?可以。旋钮其实真的就是一个随机数,在这个例子里是零到一之间的数,整个过程就像个黑盒。你把输入转换成数字,然后拿它们去乘这些随机数、这些旋钮,而旋钮的某种特定组合,会让你非常接近、几乎总能得到正确答案。现在假设我们没法……

[360s - 480s]

With three knobs, right? With with three numbers. So when I’m turning this knob, the the number is moving, right? As you can see here, and it’s adjusting the output. Let’s say we can’t get perfect with these three knobs. Well, you can actually just add more knobs or more layers or more parameters to build an even more complex function, till eventually you reach the green. And tell me if this is a right way to describe what these knobs are doing. But it’s it’s kind of assigning almost an importance value to each of those inputs. So maybe the size of your apartment is super important to the price output, or maybe actually how many baths you have is really really important. Maybe the location is less important. You’re is that a good way to describe it? Where each of these different knobs is kind of adjusting how important our little formula, our little algorithm is taking into account each of these factors. Yeah, that’s a great way to put it. Now, this is an extremely simple example where the number of bathrooms isn’t in some way intertwined with the location, and so let’s say Soho might be not desirable to have a large place. This is a very simple example just for demonstration purposes. But you’re exactly right. In this simple example, it’s basically saying how much do we weight each one, how much we multiply each one. But you can imagine we can generate, we can add more terms such that you also divide by the size in a new knob, assuming the location is a certain thing. So we can build arbitrarily large complex functions just by adding more knobs and changing the ordering of the knobs. And this would be an example of basically just one layer of a network because you know we just have this simple simple function. But you can imagine that this this output, all of these knobs produce one number, and that number gets fed into a whole new set of knobs and a whole new set of knobs. And so you have this function and.

【译】用三个旋钮做到,对吧?只用三个数字。当我转动这个旋钮的时候,那个数字就在动,对吧?你在这里能看到,它在调整输出。假设只用这三个旋钮没办法做到完美。那你其实完全可以再加更多旋钮、更多层、更多参数,去构建一个更复杂的函数,直到最终命中绿色那个值。再告诉我,这么来描述这些旋钮的作用对不对:它差不多是在给每个输入分配一个重要性数值。也许你公寓的面积对价格输出超级重要,或者卫生间数量其实非常非常重要,也许位置反而没那么重要。这么描述合适吗?就是说,每个不同的旋钮都在调整我们这个小公式、小算法对各个因素的考量权重。对,这个说法非常到位。当然,这是一个极其简单的例子,卫生间数量并没有和位置以某种方式相互纠缠——比如可以说,在 SoHo 大家可能并不想要一套大房子。这只是一个为了演示用的非常简单的例子。但你说得完全正确。在这个简单例子里,它基本上就是在说:每一项我们给多大权重、乘上多少。但你可以想象,我们还可以生成、可以添加更多的项,比如在位置满足某个条件的前提下,再用一个新的旋钮去除以面积。所以,只要不断添加旋钮、改变旋钮的排列顺序,我们就能构建出任意庞大、任意复杂的函数。而这基本上只是网络中一层的例子,因为我们只有这一个简简单单的函数。但你可以想象:这个输出——所有这些旋钮共同产出一个数字,而这个数字又被喂进一整套全新的旋钮,再喂进又一整套全新的旋钮。于是你就有了一个函数,而——

[480s - 600s]

Inside of a function, inside of a function, which is ultimately what neural networks are. And again, at each layer, you have a whole new set of knobs that you can twist and turn. And the point is really to minimize this number right here. So this is the average, on average, each prediction is off by. And so what we’re trying to do is minimize this number. So you can see that if we’re just doing this by hand, you know, in this simple example, we can get relatively close. And and so this is really the intuition, yeah, behind neural networks. It’s really just turning knobs that that create arbitrary functions that get you closer and closer to minimizing what we call loss, which is the difference between what the output is and or what what your model predicted and what actually exists in the world. Right. So if the actual sales price of that apartment in Soho is two million dollars, and we predict or the model predicts it’s one million dollars, that’s way off. And we want to continue to adjust those knobs until we get closer. Exactly. Yes. And you just want to keep adjusting. So we will come back to this example. Actually, let me now go back to the slides. This is just a general, quick level intuition behind what what exactly are knobs and and what are they doing. Now here’s the actual example. If this were a neural network, we don’t really need to focus into what all these numbers are. But if you wanted to actually see, we would turn the location into numbers as an input layer. We would turn the size into a number. We would turn the bathrooms into a number. And then each of these connections is the actual knob. It’s the number. It’s the weight. And so latitude has a weight that goes into and in this case there are three there are three intermediate layers. So we can construct a function. And what you’re doing is you’re basically

【译】函数里面套着函数、再套着函数——这归根结底就是神经网络。而且同样地,在每一层,你都有一整套全新的旋钮可以拧来拧去。而重点就在于把这个数字压到最小。这个数字表示的,是平均而言每次预测偏差多少。我们要做的就是把这个数最小化。你可以看到,如果纯靠手动来做,在这个简单例子里,我们能调到相对接近。所以这就是神经网络背后的直觉。它真的就是在转旋钮,构造出各种任意的函数,让你越来越接近、不断最小化我们所说的 loss(损失)——也就是模型的预测输出与世界上真实存在的答案之间的差距。对。所以,如果 SoHo 那套公寓的实际成交价是两百万美元,而我们预测、或者说模型预测的是一百万美元,那就差得太远了。我们就要继续调整这些旋钮,直到越来越接近。没错,是的,你就是想不停地调下去。这个例子我们后面还会回来讲。实际上,让我先回到幻灯片。这只是先给大家一个总体、快速的直觉:旋钮到底是什么、它们在做什么。现在来看实际的例子。如果这是一个神经网络,我们不必去深究所有这些数字都是什么。但如果你想真正看清楚的话:我们会把位置转换成数字,作为输入层;把面积转换成数字;把卫生间数转换成数字。然后,这里的每一条连线就是真正的旋钮。它就是那个数字,就是权重。比如纬度就带有一个权重输入进去,而在这个例子里有三层中间层。这样我们就能构造出一个函数。而你所做的,基本上就是——

[600s - 720s]

You’re filling in. This is a number. This is a number. This is a number. This is a number. You’re multiplying this number by this number, plus this number by this number, plus this number by this number. And I know it gets very complicated, which is why this is really yeah. This this looks intimidating, but I think the way to think about it is what we did on that previous slide with the knobs. It’s just a much more sophisticated version of that. Yes. Yes. Exactly. At the end of the day, we are just turning knobs, and we are building these functions. And as you can see, these are functions that are now you know relatively complicated, even though we’re just turning knobs. Now, as you can see, it would get very time-consuming to have to go in and individually tune each knob. You know, okay, we tune these knobs, and then we run these examples, and then we see that we’re off by this amount. Okay, well, let’s adjust this knob. Let’s adjust this knob. You know, there’s there you can do it by hand, but the great the great invention really of neural networks is we can actually do this. We can have the computer calculate a lot of how we should tune these knobs automatically. And I will now get to that. But just before, I know this seems relatively simple, right? Our neural networks really just they’re just numbers, and then it’s a Python script generally that really just describes how these numbers are ordered and wired, and that is really it. So you know what is a language model? A language model is really just a download from Hugging Face, which has the numbers, and the numbers are the brain. That’s actually the parameters. So when we say you know there’s a two trillion parameter model, that means they’re they’re basically two trillion numbers, and then we have a Python function that describes the wiring of all of these numbers, which will ultimately build the compute graph, which we will then run.

【译】往里填数字。这是一个数、这是一个数、这是一个数、这是一个数。你拿这个数乘以这个数,加上这个数乘以这个数,再加上这个数乘以这个数。我知道这会变得非常复杂,这也是为什么……对。这看起来确实吓人,但我认为理解它的方式,就是回到我们上一页幻灯片里讲的旋钮,它只是那个东西复杂得多的版本。对,对,没错。说到底,我们就是在转旋钮、在构建这些函数。如你所见,这些函数现在已经相当复杂了,尽管我们做的只是转旋钮。另外你也看到了,如果要钻进去一个一个地手动调每个旋钮,会非常耗时:好,我们调这几个旋钮,跑一遍这些例子,发现偏差了这么多;好,那就调一下这个旋钮、再调一下那个旋钮。手动做当然可以,但神经网络真正伟大的发明在于:我们真的能做到让计算机自动算出这些旋钮该怎么调。这一点我马上就会讲到。不过在此之前——我知道这看起来相对简单,对吧?我们的神经网络真的就只是一堆数字,外加一段 Python 脚本,这段脚本描述的就是这些数字如何排列、如何接线,仅此而已。那么,什么是语言模型?语言模型其实就是一份从 Hugging Face 下载下来的东西,里面装着那些数字,而那些数字就是大脑——那其实就是参数。所以当我们说有一个两万亿参数的模型,意思就是它基本上就是两万亿个数字,然后我们有一个 Python 函数,描述所有这些数字的接线方式,最终构建出计算图,然后我们再运行——

[720s - 840s]

The inputs through, and then we will get our output. But it is really, really as simple as just tuning knobs. I said before that there’s a better way than just hand tuning these, right? So, if you’ve heard of PyTorch or JAX or or TensorFlow, these are called autograd engines. And at the end of the day, really what they’re doing is they are keeping track of all of the parameters, all of the numbers, and all of the computations that those numbers are involved in. And then they are keeping track, and then they are, you know, at the end you get your value, which is how much you are off by. So in this case, we were off by you know around point two million dollars. And then what the autograd engine, what PyTorch is doing, it’s keeping track of all of the calculations, and it knows what each parameter. It actually knows how much each parameter, if you were to wiggle it, if you were to update it, you know, by point one or by point zero, how much it would affect the ultimate loss. So how much if we wiggle this size? How much should it ultimately affect this position? So the way it does this is that ultimately we are just creating you know a function. We are creating a very complicated function that ends up outputting the loss, but it’s a function. And what we can do is we can take the derivative of each parameter. So with respect, so we can take the derivative of this ultimate loss, how much we are off by, with respect to each single parameter. And so you can imagine we have this size weight, which is multiplied. Jeremy, sorry, let me interrupt for a sec. There was a lot of terms thrown out. Maybe you can just use the most basic terms and then go deeper. Yes, yes. Taking a step back, we are ultimately just building a function that takes in the inputs. It multiplies these inputs by a variety of numbers, which are the knobs, and then we get.

【译】把输入跑进去,然后就会得到我们的输出。但这件事真的、真的就简单到只是调旋钮而已。我之前说过,比起手动去调,还有更好的办法,对吧?如果你听说过 PyTorch、JAX 或者 TensorFlow,它们被称为 autograd 引擎。说到底,它们做的事情就是跟踪所有参数、所有数字,以及这些数字参与的所有运算。它们一直在记录,到最后你会得到一个数值,也就是你偏差了多少。在这个例子里,我们偏差了大约二十万美元。接下来,autograd 引擎、PyTorch 所做的,就是把所有这些计算都记录下来,并且它知道每个参数——它确切地知道每个参数如果你去拨动它一下,比如把它更新 0.1 或者 0.0,会对最终的 loss 造成多大影响。也就是说:如果我们拨动这个「面积」,最终会对这个结果产生多大影响?它的做法是这样的:归根结底,我们只是在创建一个函数,一个非常复杂、最终输出 loss 的函数,但它就是个函数。而我们可以对每个参数求导——也就是说,我们可以拿这个最终的 loss、拿我们偏差了多少,去对每一个单独的参数求导。你可以想象,我们有一个「面积权重」,它被乘在那里——Jeremy,抱歉,让我打断一下。刚才一下子抛出了太多术语,能不能先用最基础的说法讲,然后再往深走?好,好。退一步说,我们归根结底只是在构建一个函数:它接收输入,把这些输入乘上一系列数字,也就是那些旋钮,然后我们得到——

[840s - 960s]

An output, and we can tell how different that output is from what we expected. With just this information, we can then determine how much, basically, if we what the effect of changing one of these knobs is on the final loss. In other words, if we were to shift this, this this parameter, this this knob, how much? What is the effect on the final loss? And we can do this per parameter. And so, let’s say we shift this, and the effect actually on the loss is something like three. So, for every one change we make in the size, the loss is let’s say increased by three. So now we actually know. Well, if we want to minimize the loss, right? Well, we can just make this number a bit smaller. And if we make this number a bit smaller, we are going to decrease the amount we’re off by. And we can do this per parameter. And so, what PyTorch is really doing is it’s saying for each of these knobs, what is the effect of each of these knobs on the final result, such that we can now know how to slightly adjust each knob to get closer to the actual number that we’re trying to get to. And PyTorch is traditional software. It is a piece of software that kind of manages this entire pipeline for us. Exactly right. PyTorch is tracking the effect of this knob on ultimately on the outcome of the prediction. And so, at the end of the day, it will tell us how much a change in this knob will affect the loss. And once we know how much, what what is the effect of this parameter on the final loss? We can then inch it.

【译】一个输出,而且我们能判断这个输出和我们预期的相差多少。仅仅凭这些信息,我们就能确定:改动其中某一个旋钮,会对最终的 loss 造成多大的影响。换句话说,如果我们挪动这个参数、这个旋钮,会怎样?它对最终 loss 的作用是什么?这件事我们可以对每个参数分别做到。比如我们挪动它,对 loss 的效果是 3 这样的数——也就是说,面积每改动 1,loss 就(比如)增加 3。这样一来我们就真正知道了:我们不是想把 loss 最小化吗?那就把这个数字调小一点。只要把这个数字调小一点,我们的偏差量就会减小。这可以对每个参数逐一进行。所以 PyTorch 真正在做的,就是对每一个旋钮回答:这个旋钮对最终结果的影响是多大——这样一来,我们就知道该把每个旋钮朝哪个方向微调多少,去逼近我们想达到的那个真实数字。而 PyTorch 是传统软件,就是一段替我们管理这整套流水线的程序。完全正确。PyTorch 跟踪的就是这个旋钮对预测最终结果的影响。到最后,它会告诉我们这个旋钮的改动会影响 loss 多少。而一旦我们知道了这个参数对最终 loss 的影响有多大、是什么方向,我们就可以一点一点地挪动它了。

[960s - 1080s]

Either in a positive direction or negative direction, right? We can add point one or subtract point one, and that will get us closer to the actual prediction. And so this is, and we do that for every single parameter. So every parameter, every knob is moved slightly, such that if you were to run the inputs again, you would get closer to the right answer the next time. And and it’s it’s not guessing at this stuff. It is it actually has to run the calculation and figure out what how how the different knob turns will affect the final output. How will how will it it will affect the loss? Right, and the way it does this is is ultimately uses the the chain rule from calculus. I think it’s probably we shouldn’t get into this, and there are videos that can describe this. Yeah, a little too deep. I think it’s good to just take for granted. Take for granted that PyTorch will basically give you this information. So you, yeah. No, I’m sorry, I cut you off. Please finish that. No, so so if we take for granted that PyTorch will give us this information, what we have, we have the amount we were off by given our current knobs, and then we know that if we just adjust the knobs according to how much PyTorch says they will affect the loss, so in the right direction. So if if this knob, if we increase this knob, the loss will go down. We should increase it, and if we decrease and vice versa, right? If if if the loss, if PyTorch tells us, oh, actually, when this when this gets larger, the loss grows, as in our inaccuracy grows. Oh, well, let’s make it a bit smaller. And the amount that we inch up or down by is determined by the learning rate. And somebody who’s just learning this for the first time doesn’t necessarily need to know what’s happening under the hood of PyTorch. Totally, it does it automatically. And I’ll actually I have some code, very simple code that will show you the few lines, the only lines where where this is all done automatically for you, and.

【译】往正方向或者负方向挪,对吧?我们可以加 0.1 或者减 0.1,这样就会更接近真实的预测值。然后我们对每一个参数都这么做。也就是说,每个参数、每个旋钮都被轻微挪动,这样当你再次跑这些输入时,下一次就会更接近正确答案。而且它不是在瞎猜。它真的必须把计算跑出来,弄清楚各种不同的旋钮转动会如何影响最终输出、会如何影响 loss。对,而它实现这一点的方式,归根结底用的是微积分里的链式法则。我觉得我们大概不用深入这个,有不少视频可以把这部分讲清楚。对,稍微有点太深了。我觉得直接把它当成理所当然就好:就当 PyTorch 基本上会把这信息交给你。所以——抱歉,是我打断了你,你把刚才的讲完。没事。那么,假如我们认定 PyTorch 会给我们这个信息:我们手里有的,是当前这组旋钮下我们偏差了多少;然后我们知道,只要按照 PyTorch 所说的各旋钮对 loss 的影响幅度去调整它们——也就是朝对的方向调。如果这个旋钮调大了 loss 会下降,那我们就该把它调大;反过来也一样,对吧?如果 PyTorch 告诉我们:哦,实际上这个变大的话 loss 会涨,也就是我们的不准确性会变大——那好,我们就把它调小一点。而我们每次上下微调的幅度,是由学习率决定的。第一次接触这些内容的人,并不一定需要知道 PyTorch 引擎盖底下发生了什么。完全同意,它自动就做掉了。我这里其实准备了一些代码,非常简单的代码,给你看其中那几行——也是仅有的几行——这一切都替你自动完成的地方……

[1080s - 1200s]

What this looks like in practice, I just have a quick. So I’m going to hit auto train here, and as you can see, it’s automatically updating. Let’s reset auto train. So it’s automatically adjusting those knobs, right? So that we are minimizing the amount that we are off by, and so it looks like possibly the best we’re going to get is around being off by you know 0.07 million dollars, and that’s that’s actually because we only have a simple linear really function here, right? This is a very simple function, but if you add more layers to your neural network, as in you have functions inside functions inside functions inside functions, each with their own knobs, and we have activation functions which change it so that you can represent more complicated relationships, we won’t which we won’t get into. You can actually you can represent any function with a neural network, which is a really cool property. It’s called a universal function approximator because you just add more layers, you add more knobs, and you can get to any function. So in theory, we can actually get this loss to zero if we added a ton of knobs and a ton of layers. Awesome, and and and you’re like what you have just described is the basic unit of all AI today. Yes, exactly. This is called backpropagation. Yes, this is how we are able to update our knobs in a directed fashion to minimize the difference between what is actually in the world that we want to model and what our model gives us. Now, the important ingredients going into this is you need the inputs. You actually need to know, okay, where’s the home located? What’s the size? How many baths? And then you also need to know the real world answer. What did that apartment actually sell for? Yes, exactly. Right, and.

【译】实际跑起来是什么样子。我快速演示一下。我现在点一下「自动训练」,如你所见,它在自动更新。我们把自动训练重置一下。它就是在自动调整那些旋钮,对吧?好让我们的偏差量不断变小。这样看起来,我们最好大概能做到偏差七万美元左右。这其实是因为我们这里只有一个简单的线性函数,对吧?这是一个非常简单的函数。但如果你给神经网络加上更多层——也就是函数里套函数、再套函数、又套函数,每一层都有自己的旋钮——再加上激活函数(它能让网络表达更复杂的关系,这个我们就不展开了),那你就真的可以用一个神经网络来表示任何函数,这是一个特别酷的性质。它叫做万能函数逼近器,因为你只需要加更多层、加更多旋钮,就能逼近任何函数。所以在理论上,如果我们加上海量的旋钮和海量的层,真的可以把这个 loss 压到零。太棒了。而你刚才所描述的,其实就是当今所有 AI 的基本单元。对,没错。这就是所谓的反向传播。是的,这就是我们如何能有方向性地更新旋钮,把世界上我们想建模的真实情况与我们模型给出的结果之间的差距最小化。这里面重要的原料是:你需要输入。你得真的知道——好,这套房子在哪?多大?几个卫生间?然后你还需要知道现实世界的答案:那套公寓实际卖了多少钱?对,没错。是啊,还有——

[1200s - 1320s]

You know there are various. There’s a lot to cover in this. I think for now, yeah, this is this is the intuition behind it, and we could of course go deeper. And as a final point to this, I’m going to show some code, very simply that actually does this in PyTorch. So you don’t really you don’t need to know. I don’t want people. You know, no one should be scared off by this code. This is just turning these inputs into numbers. These are the labels. So this is the the home prices, and then this is the training. This is it. This is the training. And so here is our prediction. So we run we run the model. We we run the the the function. We calculate what the predictions are. This is our loss that we were just describing. This is how off we were, and now all we this means that we’re just zero. We’re starting a new step. So forget everything that we’ve we’ve done before. We’re going to loss dot backwards, which means we’re going to calculate for each of the parameters what is their effect on the loss, and then we are going to take a step according to our learning rate, which says given that now we know the directions that we should be making parameters larger or smaller and the amount. Let’s do that, and now we can test. And so I’ll just run this quickly. Again, you really don’t need to know what’s happening, but this is just an example of literally it’s it’s this. This is what PyTorch gives us. This would be a lot of code. If and if this seems a little bit complicated, what’s really nice is Claude and ChatGPT. These systems are extremely good at writing and explaining code. So you can literally have it write this code for you, adjust it for you, explain each line in detail. So if you want to go a little bit deeper, that’s a great way. Yes, definitely. Yes. So this ran, and here is what we are seeing. Again, this is not how you would want to train this in production. This is just a toy example. And so for each of our optimization steps, right.

【译】这里面名堂很多,可以讲的东西非常多。我觉得就目前而言,对,这就是它背后的直觉,我们当然还可以再往深讲。作为这一部分的收尾,我给大家看一段代码,非常简单地在 PyTorch 里实际做这件事。所以你真的不需要看懂。我不想让大家被这段代码吓到——没有人应该被它吓到。这里只是把这些输入转换成数字。这些是标签,也就是房价;然后这就是训练。就这样,这就是训练。这里是我们的预测:我们跑模型,跑那个函数,算出预测是什么。这是我们刚才一直在讲的 loss,就是我们偏差了多少。而这下面这些,意味着我们刚做了归零,开始新的一步。所以,把之前做过的一切都忘掉。我们要调用 loss.backward(),意思是针对每个参数算出它对 loss 的影响;然后按照学习率走一步——既然现在我们知道了该把各参数调大还是调小的方向和幅度,那就来吧。现在我们可以测试了。我很快跑一下。再说一遍,你真的不需要知道发生了什么,这只是个例子,事情就是这么回事,这就是 PyTorch 提供给我们的东西。这些要是手写,会是很大一段代码。如果这看起来有点复杂,好消息是:Claude 和 ChatGPT 这类系统在编写和解释代码方面极其强大。你完全可以让它替你写出这段代码、替你修改、再逐行详细解释。所以如果你想再深入一点,这是个非常好的途径。对,绝对是的。好,这个跑完了,下面是我们看到的结果。再强调一次,这绝不是你在生产环境中训练模型的方式,它只是个玩具例子。那么,对于我们每一个优化步骤,对吧——

[1320s - 1440s]

Each tuning of the knob, and actually, in this case, we are taking training steps, so a thousand steps, a thousand tunings, and we are getting results for every one hundred, just so that we don’t have a thousand outputs. So at step zero, right, randomly initialize knobs. Our losses is eight, and our prediction for an Upper West Side, and this loss is using a mean squared error. The larger the loss, the worse it is. It is basically taking the literal difference in prices and and turning it into you know a loss which we won’t get into here, but but the larger it is, the the worse the prediction was. And so, so how does it how does it know to head in the right direction? So like it could just test a bunch of those in a bunch of the knobs randomly, but it seems like it’s kind of you know heading towards the correct answer. How does it know to continue towards that correct answer? Yeah, so when we do loss dot backwards, what PyTorch is doing is it’s saying for each parameter, I know where it was involved in calculating the final result, and I know how off the final result was from what I wanted to get, right? Which is actually calculated here. So here’s the predictions, what we actually said. Here is minus the actual labels. We’re going to square it, take the mean, which is which is generally how we. I won’t get into this, but this is a way of turning those into you know numbers that are are are useful for PyTorch. And so what this loss dot backwards is saying is for each of these parameters, what effect if I were to make them larger, if I were to increase the knob, what effect would they have on the loss? Would it make the loss larger or would it make the loss smaller? And now that we’ve calculated this, so what actually happens in each of these parameters, which is a compute graph, we have a dot grad which tells it the effect of that parameter moving up on the loss, and we do this step, which then nudges.

【译】每转动一次旋钮——实际上在这个例子里我们做的是训练步,也就是一千步、一千次调节,而我们每一百步取一次结果,免得拿到一千份输出。所以在第 0 步,对吧,随机初始化旋钮,我们的 loss 是 8,这是我们做出的对上西区一套房价的预测,而这个 loss 用的是均方误差。loss 越大,效果越糟。它基本上就是把价格上的实际差值变成一个 loss,具体细节我们这里不展开,但 loss 越大,就说明预测得越差。那么——它是怎么知道要朝正确方向走的呢?它本来也可以对一堆旋钮做一堆随机测试,但看起来它是有点在朝正确答案逼近的。它怎么知道要继续朝着那个正确答案走?是的。当我们执行 「loss.backward()」 的时候,PyTorch 做的事情是:对每一个参数,它都知道这个参数在计算最终结果的过程中起了什么作用,也知道最终结果离我想要的目标差了多少,对吧?而这个差值就是在这里算出来的。这里是预测值,也就是我们实际给出的东西;这里减去真实的标签,然后平方、取平均——一般来说我们就是这么……这个我不细讲,但这就是把这些东西变成对 PyTorch 有用的数字的一种方式。而 「loss.backward()」 说的就是:对于这些参数中的每一个,如果我把它们调大、如果我把这个旋钮调大,会对 loss 产生什么影响?是让 loss 变大,还是让 loss 变小?算完之后,实际发生的事情是——每个参数所在的这个东西叫计算图(compute graph)——我们都有一个 「.grad」,它告诉我们这个参数往上调会对 loss 造成什么影响,然后我们执行这一步 step,它就会去轻轻推一下——

[1440s - 1560s]

That parameter either makes it larger or smaller, according to the direction of what is called the gradient. But really, in terms, we are making it smaller or larger to decrease the loss if we were to run this again. So we are nudging it in the direction that will minimize the loss. And again, it knows that because it knows how each parameter, how each knob, is related to the final loss. It’s kept track of this the whole time, and so it can tell. Yeah, if we make it larger, what is the effect on the loss? We’ve now kind of have an overview of how general non-language model neural network works, which is you have specific inputs, they are of specific, you know, numbers, and then they output a specific number, and we can basically calculate given this output how how close are we to the expected output. Language models are totally different beasts. They are much more general. But what’s interesting is we can take the same document, the same data, and we can build a language model that will also predict the price, but we do it with language. And so the inputs, the inputs are now the actual words on this document. Really, in reality, they’re tokens, which are fractions of words or multiple words put together. But for now, simplify. Let’s just say they are words. And so the model, the training data as input, will be words as a sequence. So at first, it will just see Soho. It’ll predict this comma. Soho comma. It should predict twelve hundred. Soho comma twelve hundred. And so, sorry, real quick. So we’re looking at the same data, right? Soho twelve hundred two bath, which before were individual inputs, but now we’re looking at it as just like pure text, where it’s just like here’s a string of text. Let’s continue and look what the next potential token or word is. Yes. Yeah. And fundamentally, at a high level, neural networks are finding patterns in your data, and they are.

【译】那个参数,要么把它调大,要么把它调小,方向由所谓的梯度(gradient)决定。但说白了,我们把它调大或调小,是为了让下一次运行时 loss 变小。也就是说,我们是在朝能把 loss 最小化的方向轻推这些参数。而它之所以知道该这么推,是因为它清楚每个参数、每个旋钮与最终 loss 之间的关系——它从头到尾一直在记录这件事,所以它能判断:对,如果把它调大,loss 会受到什么影响。到这里,我们算是大致看懂了一个通用的、非语言模型的神经网络是怎么工作的:你有特定的输入,它们是一些特定的数字,然后它们输出一个特定的数字,而且我们基本上能计算:给定这个输出,我们离期望的输出有多近。语言模型则完全是另一种野兽,它通用得多。但有意思的是,我们可以拿同一份文档、同一份数据,构建一个同样能预测价格的语言模型——只不过是用语言来做。于是输入就变成了这份文档上实际的文字。当然,现实中它们是 token,也就是一个词的碎片,或者多个词拼在一起。但现在为了简单起见,我们就先说它们是词。于是,作为输入的训练数据就是一个词的序列。一开始它只会看到 「Soho」,然后预测出这个逗号——「Soho,」;接着它应该预测出 1200——「Soho, twelve hundred」。然后——不好意思,快问一下。我们看的还是同一份数据,对吧?「Soho twelve hundred two bath」,之前这些是各自独立的输入,而现在我们把它当成纯文本来处理:这里就是一串文本,让我们接着往下看,下一个可能的 token 或词是什么。是的。对。而从根本上、从高层次看,神经网络就是在你的数据里找模式,而且它们——

[1560s - 1680s]

Really becoming your data. So the idea is they are learning to output given the data that it’s already seen and the patterns it has ingested. What is the most likely next word, such that I am being faithful to the data that you presented me with? So, so in essence, neural networks really are just the data that you are putting into it, right? So if we only feed it this type of document, and let’s say this document is a million lines, right? It it knows how to only make sense of these types of words, but it should, at the end of the day, actually understand the patterns in the data, such that it can also output a next a word, which in this case will be the prediction for the price of the of the unit. And Jeremy, when we’re so the previous model we’re running is very different from what a large language model is. First, can you remind me what the previous model is called? The previous model was just a neural network. Okay. Can neural networks or are neural networks more accurate when you’re looking for a very specific answer versus like a text based answer? Right. So the real answer is with enough data and compute, they should converge to the same thing, which is finding the correct function for to map your data and finding the patterns. So in the limit, these should converge. However, with finite resources, if there’s a problem where you’re just wanting to output the price of something, you would certainly prefer to just have a normal neural network. A language model is a you know in the subgroup of of neural networks, like you know language model is a deep neural network. But the point is, you know, neural networks will get the gist of the thing. These are two flavors of neural networks, but fundamentally, what is happening under the hood is knobs are adjusting to map inputs.

【译】真正变成了你的数据本身。也就是说,它在学习的是:在已经见过的数据和已经吸收的模式的基础上,最有可能的下一个词是什么,同时让我忠于你交给我的这份数据。所以从本质上讲,神经网络真的就是你喂给它的那些数据,对吧?如果我们只喂它这一类文档——比方说这文档有一百万行,对吧——那它就只会理解这类词。但归根结底,它应该真正吃透数据中的模式,从而也能输出下一个词——在这个例子里,这个词就是那套房源价格的预测。还有 Jeremy,我们之前跑的那个模型跟大语言模型很不一样。首先,能再提醒我一下之前那个模型叫什么吗?之前那个就是一个神经网络。好。当你想要一个非常具体的答案,而不是基于文本的答案时,神经网络会不会更准?对的。真正的答案是:只要有足够的数据和算力,它们应该会收敛到同一个东西,也就是找到映射你数据的正确函数、找到其中的模式。所以在极限意义下,这两者会收敛到一起。不过,在资源有限的情况下,如果一个问题只是想输出某个东西的价格,你肯定会更想直接用一个普通的神经网络。语言模型是神经网络的一个子类——你知道的,语言模型是一个深度神经网络。但重点是,神经网络会把事情的大意抓住。这是神经网络的两种口味,但在底层真正发生的事情,都是旋钮在不断调整,去把输入映射——

[1680s - 1800s]

To outputs, and if you do it for a long enough time with you know the same data, they should converge to the same answer. Now, as you can tell, language is a whole new beast, right? Because there are so many more degrees of freedom with language than there are with numbers, or you know, with specific numbers that mean a certain thing. So, compute for compute, you will always prefer to do just a normal neural network. But the the underlying, you know, the the truth is, they will both converge to the the correct answer, which is to find the function, the the correct function, the correct pattern from from input to output. And because there’s so much more flexibility with a language model, that makes it take much more data, much more input data to converge to the same level of accuracy as a as kind of the previous neural network we were just looking at would be, right? That’s generally correct. Yes. Okay. Yeah. There’s a there’s a lot of nuance with what you said, but but absolutely, right? There are so many degrees of freedom. There are so many complicated relationships now that we’re in language space. That yeah, you’re going to need a lot more parameters and a lot more compute to to make sure that it really grasps the pattern. Cool. So yeah, but ultimately, you know, language models are are just a new flavor of neural networks, but much more general. And so, what’s really cool is, okay, we care about predicting the next phrase. Sure, we can use a language model for it. But the the beauty is, we can dump any text, train any language model on any amount of text, like the entire internet, and now it’ll soak up the patterns of the internet. And ultimately, if you train it well, it will be able to predict the next word as an autocomplete of a good of a given text, and it will reflect the data that you gave it. So if you train it on the entire internet and then you ask it to just you know start generating next words, it will generate the most likely words given.

【译】到输出上;而且只要你用同样的数据做足够久,它们就会收敛到同一个答案。那么,你也看得出来,语言是一种全新的野兽,对吧?因为语言的自由度比数字多得多——比那些有特定含义的具体数字多得多。所以,单就同等算力而论,你永远会更愿意只做一个普通的神经网络。但底层的真相是:两者都会收敛到正确答案,也就是找到那个函数、那个正确的函数、从输入到输出的正确模式。而正因为语言模型的灵活性大得多,它就需要多得多的数据、多得多的输入数据,才能收敛到跟我们刚才看的那个神经网络同等的精度,对吧?大体上是对的。是的。好。嗯。你说的内容里有很多细微之处,但绝对是这个道理,对吧?自由度实在太多了。一旦进入语言空间,复杂的关系也实在太多了。所以没错,你会需要多得多的参数和多得多的算力,才能确保它真正抓住模式。酷。所以归根结底,语言模型只是神经网络的一种新口味,但通用得多。而真正酷的地方在于:好,我们关心的是预测下一个短语,当然,我们可以用语言模型来做这件事。但妙就妙在,我们可以倾倒任何文本、用任意数量的文本去训练任意一个语言模型——比如整个互联网——那它就会把互联网的模式统统吸收进去。归根结底,只要你训练得好,它就能作为自动补全去预测给定文本的下一个词,而且它会反映出你喂给它的数据。所以,如果你用整个互联网训练它,然后让它就直接开始生成下一个词,它就会生成最有可能的那些词,其依据是——

[1800s - 1920s]

The input, which is the internet, and so it is finding all of these patterns, and it is really what its data is ultimately. And I think you know one obvious question is well, it was easy to calculate the loss, the the how off we were when we were just outputting numbers at the end. But with language, you’re outputting a word at the end. How are we supposed to compare 1.2 million to 1.5 million? These are two words. Well, the trick is language models don’t output the final layer of the of a neural network when we’re predicting just the price is just one. It’s just the price. It’s the number. With language models, you actually the final layer are the number of words that you could possibly predict next, and each of them is assigned a probability of how likely the model thinks that token that next word should be. And now you can compare the probabilities. So let’s say the right answer is 1.2 million, and as we’re training, the language model thinks this is only 10% likely, but the real answer is it’s 100% likely because it actually happened. For the the the real world says 1 1.2 million is the right answer. So now we tune our knobs to turn what was 10% likely, we want to inch it towards 100%. So we want to make this more likely 1.1 or 1.2 million more likely slightly. We’re going to nudge all of the input knobs to make 1.2 just a bit more likely, which by definition makes everything else a bit less likely. And this is how we’re training these neural networks. Here is a real example of using Qwen 2.5 0.5B, which is 500 million knobs numbers, and we have two models here. We’re going to take a base model, which is a pre-trained model from Qwen, and we’re going to start with this. And so what the base model says is again we’ve taken all of the internet, and we now have this model, and we can now generate completions from it. We have now created

【译】输入,也就是互联网。所以它是在找出所有这些模式,而归根结底,它就是它的数据本身。我想有一个显而易见的问题:之前当我们最后只是输出数字的时候,计算 loss、算我们偏差多大是很容易的。但在语言里,你最后输出的是一个词。那我们该怎么拿 120 万跟 150 万比较呢?这可是两个词啊。嗯,诀窍在于:当我们只预测价格时,神经网络的最后一层只有一个输出——就是价格,就是那个数字;而语言模型的输出不是这样的。语言模型最后一层的输出,实际上是你下一个可能预测出的所有词的数量,每一个都被赋予一个概率,表示模型认为那个 token、那个下一个词该出现的可能性有多大。现在你就能比较概率了。比方说正确答案是 120 万,训练时语言模型认为它只有 10% 的概率,但真实答案是它 100% 会发生,因为它实际上发生了——现实世界说了,120 万才是正确答案。于是我们现在调整旋钮,要把那个原本只有 10% 概率的东西,一点一点往 100% 推。也就是说,让 110 万、120 万稍微更可能一点。我们会轻推所有的输入旋钮,让 120 万这个答案变得稍微更可能一点——而按照定义,这会让其他所有选项都稍微更不可能一点。我们就是这样训练这些神经网络的。这里是一个真实例子,用的是 Qwen 2.5 0.5B——也就是 5 亿个旋钮、5 亿个数字——我们这里有两个模型。我们要取一个 base model(预训练模型),也就是 Qwen 训练好的预训练模型,我们从它开始。这个 base model 意味着:我们已经把整个互联网读进来了,现在有了这个模型,我们可以从它生成补全了。我们等于刚刚造出了——

[1920s - 2040s]

A complete an autocomplete from the internet. So all it knows to do is is complete texts that are similar to those that it has seen in in training. So we can actually just take it for a spin here. This should already be loaded. Cool. Okay. So what I’m doing here is just two examples. I’m giving it an input of zero. So it’s basically saying I’m asking it, and then I’m asking it to generate a hundred new words. And so what we would expect is it’s going to generate words that it’s that are in what it’s been trained on. It thinks it’s most likely randomly. So we can tell that this model Qwen has been trained on a lot of code because the first thing it outputs are code, right? Just auto completing from the internet. And then the second thing is this weird Chinese thing. So it’s obviously also been trained on text that looks like this. So we can it’s safe to assume that a lot of the training data in the Qwen model that it’s been trained on this base model looks like this. Now it’s autocomplete. So I can actually say Matthew Berman said, and now it’s going to generate a hundred tokens that follow said, and we get to just see what’s in this weird mind of this model that has seen basically all of the internet. Matthew Berman said in this interview that a good book should be of of a good story with main character. I don’t think you said this. I don’t remember saying that. I don’t think you said anything. But the point is this is a an autocomplete. It’s it’s it’s repeating what it thinks will given all of the inputs that it’s been trained on what are likely things that should follow, and that is really all that this is doing. But it’s fun to play around with. So again, it’s autocomplete. You can put anything you want in here, and then it will output something interesting. And if you remember, yeah. Real quick, Jeremy. So I think one interesting thing to point out is that this Qwen model was trained probably a while ago, and maybe or the reason why it’s making something up about what I.

【译】一个来自互联网的自动补全。它所知道的全部,就是去补全那些与它训练时见过的文本相似的文本。那我们可以直接在这儿试玩一下,这个应该已经加载好了。酷。好。我在这里做的是两个例子。我给它的输入是 0——基本上就是我在向它提问,然后让它生成一百个新词。我们预期它会生成训练数据里的那些词,也就是它认为(在随机输入下)最有可能的词。所以我们能看出这个 Qwen 模型训练过大量代码,因为它最先吐出来的东西就是代码,对吧?纯粹是在对互联网做自动补全。然后第二个东西是这种奇怪的中文,所以它显然也训练过长得像这样的文本。所以我们可以放心地认为,Qwen 这个模型、这个 base model 的训练数据里,有很多就是长这个样子的。好,现在它是自动补全。所以我可以直接输入 「Matthew Berman said」,然后它会生成一百个跟在 said 后面的 token,我们正好可以看看这个基本见过整个互联网的怪脑子里到底装了什么。它输出的是:「Matthew Berman said in this interview that a good book should be of a good story with main character.」我觉得你没说过这话。我不记得我说过。我甚至觉得你什么都没说过。但重点是:这就是一个自动补全。它是在复述——给定它训练时见过的全部输入,它认为接下来最有可能跟着出现的是什么——而这真的就是它做的全部事情。不过拿它玩一玩挺有意思的。所以说到底,它就是自动补全。你可以在这里放任何你想放的东西,然后它就会输出一些有意思的玩意儿。如果你还记得的话——好。快问一句,Jeremy。我觉得有一点挺值得指出的:这个 Qwen 模型大概是挺久以前训练的,也许——或者说,它之所以会编造"我说过什么"之类的内容,是因为——

[2040s - 2160s]

Said is because it has no information about it. Nothing in the training data told it what I have said. Now, if, as part of the training data, it took some of my YouTube videos, transcribed them, and put them in the training data, it would know what I said. That is true. However, I’ll note that a pre-trained model might not have been trained to output necessarily things that are coherent or correct or not hallucinated, but it will definitely sound more like you if it has been trained on data that you’ve actually said. It it might not give verbatim things that you’ve said. So it’s definitely been trained on Einstein, right? And these might be correct quotes. But also, what you’ll see is this is a bit incoherent, right? The answer to this question is in the text. My understanding is this is like incoherent, right? This is this is autocomplete. It’s just it’s just producing what it thinks is most likely. But this is actually not very useful. It might be useful, you know, for this amount. Maybe if you want to write an email, it’s seen a lot of emails. It can give you the gist of what a good email might be. Um, but this is also not very useful. So if you remember, you know, the pre ChatGPT days, generally these were were base models, and the base models aren’t trained to be helpful. They aren’t trained to necessarily tell the truth. They are just trained to autocomplete whatever is given to them. And so this is pre-training. Pre-training is okay. We have this incredible neural network where we can we can train it on anything we want, any text we want, and it will have the gist, the patterns of this text, and it will predict things that it thinks are likely given the text that it’s been trained on. With no guarantee that it’s correct. It’s just what’s what’s more likely. What’s what’s likely? What’s likely? What’s likely? Given the text that it’s been trained on. So the question is, how do you turn this into a chatbot or something useful? So one idea could be, well, what if we actually

【译】它手里根本没有这方面的信息。训练数据里没有任何东西告诉它我说过什么。那么,如果它把我的部分 YouTube 视频拿来做训练数据——转录出来、放进训练数据里——它就会知道我说过什么了。确实如此。不过我要指出:一个预训练模型未必被训练成会输出连贯的、正确的、不产生幻觉的东西;但如果它训练所用的数据是你真说过的话,它听上去肯定会更像你。它未必会逐字逐句地给你你说过的话。比如它肯定训练过爱因斯坦的文本,对吧?这些引语也可能是对的。但你也会看到,这东西有点不连贯,对吧?这个问题的答案就在文本里。我的理解是,这就属于不连贯,对吧?这就是自动补全,它只是在产出它认为最可能的东西。但这其实没什么大用。在这个份量上也许有用——比如你想写封邮件,它见过海量邮件,能给你一封好邮件大概长什么样。嗯,但这也确实不太有用。所以如果你还记得 ChatGPT 出现之前的那些日子:当年的这些模型一般都还是 base model,而 base model 并没有被训练得乐于助人,也没有被训练得一定讲真话,它们只是被训练去补全任何丢给它们的东西。而这,就是预训练(pre-training)。预训练是:好,我们有了这个不可思议的神经网络,可以用我们想要的任何东西、任何文本来训练它,它就会掌握这些文本的大意和模式,并基于它训练所用的文本,预测它认为可能出现的东西。没有任何"它是对的"的保证,只是"什么更有可能"而已。什么可能?可能?可能?——都是就它训练所用的文本而言。于是问题来了:你怎么把它变成一个聊天机器人,或者什么有用的东西?有一个想法可能是:那要是我们真的——

[2160s - 2280s]

Actually, if I say like, user, what is one plus one? Assistant. So people figured out that because it’s just autocomplete, what we can do is we can actually like figure out interesting things to prefill it with, such that then it starts out outputting, completing more of what we want it to. So what I just did is I kind of tricked it. I said, okay, there’s a this is a text we want you to complete. A user says, what is one plus one? Then the assistant colon, and we’re kind of tricking it into becoming an assistant, right? It’s taking all of what it knows about assistants online, and then it’s going to autocomplete it. And so, user, what is one plus one? Assistant, one plus one equals two. Okay, so now you know it goes on to something incoherent, but okay, we actually have an answer, and this is really cool. We’ve just turned this, you know, this autocomplete engine into something that could possibly be useful, and this is something that researchers found, and so they’re thinking, wait, okay, so if we come up with some sort of format, we can trick the model into being an assistant by basically like having complete, and if it were to complete the document, it would do what we want. And so here, this is the actual Qwen 2 formatting, so they come came up with something called im_start, im_end, and start, and we can actually just run this, and it will autocomplete as an assistant, but it hasn’t been trained to know when to stop, so it’s just going to continue and continue. It’s not necessarily a helpful assistant, but it is now assuming the role at least right here of the assistant. Like this is a correct answer. And when you say continue and continue, it’s literally just indefinitely predicting whatever the next token is, whatever the next word is. Right, and this is I I gave it 200 tokens, so for the next 200 tokens, predict what you think is the right thing to do. Right, and it doesn’t notice if you said 10,000, it would continue till that number as well. Okay, got it. Yes, yes, and as with language.

【译】真的去做——比如我输入 「user: what is one plus one? assistant:」。人们发现了:因为它就是个自动补全,我们能做的就是琢磨出一些有意思的内容给它预填(prefill)进去,让它由此开始输出、补全出更多我们想要的东西。我刚才做的就是有点"骗"了它一下。我说:好,这里有一段我们要你补全的文本——一个 user 说:what is one plus one? 然后是 assistant 的冒号——我们等于是在骗它去扮演一个助手,对吧?它会把它所知道的、网上关于"助手"的一切都调动起来,然后接着补全下去。于是,「user: what is one plus one? assistant: one plus one equals two」。好,接下来你也知道,它会继续输出一些不连贯的东西,但不管怎样,我们确实得到了一个回答,而这真的很酷。我们刚刚把这个自动补全引擎变成了一个可能真有用的东西。这是研究人员发现的,于是他们就想:等等,好——如果我们设计出某种格式,我们就能骗这个模型去当助手,本质上就是让它去补全,而只要它把这份文档补全完,它做的就是我们想要的事。这里就是 Qwen 2 实际使用的格式,他们搞出了叫 「im_start」、「im_end」 还有 start 的标记,我们可以直接跑一下,它就会以助手的身份做自动补全。但它还没被训练得知道什么时候该停,所以它就会一直继续、一直继续。它未必是个有帮助的助手,但至少此刻,它已经进入了助手的角色。你看,这是个正确的回答。还有,你说"继续又继续"——它就是在字面意义上没完没了地预测下一个 token 是什么、下一个词是什么。对。这里我给了它 200 个 token,也就是"在接下来的 200 个 token 里,预测你认为该做的事"。对。而且它自己意识不到——你要是说 10000,它同样会一直生成到那个数为止。好,明白了。是的,是的,而且对于语言——

[2280s - 2400s]

Models remember it’s predicting it’s predicting a sequence. So for each new word, it it adds that word to the sequence and then predicts the next one, adds that next word to the sequence and then predicts the next one. So we’ve noticed this. Researchers noticed this, and they’re like, okay, so we can now trick it into thinking it’s an assistant. So what if we just create a bunch of data for how we want the assistant to behave with our formatting, and then the model again, which will will learn the formatting that we’re telling it to learn, and it will become an assistant. And so this is what we do, and this is the start of post training, which is we’re taking this base model, which is kind of a model of the world, it can assume all of these various personas. It doesn’t know it’s an assistant; it has been trained to be an assistant, and we’re we’re filling it with a bunch of data. Maybe we start by having humans literally like write user queries and then write assistant queries, and then we’re training on it. And then we’re going to say we we generate a hundred thousand examples of an assistant auto completing, and we’re also going to include in these examples a stop token, which means this is when the assistant stops. And now the assistant learns, okay, my role. It’s starting to gain an ego here. My role is an assistant, and when I’m done responding to the user in a good way, as seen in the data, I should emit a stop token, and when the program sees the stop token, it stops generating. And so now I’m going to use the instruction model, which has been trained with this data to know that it’s an assistant. It now has an ego, and it should know how to stop. And as you can see here, why is the sky blue? The sky appears to be blue when sunlight, however, when light, so when we look up at the sky, the clouds different colors and refracted options in the air. Great. So this is a pretty pretty good response. And so comparing this this response to this response is really the difference between an instruct model.

【译】模型——记住,它是在预测一个序列。所以每来一个新词,它就把这个词加进序列,然后预测下一个;再把那个新词加进序列,再预测下一个。我们注意到了这一点,研究者们也注意到了,他们就说:好,既然我们现在能骗它以为自己是助手,那要是我们干脆造一大批数据——按我们的格式写好我们希望助手怎么表现——会怎么样?于是这个模型会学会我们让它学的格式,然后它就会变成一个助手。我们就是这么干的,而这正是后训练(post-training)的开始:我们拿这个 base model——它某种程度上是一个"世界的模型",可以扮演各种各样的人格——它并不"知道"自己是助手,它是被训练成了助手——然后往里面灌一大批数据。也许一开始我们让真人来写 user 的查询,再写 assistant 的回答,然后在这些数据上训练。然后我们会说:我们生成十万个助手自动补全的例子,而且在这些例子里还要放进一个 stop token(停止标记),意思是"助手到这里就停"。于是助手就学会了:好,我的角色——它在这儿开始长出一个自我(ego)了——我的角色是助手,当我按照数据里示范的样子,好好地回答完用户之后,我就应该发出一个 stop token;而程序一看到 stop token,就停止生成。所以现在我要用 instruct 模型(指令模型)了——它已经用这些数据训练过,知道自己是个助手,如今有了自我,也应该知道怎么停下来。你可以看到这里,「why is the sky blue?」——输出是「The sky appears to be blue when sunlight, however, when light, so when we look up at the sky, the clouds different colors and refracted options in the air.」很好,这算是相当不错的回答了。而把这个回答跟前面那个回答一比,这真的就是 instruct 模型——

[2400s - 2520s]

And a pre-trained or base model, and this probably in the Qwen 2 series was mostly really done with generating a bunch of data of good assistant messages with this formatting, and the model learns to learns the patterns and learns to be an assistant. And what is key here is every message. So this is what you might be familiar with when you actually like write to a language model, right? You have a role, user, content wise sky blue. Under the hood, the model is actually just generating this format and giving it to the model. So it’s trickery, right? Like you are just pre-filling the model with what it’s things that it’s been trained on, and then it can respond in a similar way. So these are this and this are equivalent. These are the exact same. So we’ve turned this auto completion engine into an auto completion engine that now understands has been trained to see a lot of assistant messages and knows now what good assistants sound sound like and can do it. And if you ever want to see what is actually being sent to the model, the actual tokens that the model is taking as input, you can just you can use the tokenizer. You can input the messages, and it will give you literally what the what the model sees. So when you write wise the sky blue, what the model is really saying is a system by default message, and then it is wise the sky blue, and it starts the assistant, so it knows to complete after assistant. And I just want to interject: if people want to try this, it is effectively free to do what you’re doing. You can use Google Colab for free. Qwen is an open weights model you can download for free. So and we’ll drop all the links to all this stuff down below. Yep, this is all free. I don’t have a special plan. I’m using a T4 for free on Google Colab. Cool. Yep. Okay, so this is the start of

【译】和预训练模型,也就是 base model,之间的区别。在 Qwen 2 系列里,这一步基本上就是靠生成大量符合这种格式的高质量助手消息数据做到的,模型学会了这些模式,也就学会了当助手。而这里的关键点在于每一条消息。这就是你平时给语言模型发消息时可能已经熟悉的东西,对吧?你有一个角色 user,内容是「为什么天是蓝的」。在底层,程序其实只是在生成这种格式,再交给模型。所以这就是一种「骗术」,对吧?你只是把模型训练时见过的那类东西预填(prefill)进去,然后它就能以类似的方式回应。所以这两个是等价的,是一模一样的东西。我们就这样把一个自动补全引擎,变成了另一个自动补全引擎——只不过它现在受过训练、见过海量助手消息,知道好的助手听起来是什么样子,并且能照着做。如果你什么时候想看看真正发过去的到底是什么、模型作为输入接收到的到底是哪些 token,你可以直接用 tokenizer(分词器):把消息输进去,它就会原原本本给你模型眼里的内容。所以当你输入「为什么天是蓝的」,模型真正收到的是一条默认的系统消息,然后是「为什么天是蓝的」,接着它把 assistant 的开头也预填好,这样它就知道要在 assistant 之后接着往下补全。我想插一句:如果有人想亲自试试,做这些事基本上是免费的。Google Colab 可以免费用,Qwen 是开放权重模型,可以免费下载。这些相关内容的链接我们都会放在下方。对,这些全都免费。我没有什么特殊套餐,我就是免费在 Google Colab 上用一块 T4 GPU。酷。好,那么这就是

[2520s - 2640s]

Post training, which is really exciting. We have an assistant model, and this is you know GPT-3. There are a lot of things I’m glossing over, but this is the general gist: is we’ve turned an auto complete engine, and we’ve tricked it with more data into thinking that it’s an assistant, and it’s now developed this assistant persona, and this is really cool and interesting. But now there’s kind of a separate problem, which is the models are you know can produce interesting things, but they are making obvious errors, right? If you ask it, I don’t know if you remember asking it math, right? It will seem very confident. It will return to you the answer without thinking, right? So here’s an example: what is you know 398 times 923 plus 2901, right? And the result of multiplication of this is is 37,000, which is wrong. The right answer is 370,000. So this model totally got it wrong, right? And the but it was an assistant, right? It generated it correctly. It knew knew to stop. So now there’s this new issue, which is the models are just blurted out whatever they they think, right? They’re not actually thinking. And when if I were to ask you this, you would you know think about it, think step by step, actually solve it, you know, thinking. And so one thing that researchers discovered is maybe all you need to do is first pre-fill the assistant with “let’s think step by step,” and then ask it again, and then all of a sudden you actually don’t necessarily always get the right answer, but it is now actually thinking step by step, and it’s getting closer. So now, yeah. By the way, the discovery of “let’s think step by step” seems like very obvious, but it was kind of a recent discovery. It was wasn’t it post ChatGPT becoming really publicly available, publicly known that people figured out oh, literally just ask it to think.

【译】后训练(post-training)的开始了,这一步真的非常令人兴奋。我们手里有了一个助手模型,而这基本上就是 GPT-3 的水准。我省略了很多东西,但大体脉络是:我们拿着一个自动补全引擎,用更多数据把它「骗」成了助手,它现在发展出了这种助手人格,这真的很酷、很有意思。但接下来又冒出一个新的问题:模型虽然能产出有意思的东西,却会犯一些明显的错误,对吧?如果你问它数学题——不知道你还记不记得让它算过数学——它会显得非常自信,不加思考就把答案直接丢给你。举个例子:398×923+2901 等于多少?它算出来的乘法结果是 37,000,这是错的,正确答案是 370,000。所以这个模型完全算错了,对吧?但它毕竟是个助手,格式生成得没错,也知道该在哪里停下。于是新的问题就是:模型只是把脑子里冒出来的东西一股脑全倒出来,它并没有真的在思考。而如果换我来问你这道题,你会先想一想,一步一步地思考,把它真正解出来——是在动脑子。研究人员发现的一个思路是:也许你只需要先给助手预填一句「让我们一步一步思考」(let’s think step by step),然后再让它作答,忽然之间——虽然不一定总能得到正确答案——但它现在是真的在一步一步思考了,而且离正确答案越来越近。所以就……对了,顺便说一句,「让我们一步一步思考」这个发现现在看上去理所当然,但它其实算是挺晚近的发现。是不是在 ChatGPT 真正公开可用、广为人知之后,人们才恍然大悟:哦,原来直接让它思考就行了?

[2640s - 2760s]

Step by step, and you get better answers. Because I remember when I was making videos in the early days of model reviews, I would manually type, think step by step to get better answers from the models. Yeah, this it’s unclear what was happening at the labs at this time, but in public, this is definitely true. And there are multiple ways to do it. There’s one to like first force the assistant to start with this text, which is what we’re doing here. There’s also one where you prompt it to think step by step, which also yields better results. And yes, this is relatively recent. Again, I think probably the labs had figured out pretty quickly, but I agree publicly this was this was relatively new. And now all of a sudden, we’re getting quite close. Okay, now I’m going to transition. And the first public publicly available model to use this new thinking was o1. Is that right? Right. It was o1. Yes. By OpenAI. Yes. So you know, we were living in this non-thinking paradigm, and part of why the non-thinking was the case is because on the internet, you get a lot of the outcomes of thinking. Right. You see blog posts which had a lot of thinking, but you know, by humans to build the blog post, but you don’t see the thinking with code. Right. You see the final finished code, but you don’t see the thinking. All the thinking that came into writing these these pieces of code, and so the internet generally lacks thinking data. And and not only that, even if it had thinking data, this is the model learning to think, but not for itself, kind of imitating what it thinks thinking should be. Now, in the limit, if you had enough of this data and a large enough model, it’s very possible it would, you know, grasp fundamentally the patterns of thinking, and you could tell it to think like Einstein, and it would think for itself. But practically, what we found is that we can actually train the model to think for itself, to actually try out problems and learn from trial and error, which is called reinforcement learning, and this is what led.

【译】一步一步地想,就能得到更好的答案。因为我记得早年做模型评测视频的时候,我会手动敲下「think step by step」,好从模型那里拿到更好的回答。是的。这个时期各家实验室内部在干什么,我们并不清楚,但在公开层面,事情确实是这样。而且做法有好几种:一种是先强制让助手以这段文字开头,也就是我们这里在做的;另一种是直接在提示词里让它一步一步思考,这同样能带来更好的结果。是的,这确实是相对晚近的事。再说一次,我猜各家实验室可能早就搞明白了,但我同意,在公开层面这还是很新的东西。而这样一来,答案忽然就相当接近了。好,现在我要转个话题了。第一个公开使用这种新式思考的模型是 o1,对吗?对,就是 o1。是的,OpenAI 出的。对。要知道,此前我们一直生活在不思考的范式里,而之所以如此,部分原因在于:互联网上到处都是思考的「成果」。对。你看到的博客文章背后有大量思考——不过是人类为了写出这篇博文而付出的思考——但你看不到伴随代码而来的思考。对。你看到的是最终完工的代码,却看不到思考过程,看不到写这些代码时所投入的全部思考。所以互联网总体上是缺乏思考数据的。而且不止如此,就算互联网上有思考数据,那也是模型在学习思考,却不是为自己而思考,只是在模仿它心目中思考应该有的样子。当然,从极限上讲,如果这类数据足够多、模型足够大,它完全有可能从根本上把握思考的模式,你可以让它像爱因斯坦那样思考,它就能自己思考了。但实践中的发现是:我们其实可以训练模型为自己而思考,让它真正去尝试解题、从试错中学习——这就叫强化学习(reinforcement learning),而正是这一步引出了

[2760s - 2880s]

To o1, yeah. So o1 was the first public model that that had thinking, and it was this. I remember when it came out; it was just incredible. It was doing really well on things like ARC. It could code, you know, much better. It was just a a whole new way of being able to use these language models. It was hallucinating less, and we didn’t really know how it worked publicly until DeepSeek came out with R1, the famous DeepSeek R1 paper, which showed how you can do this with reinforcement learning. So I’m going to gloss over quickly around the the next stage, which is using reinforcement learning to train the model to think for itself and and to through trial and error update itself. So how DeepSeek was able to train this model to think for itself is called GRPO is the method they use group relative policy optimization. But what this really means is okay. So we have this math problem, right? Let’s have the model try to answer this math problem a hundred times. Actually, let me take a step back. Maybe the naive approach is let’s have the model try and answer a problem a hundred times, and let’s tell it to think step by step. And every time it gets it right, let’s add this to the training data and train on this. So reinforce the times when it thought well, and we’ll just throw out the bad examples. So this is a naive approach, which actually does work. It’s called rejection sampling. There are a few problems with this. One is that you don’t learn from negative examples, and then two, there’s a lot of noise in every rollout, in every response, right? There’s of’s, does, random tokens that don’t actually matter. They’re kind of noisy, but you’re also upvoting them. Again, you’re training on them, and GRPO is a way of learning from negative examples as well, and also with scale canceling out a lot of the noise that you have. This stable training of the model trying out problems for itself and learning. So the way it works, the model answers a problem a hundred times, and then

【译】o1。对。所以 o1 是第一个具备思考能力的公开模型,而它用的就是这个。我还记得它刚出来的时候,简直不可思议。它在 ARC 这类东西上表现得非常好,写代码也强了很多,这完全是一种使用语言模型的全新方式,幻觉也更少了。而在 DeepSeek 发布 R1 之前——也就是那篇著名的 DeepSeek R1 论文——外界其实并不真正清楚它是怎么工作的,那篇论文展示了如何用强化学习做到这一点。下一个阶段我会快速带过:用强化学习训练模型为自己思考,通过试错来更新自己。DeepSeek 训练模型自主思考所用的方法叫 GRPO,也就是组相对策略优化(group relative policy optimization)。它到底是什么意思呢?这么说吧:我们手上有一道数学题,对吧?让模型试着解这道题一百次。其实,让我先退一步说。也许最朴素的做法是:让模型把一道题尝试作答一百次,告诉它要一步一步思考,每当它答对,就把这条加进训练数据拿去训练——也就是强化它思考得好的那些回合,把坏样例直接扔掉。这是种朴素做法,而且确实管用,它叫拒绝采样(rejection sampling)。但这样有几个问题:第一,你从负面样例里学不到东西;第二,每一次 rollout(一次生成回答)、每一条回复里都有大量噪声,对吧?里面混着 of、does 之类实际上无关紧要的随机 token,它们本来是噪声,可你也在给它们「点赞」——你在拿它们做训练。而 GRPO 是一种同样能从负面样例中学习的方法,并且能靠规模效应把你手上的大量噪声抵消掉,实现稳定的训练:模型自己尝试解题、自己学习。它的运作方式是:模型把一道题作答一百次,然后

[2880s - 3000s]

You score each problem based on how well it did. One, how well it followed, you know, your desired formatting for thinking, and then two, whether it got to the right answer. And then you you take the average score of all of these groups, and then you subtract its score from the average, and this is called the advantage. This is basically how much this solution was better than the average solution the model is producing. And Jeremy, just to just to clarify, this is all within the category of post training. This is not happening within kind of what people think of chain of thought or kind of the thinking aspect of the model. This is separate. Yeah, this is this is training the model to learn to think on its own from from its own synthetic data. Yeah, got it. And so with this now, each each time you answer a problem, you know its relative score. How well was it relative to if it you know answered a hundred times? And then you use this number to update the model to be more or less like that response over time. So for every token in a in a role in an answer that was really good, so we have a really good answer, right? It was like one of one. It was it was great answer. We make every token in that response more likely based on how good it was relative. And same thing if it’s a bad example, we make every token in that rollout in that in that answer a bit less likely. And so we are just tuning the dials to shift the model to make it more likely to answer correctly and less likely to answer incorrectly. But if you think about this on a high level, ultimately, right? This is just changing the data that we are using to train these models to be more correct. And this actually has an added benefit. So this is called on policy training. Policy is the model, and this is the model generating its own training data on policy and reinforcing and this.

【译】你根据每次作答的表现来打分:一,它多大程度上遵循了你期望的思考格式;二,它有没有得出正确答案。然后你取这一组所有回答的平均分,再用平均分减去它的得分——这个量就叫 advantage(组内相对分差),它衡量的基本就是:这条解答比模型正在产出的平均解答好多少。Jeremy,我想确认一下:这些都属于后训练的范畴,对吧?它并不发生在大家通常以为的思维链(chain of thought)、也就是模型思考的那个部分里,这是两码事。对,这是在训练模型从自己生成的合成数据里学会自主思考。好,明白了。这样一来,模型每答一次题,你都知道它的相对得分——相对于它答一百次的整体水平,这次表现怎么样。然后你就用这个数字去更新模型,让它随着时间推移变得更像、或者更不像那条回答。对于一条特别好的回答里的每一个 token——我们有一条非常好的回答,对吧?相当于一分制里的满分,是条绝佳的回答——我们会依据它的相对好坏,让这条回答里的每个 token 都变得更可能出现。坏样例同理,我们让那个 rollout、那条回答里的每个 token 稍微不那么可能出现。所以我们其实就是在拧旋钮,把模型往「更可能答对、更不可能答错」的方向调。但你从高处想想,归根结底,这不过是改变了我们用来训练这些模型、让它们变得更正确的数据。而这里还有个额外的好处——这就叫 on-policy 训练:policy(策略)指的就是模型,这是模型在 on-policy 地生成自己的训练数据、自我强化,然后——

[3000s - 3120s]

This is, in many ways, better than taking someone else’s thinking and updating on someone else’s thinking because the model generated this this answer itself with its own circuits. And so, if you want to make this answer more likely, well, you know the model is already capable of answering like this. You can just twist the knobs just a little bit to make it just a little bit more likely to output this token, where next word, versus if it’s someone else’s thinking, you are making all of that other person’s thinking more likely, but you don’t know what words you’re making less likely by doing this. You might start to forget or degrade in other capabilities in a way that with reinforcement learning you don’t as much because the updates are generally nicer when you are they are you are being less destructive to the knobs when it is your own thinking because you generated it. You just need to tweak it slightly. So this is a this was a you know breakthrough, and it allowed the models fundamentally to learn from trial and error and to teach itself new things. And now we are in this regime where if you can build an environment such that you can have the the model answer many times and you can verify whether the answers are correct, then you can build this regime and the model will start to hill climb. It will start to improve on this task with limited degradation or degradation to the other things that the model knows. Of course, there’s still degradation. Yeah. Well, Jeremy, I wanted to ask you what why are these pre-training and post-training phases separate? Because it sounds like reinforcement learning is so powerful. Why can’t that just be done from the beginning? And and like maybe you can just kind of from a very high level explain why there needs to be two phases. Right. So there are papers that try and merge the two, and I think it is totally possible that they they will be merged.

【译】——这在很多方面都比拿别人的思考、在别人的思考上做更新来得好,因为这条回答是模型用自己的回路亲自生成的。既然你想让这样的回答更常出现,那说明模型本来就有能力答成这样,你只需把旋钮轻轻拧一点点,让它输出这个 token、这个下一个词的概率稍微提高就行。可如果那是别人的思考,你就是在让那个人的全部思考变得更可能出现,而你并不知道这样做会让哪些词变得不那么可能。模型可能会开始遗忘,或在其他能力上出现退化;而用强化学习时这种损伤就小得多,因为当这是它自己的思考时,更新通常更温和——内容是它自己生成的,对旋钮的破坏性更小,你只需要轻微调整。所以说这是一项突破,它让模型从根本上能够从试错中学习、自学新东西。现在我们进入这样一个范式:只要你能搭建出一个环境,让模型大量作答、并且你能验证答案是否正确,你就能建立这种机制,模型就会开始爬山式提升——在这个任务上不断变强,而对它已掌握的其他东西,退化很有限,或者说有所退化。当然,退化仍然存在。是啊。好,Jeremy,我想问你:为什么预训练和后训练这两个阶段要分开?听起来强化学习这么强大,为什么不从一开始就这么干?也许你可以从很高的层面讲讲为什么必须分成两个阶段。好。确实有一些论文在尝试把两者合并,而且我认为两者完全有可能最终合并。

[3120s - 3240s]

And I’m sure many people are working on this, but I think maybe just on a high level fundamentally, when you’re pre-training, you’re taking off policy traces, as in you are taking the world’s data, right, and you are building a next token, a next word predictor from the world’s data. Once you give the model an ego, a personality, now if you give it data, it will start to imitate and become that thing. And so you can’t, if you were to then go back to pre-training data, let’s say, oh, I have this really great code corpus, set of code, and I want to train the model after it’s already been assistant post-trained. What will happen is the model will start to adopt the style of the data that it’s training on, and so it will start to lose the ability to be an assistant. It will start to respond in code, maybe, and then it will also take it for granted. So once you have to be very careful that you are making sure that once you give it an ego, you give it the assistant model. You really can’t, at least you know publicly, there’s no. It is difficult to then train it on data that it did not produce. So yeah, if you were to train it on a code corpus, it would start to then talk like code. It would start to take that code for granted. But there are a lot of interesting there are a lot of interesting experiments going on to yeah to to build and reinforcement learning to all parts of the stack. Very cool. Finally, I’ll just end with you know I think for for a long time, first of all, we’re in a very interesting moment, which is language models. You know, to my knowledge, haven’t come up with you know super important novel discoveries that have been world changing at this moment, but they are now starting to crack unsolved human math problems, for example. And one of the main criticisms of language models as well, if they’re just next word predictions and they’ve been trained on a distribution, and by definition.

【译】我也确信很多人正在做这件事。但我认为,从根本上、从高层来说:预训练的时候,你采用的是 off-policy 的轨迹,也就是说你在用全世界的、人类的数据,用这个世界的数据构建一个预测下一个 token、下一个词的预测器。可你一旦给了模型一个自我(ego)、一种人格,这时再给它数据,它就会开始模仿,开始变成数据里那个东西。所以你没法……如果你回过头去用预训练数据——比如说:「我这儿有一份特别棒的代码语料、一批代码」,想在模型已经完成后训练、当了助手之后再去训练它——会发生什么?模型会开始采纳它所训练的那批数据的风格,于是开始丧失当助手的能力,可能会开始用代码来回应你,而且还会把这一切当成理所当然。所以你必须非常小心,确保一旦给了它自我、把它变成助手模型之后……你真的没法——至少就公开所知,还不存在这样的办法——再拿不是它自己产出的数据去训练它,这很难。是的,如果你拿代码语料去训练它,它就会开始满口代码腔,会把那些代码当成理所当然。不过现在也有很多很有意思的实验,在尝试把强化学习用到整个技术栈的各个部分。非常酷。最后,我想以此收尾。我认为,首先,在很长一个时期里、直到此刻,我们正处在一个非常有趣的时刻:就我所知,语言模型至今还没有做出那种改变世界的、超级重要的全新发现,但比如说,它们已经开始攻克人类未解决的数学难题了。而对语言模型最主要的批评之一就是:它们不过是在预测下一个词,是在一个训练分布上训练出来的,那么按照定义——

[3240s - 3360s]

There’s nothing new in this distribution because we’ve taken things that we’ve you know already know right to train these models. You know, are they really going to be fundamentally capable of escaping the model that they’ve been trained on and developing new new knowledge? I think you know the answer to this is yes because ultimately reasoning is the process of making these unlikely, true, and interesting things more likely. And so, if you think you know Einstein when he’s coming up with general relativity, at first the idea of general relativity wasn’t a likely thing for him to just come up with because he hadn’t thought through and built up built all the assumptions and new abstractions to be able to deduce general relativity. But it was over time through reasoning that he was able to mold the you know his thinking and ultimately the data itself that he’s been trained on, such that he was able to get there. And models, I think, are the same way, right? As long as we continue to train them to reason really well over long horizons, I don’t think there’s a reason why they shouldn’t be able to develop new knowledge and escape the distribution because fundamentally, when they are reasoning for themselves and we are not teaching them to reason for themselves, what this means is they are slowly building new abstractions on the fly until they’re able to deduce new things. So you know, time will tell. But my money is on on the fact that that models will continue to get much better and they will end up discovering new things. Well, Jeremy, I want to just say thank you so much for sharing all this. I I learned a lot. It it really shows that it you know it seems a little bit intimidating, but if you start from the fundamentals and you build off of that, you can really learn it. You can apply it. You can experiment with this stuff yourself. And if you want to make

【译】——这个分布里没有任何新东西,因为我们拿来训练这些模型的,都是我们已经知道的东西。那么,它们真的能从根本上逃出自己被训练的那个分布、发展出新的知识吗?我认为答案是肯定的,因为说到底,推理就是把那些原本不太可能、却又真实而有趣的事物变得更可能的过程。你想想爱因斯坦提出广义相对论的时候:一开始,广义相对论这个想法对他来说并不是一个随随便便就能冒出来的高概率念头,因为他还没有把所有前提假设和新的抽象一层层想透、搭好,从而能够推导出广义相对论。而正是随着时间推移、通过推理,他才得以重塑自己的思考方式,乃至重塑他本身被「训练」所依赖的那份数据,最终抵达了那里。我认为模型也是同样的道理,对吧?只要我们持续训练它们在很长的跨度上进行真正高质量的推理,我就看不出它们有什么理由不能发展出新知识、逃出训练分布——因为从根本上讲,当它们在为自己推理、而不是我们教它们如何为自己推理时,这意味着它们正在现场一点点搭建新的抽象,直到能够推导出新的东西。所以,时间会证明一切。但我赌的是:模型会继续大幅变好,最终做出新的发现。好,Jeremy,我只想说,非常感谢你分享这一切,我真的学到了很多。这也真的说明:这东西看上去有点吓人,但只要你从最基础的原理出发、在上面一层层往上搭,你是真的能学会的。你能把它用起来,能自己动手做这些实验。而如果你想把这

[3360s - 3375s]

This into a career, you can absolutely do that. It does not require a PhD. Certainly, a lot of work, a lot of hard work, putting your head down, learning it. But it is very, very possible. So, I just want to say thank you again. No, thank you. Thank you.

【译】件事变成一份职业,你完全做得到。它不需要博士学位。当然,要下很多功夫、很多苦功,埋头进去学。但这是完全、完全可能的。所以,我只想再次说声谢谢。不,谢谢你。谢谢。