2Embed
wte[“i”] + wpe[3]
+
→ RMSNorm
wte[“i”] + wpe[3]
+
→ RMSNorm
3q, k, v
for the new token only
q
k
v
for the new token only
q
k
v
4Append to cache
BOS
l
a
i
kv
BOS
l
a
i
kv
5Attend
q · every cached k / 4
→ softmax → mix of v
no mask needed: the cache only holds the past
q · every cached k / 4
→ softmax → mix of v
no mask needed: the cache only holds the past
6MLP + residuals
then the next layer
3 layers, each with its own cache
then the next layer
3 layers, each with its own cache
7Sample
logits ÷ 0.5 → softmax
draw one → “a”
logits ÷ 0.5 → softmax
draw one → “a”
1BOSpos 0
GPT · 3 layers
t = 0
t = 0
l
KV cache after t = 0
BOS
BOS
lpos 1
GPT · 3 layers
t = 1
t = 1
a
KV cache after t = 1
BOS
l
BOS
l
apos 2
GPT · 3 layers
t = 2
t = 2
i
KV cache after t = 2
BOS
l
a
BOS
l
a
ipos 3
GPT · 3 layers
t = 3
t = 3
a
KV cache after t = 3
BOS
l
a
i
BOS
l
a
i
apos 4
GPT · 3 layers
t = 4
t = 4
BOSstop
KV cache after t = 4
BOS
l
a
i
a
BOS
l
a
i
a
One generation step · t = 3: the input is “i” at position 3
Generating a name, one character at a time · example run, temperature 0.5
Result: l · a · i · a → “laia”