-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathquiz.json
More file actions
78 lines (78 loc) · 3.31 KB
/
Copy pathquiz.json
File metadata and controls
78 lines (78 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
"lesson": "61-cross-attention-fusion",
"title": "顶点课 61 —— Cross-Attention 融合",
"questions": [
{
"stage": "pre",
"question": "在视觉-语言建模里,early fusion 和 late fusion 在运作上有什么区别?",
"options": [
"early fusion 在挂钟时间上先跑",
"early fusion 把图像和文本 token 拼成一个序列;late fusion 让它们分开,在每个 block 通过 cross-attention 桥接",
"late fusion 占更多内存",
"early fusion 是不允许的"
],
"correct": 1,
"explanation": "Chameleon 和 Emu3 是 early-fusion;Flamingo 和 BLIP-2 是 late-fusion。这个架构选择会改变 mask 的形状和 KV caching。"
},
{
"stage": "pre",
"question": "在一个同时有 self-attention 和 cross-attention 的 decoder block 里,哪个用 causal mask?",
"options": [
"两个都用",
"只有 self-attention 用;图像是完全可见的,cross-attention 没有时序顺序",
"只有 cross-attention 用",
"两个都不用"
],
"correct": 1,
"explanation": "文本生成是自回归的,所以文本 self-attention 是 causal 的。图像 token 在任何文本被解码之前就全部可见。"
},
{
"stage": "check",
"question": "为什么 cross-attention 的 KV cache 每张图只构建一次?",
"options": [
"PyTorch 要求必须缓存",
"图像的 key 和 value 在文本解码过程中不会变,所以把 memory 投影一次、在所有解码步里复用这个 K 和 V,就是整个推理加速的关键",
"缓存能省磁盘空间",
"它能避免用 GPU"
],
"correct": 1,
"explanation": "视觉编码器只跑一次,它的 KV projection 只算一次,每个文本 token 都白嫖这份缓存。"
},
{
"stage": "check",
"question": "文本长度 Nt=10、图像长度 Nv=197、hidden=256 时,cross-attention 的输出形状是什么?",
"options": [
"(B, 197, 256)",
"(B, 10, 256)",
"(B, 10, 197)",
"(B, 207, 256)"
],
"correct": 1,
"explanation": "cross-attention 的输出形状跟着 query 流走,所以无论 key 多长,输出都是 (B, Nt, hidden)。"
},
{
"stage": "check",
"question": "为什么 cross-attention 上不加 mask?",
"options": [
"mask 太费算力",
"图像在文本生成开始前就完全可见;每个文本位置都可以 attend 到每个 patch",
"PyTorch 不支持 cross mask",
"mask 总会导致 NaN"
],
"correct": 1,
"explanation": "图像 patch 没有时序顺序,也没有要防的信息泄露,所以 cross-attention 看得到整张图。"
},
{
"stage": "post",
"question": "想恢复 Flamingo 风格的训练稳定性,你会加哪个扩展?",
"options": [
"去掉 self-attention 层",
"在 cross-attention 残差上插一个学出来的 tanh 门,让模型能从纯文本行为起步、逐渐长进图像流",
"去掉 FFN",
"只用一个 attention 头"
],
"correct": 1,
"explanation": "Flamingo 的 tanh 门从零起步,初始化时恢复纯文本行为,给模型一个平滑过渡到 cross-attention 的坡道。"
}
]
}