Attention 与 Transformer 阅读、代码与复盘工作纸
Attention 与 Transformer 阅读、代码与复盘工作纸
一句话目标
用第三周把 Attention 和 Transformer 学成一个闭环:能解释 Q/K/V、attention score、softmax weight、weighted sum、self-attention、positional encoding,并能把 word2vec、ResNet、Attention、Transformer 讲成一条主线。
Day 15:attention 直觉
1. Attention 论文想解决什么问题?
我的回答:
2. 固定长度 context vector 为什么可能不够?
我的回答:
3. alignment 可以怎么理解?
我的回答:
4. Attention 和“按相关性取信息”的关系
我的解释:
Day 16:Q/K/V 与 attention score
1. Q、K、V 分别是什么?
Q:
K:
V:
2. 为什么要计算 QK^T?
我的回答:
3. scaled dot-product attention 的输入输出 shape
| 对象 | shape | 含义 |
|---|---|---|
输入 x | ||
Q | ||
K | ||
V | ||
| attention score | ||
| softmax weight | ||
| weighted sum/output |
4. 今天仍然不懂的地方
1. 2. 3.
Day 17:手算 softmax weight
1. 构造一个 2-3 个 token 的 toy example
token:
Q:
K:
V:
2. 手算 attention score
3. softmax 后的 weight
4. weighted sum 的含义
5. 为什么 attention weight 不能自动当作因果解释?
Day 18:Transformer 结构
1. Transformer 想解决什么问题?
2. 为什么不用 RNN/CNN 也能建模序列?
3. self-attention 和 encoder-decoder attention 的区别
4. positional encoding 为什么需要?
5. Transformer 的优势和代价
优势:
代价:
Day 19:两篇论文笔记
把下面内容整理进 paper_notes/03_attention.md 和 paper_notes/04_transformer.md。
Attention 一页笔记
一句话贡献:
研究问题:
核心方法:
最小代码对应:
没覆盖的内容:
我还不懂:
1. 2. 3.
Transformer 一页笔记
一句话贡献:
研究问题:
核心方法:
最小代码对应:
没覆盖的内容:
我还不懂:
1. 2. 3.
Day 20:第 01 单元主线图
请把四篇论文串成一条线:
word2vec -> ResNet -> Attention -> Transformer
1. word2vec 解决什么?
2. ResNet 解决什么?
3. Attention 解决什么?
4. Transformer 解决什么?
5. 这四篇论文共同说明了什么?
Day 21:5 分钟单元汇报
1. 40 秒:第一单元主线
2. 60 秒:word2vec 和表示学习
3. 60 秒:ResNet 和优化困难
4. 90 秒:Attention/Transformer 和序列建模
5. 50 秒:我的代码证据和理解边界
6. 5 分钟完整稿
第三周自测与复盘
自测题 10-13
10. Q、K、V 分别是什么?
我的回答:
修正后回答:
11. attention weight 能不能直接当作因果解释?
我的回答:
修正后回答:
12. Transformer 为什么需要 positional encoding?
我的回答:
修正后回答:
13. Transformer 相比 RNN 的优势是什么?
我的回答:
修正后回答:
第三周证据汇总
| 证据 | 位置 | 是否完成 | 还缺什么 |
|---|---|---|---|
| Day15-Day21 学习记录 | daily_logs/Day15_学习记录.md 到 Day21_学习记录.md | ||
| Attention 个人笔记 | paper_notes/03_attention.md | ||
| Transformer 个人笔记 | paper_notes/04_transformer.md | ||
| Q/K/V shape 记录 | daily_logs/Day16_学习记录.md 或本工作纸 | ||
| attention 手算表 | 本工作纸 / daily_logs/Day17_学习记录.md | ||
| 第 01 单元 5 分钟稿 | 本工作纸 / daily_logs/Day21_学习记录.md | ||
| 第三周复盘 | daily_logs/第三周复盘.md |
进入 GPT/BERT 前必须讲清的 3 件事
1. 2. 3.