HackerTube English?
学习信号与模型行为 →

预测下一个词,离回答一个人还有多远?

把三个问题分开:输入如何变成表示,训练如何改变网络,一个善于续写的模型又如何成为助手。否则很容易拿其中一层解释全部行为。

本文的问题 · 7
  1. 几何向量走进词嵌入空间
  2. 从逐层激活到因果注意力
  3. 先看网络怎样计算,再看它怎样学
  4. Dropout 的共享子网络机制落到 GPT 训练
  5. Dropout 可理解为训练许多共享参数的子网络
  6. 从补全序列,分别走向实现与使用
  7. 预测下一个词的预训练,还不是教模型怎样回答用户

几何向量走进词嵌入空间

向量视频解释向量作为几何量与数值列表的不同视角;Transformer 讲解展示训练后的词嵌入也是向量,其方向能呈现语义关系。连接起来能帮助观众把“语义空间”理解成具体的向量表示,而不是隐喻。

对照原文与时间戳 · 2
the ability to translate back and forth between them
Vectors | Chapter 1, Essence of linear algebra · ▶ 8:45–8:49
directions in the space have a kind of semantic meaning
Transformers, the tech behind LLMs | Deep Learning Chapter 5 · ▶ 14:28–14:34

通用向量的几何性质不会自动赋予语义;语义结构来自模型训练,视频展示的是特定嵌入例子。

从逐层激活到因果注意力

基础神经网络视频用逐层激活解释输入如何影响输出;GPT 从头构建视频进一步展示因果自注意力如何聚合此前 token,并逐步组成 Transformer。连接可帮助观众辨认现代语言模型保留了神经网络的层间计算框架,同时增加了序列上下文机制。

对照原文与时间戳 · 2
the heart of the network as an information processing mechanism
But what is a neural network? | Deep learning chapter 1 · ▶ 4:39–4:43
you can do weighted aggregations of your past Elements
Let's build GPT: from scratch, in code, spelled out. · ▶ 57:59–58:14

GPT 视频讲的是 Transformer 语言模型,不能把基础手写数字网络的结构直接等同于 GPT;该连接只指逐层计算这一抽象层次。

注意力图告诉你「看谁」,却没告诉你「抄什么」

设想读到“fluffy blue creature”。为了让 creature 的表示带上颜色和质地,模型需要先找相关位置,再从这些位置带回内容。查询与键的点积参与第一步;第二步按得到的权重混合各位置的值向量。即使两张注意力图完全一样,只要值向量不同,写回 creature 的信息也会不同。这里的形容词是帮助拆开两步的教学例子,并非每个头都有固定的语法职责。

原文与时间戳 · 2
To measure how well each key matches each query, you compute a dot product between each possible key-query pair.
Attention in transformers, step-by-step | Deep Learning Chapter 6 · ▶ 8:27–8:34
For each column in this diagram, you multiply each of the value vectors by the corresponding weight in that column.
Attention in transformers, step-by-step | Deep Learning Chapter 6 · ▶ 14:42–14:49

先看网络怎样计算,再看它怎样学

3Blue1Brown 解释前馈网络如何逐层传递激活并把输入映射到输出;micrograd 则演示前向计算、损失、反向梯度和参数更新。前者回答网络在算什么,后者补上如何依据误差改变参数。

对照原文与时间戳 · 2
the entire network is just a function
But what is a neural network? | Deep learning chapter 1 · ▶ 15:39–15:43
efficiently evaluate the gradient of some kind of a loss function
The spelled-out intro to neural networks and backpropagation: building micrograd · ▶ 0:55–1:07

两者是不同模型规模和讲解目的的教学材料;micrograd 用标量演示数学机制,不是前一视频数字分类网络的完整训练复现。

一张写着「2」的图,究竟要求哪个参数改变?

先只给网络看一张图。输出层把它当成别的数字,我们希望「2」的分数升高。但旋钮不在输出分数上,而在连接的权重上。同样拧大一点权重,如果连接另一端在这张图上几乎没亮,效果就很小。反向传播把「希望输出怎么变」折算成每个旋钮在此处能起多大作用。

原文与时间戳 · 1
We can't directly change those activations, we only have influence on the weights and biases.
Backpropagation, intuitively | Deep Learning Chapter 3 · ▶ 4:02–4:07

换下一张图,同一个旋钮可能收到相反的要求。视频里定义的地形是训练样本代价的平均值;梯度下降依据的是这片地形的局部斜率。于是可以分清三件事:标签给了目标,反向传播算出了敏感度,优化器才决定实际迈出哪一步。

原文与时间戳 · 1
So then what you do is consider the average cost over all of the tens of thousands of training examples at your disposal.
Gradient descent, how neural networks learn | Deep Learning Chapter 2 · ▶ 4:18–4:25

Dropout 的共享子网络机制落到 GPT 训练

Hinton 把 dropout 解释为许多共享权重的子网络;Karpathy 在 GPT 教程中每轮随机屏蔽节点,并在测试时启用完整网络,提供同一正则化机制的具体实现。

对照原文与时间戳 · 2
all of these architectures are sharing the same weights, which is regularizing them a lot.
Brains, Sex, and Machine Learning · ▶ 17:13–17:20
training an ensemble of sub networks and then at test time everything is fully enabled
Let's build GPT: from scratch, in code, spelled out. · ▶ 99:07–99:16

测试时启用完整非线性网络并不等于显式平均所有子网络;也不能把教程多项扩容带来的效果单独归因于 dropout。

Dropout 可理解为训练许多共享参数的子网络

这是一种训练解释;测试时单个网络的预测不必精确等于所有子网络预测的平均值。

对照原文与时间戳 · 2
all of these architectures are sharing the same weights, which is regularizing them a lot.
Brains, Sex, and Machine Learning · ▶ 17:13–17:20
training an ensemble of sub networks and then at test time everything is fully enabled
Let's build GPT: from scratch, in code, spelled out. · ▶ 99:07–99:16

从补全序列,分别走向实现与使用

两段都以补全序列或预测后续词解释语言模型的基本任务。可以以共同定义为起点,分别进入从头构建模型与通过代码使用模型的讲解。

对照原文与时间戳 · 2
give it the start of a sequence and it completes the sequence
Let's build GPT: from scratch, in code, spelled out. · ▶ 1:50–2:05
knows how to predict the next word
A Hackers' Guide to Language Models · ▶ 1:33–1:43

共享基础定义不意味着两份教程具有相同深度、架构或 API,也不等于已经理解模型全部行为。

预测下一个词的预训练,还不是教模型怎样回答用户

两端都区分续写与助手训练,没有断言所有助手必须用同一种后训练算法。

对照原文与时间戳 · 2
it takes the model from being a document completer to a question answerer
Let's build GPT: from scratch, in code, spelled out. · ▶ 114:09–114:19
we swap out the data set now and we train on these Q&A documents
[1hr Talk] Intro to Large Language Models · ▶ 16:26–16:38

读完再想一步

当回答变好时,证据指向表示、训练目标,还是后训练?