S14 Machine learning · Practice
Attention and transformers
Problems dealt one at a time, with new numbers every time. The kinds you miss come back more often, and you can keep going as long as you like.
0 solved
0 in a row
0 of 9 kinds solid
Check
A transformer has width 1024, 6 layers and a vocabulary of 100000 tokens (feedforward width 4d).
(a)
How many weights do its layers hold, in millions?
(b)
Including the token embedding, how many in all?
Check
Queries and keys have 64 independent entries with zero mean and unit variance.
(a)
What is the standard deviation of a query–key dot product?
(b)
And after dividing by ?
Check
A query attends to 10 keys; one scores 1 above the rest, which are equal.
(a)
What weight does the softmax give it?
(b)
How large a margin would give it a weight of 0.9?
Check
A model with 32 layers of width 2048 keeps its key–value cache at 2 bytes per number.
(a)
How much cache does each token need?
(b)
How much for a batch of 1 sequences of 32768 tokens?
Check
A transformer layer of width 1024 processes a context of 1024 positions.
(a)
About how many operations does one token cost in this layer?
(b)
At what context length does attention's share reach half?
Check
Attention over 8192 positions with 8 heads stores its score matrices in 4-byte numbers.
(a)
How much memory would one layer's scores take?
Check
Layer weights: d = 768, L = 12?
Check
KV cache per token: L = 32, d = 4096, 2 bytes?
Check
Softmax weight: 20 keys, margin 2?
A kind of problem counts as solid once you've got it right on the first try twice in a row. Back to the lesson · Practice every topic in S14