Bigram ids and the embedding table
How (previous id, id) pairs become exact rows in one embedding table, the start-of-sequence row, and how many parameters the table costs.
Look one token back
After snapping, every position has H ids. For a bigram we pair each id with the id at the previous position, in the same head. Shift the ids right by one:
This is why the table has K + 1 possible previous ids but only K current ids.
From a pair to a row
All heads share one table. Head h owns a contiguous block of (K+1)·K rows, and inside it the pair picks the row:
row = (h·(K+1) + prev)·K + id = (1·5 + 2)·4 + 3 = 31
Total: 2 × 5 × 4 = 40 rows.
Quick check
K = 4. Head 1, previous id 2, current id 3. Which row?
Quick check
Why does each head need (K+1)·K rows rather than K·K?
How big is the table?
Each row has dh = w / H numbers and there are H·(K+1)·K rows, so the H cancels: the table costs (K+1)·K·w parameters no matter how many heads you use.
A plain token-bigram table at the same width would need vocab² · w = 8192² · 256 = 17,179,869,184 parameters - about 1,020× more. Notice the head count cancels out: more heads means more, narrower rows.
For Yumon cp1 that is 16,842,752 parameters, about 62% of the 27.2M model - yet each token only reads 16 rows of 16 numbers. Sparse lookups like this are cheap at inference time; the paper's pitch is exactly that trade: lots of parameters, little compute.
Quick check
K = 4, H = 2, w = 8. How many rows does the table have?