forked from rohitg00/ai-engineering-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquiz.json
More file actions
78 lines (78 loc) · 3.32 KB
/
Copy pathquiz.json
File metadata and controls
78 lines (78 loc) · 3.32 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": "Cross-Attention Fusion",
"questions": [
{
"stage": "pre",
"question": "What is the operational difference between early fusion and late fusion in vision-language modeling?",
"options": [
"Early fusion runs first in wall-clock time",
"Early fusion concatenates image and text tokens into one sequence; late fusion keeps them separate and bridges via cross-attention at each block",
"Late fusion uses more memory",
"Early fusion is illegal"
],
"correct": 1,
"explanation": "Chameleon and Emu3 are early-fusion; Flamingo and BLIP-2 are late-fusion. The architectural choice changes mask shapes and KV caching."
},
{
"stage": "pre",
"question": "In a decoder block with both self-attention and cross-attention, which one uses a causal mask?",
"options": [
"Both",
"Self-attention only; the image is fully observed and cross-attention has no temporal order",
"Cross-attention only",
"Neither"
],
"correct": 1,
"explanation": "Text generation is autoregressive, so text self-attention is causal. Image tokens are all visible before any text is decoded."
},
{
"stage": "check",
"question": "Why is the cross-attention KV cache built once per image?",
"options": [
"PyTorch requires caching",
"Image keys and values do not change as text is decoded, so projecting memory once and reusing the K and V across all decode steps is the whole inference speedup",
"Caching saves disk space",
"It avoids using the GPU"
],
"correct": 1,
"explanation": "The vision encoder runs once. Its KV projection is computed once. Each text token reuses the cache for free."
},
{
"stage": "check",
"question": "What is the output shape of cross-attention when text length is Nt=10 and image length is Nv=197 with hidden=256?",
"options": [
"(B, 197, 256)",
"(B, 10, 256)",
"(B, 10, 197)",
"(B, 207, 256)"
],
"correct": 1,
"explanation": "Cross-attention output shape follows the query stream, so output is (B, Nt, hidden) regardless of key length."
},
{
"stage": "check",
"question": "Why is no mask used on cross-attention?",
"options": [
"Masks are too expensive",
"The image is fully observed before text generation begins; every text position may attend to every patch",
"PyTorch does not support cross masks",
"Masks always cause NaN"
],
"correct": 1,
"explanation": "There is no temporal order on image patches and no leakage to prevent, so cross-attention sees the whole image."
},
{
"stage": "post",
"question": "Which extension would you add to recover Flamingo-style stability during training?",
"options": [
"Drop the self-attention layer",
"Insert a learned tanh gate on the cross-attention residual so the model can start from text-only behavior and grow into the image stream",
"Remove the FFN",
"Use only one attention head"
],
"correct": 1,
"explanation": "Flamingo's tanh gate starts at zero, recovers text-only behavior at init, and gives the model a smooth ramp into cross-attention."
}
]
}