One Prompt, Four More Tokens

TransformersMedium+20 XP+20

One Prompt, Four More Tokens

A decoder-only model is given a prompt of 6 tokens and asked to write 4 more, ending with a 10-token sequence.

It generates the way the chapter describes: predict a token, append it, feed the whole sequence back in, predict the next. Nothing is carried over between passes — every pass rebuilds its attention grid from scratch.

Watch a single masked self-attention sublayer. In one pass over a sequence of LLL tokens it computes one score for each (query position, key position) pair the mask allows: every position may compare itself against itself and against every position before it, and blocked pairs are never computed at all.

Counting the pass that reads the prompt and every pass after it, up to and including the one that produces the tenth token — how many attention scores does that one sublayer compute in total?

Answer with the exact whole number.

the
cat
sat
down
the
✓
×
×
×
cat
✓
✓
×
×
sat
✓
✓
✓
×
down
✓
✓
✓
✓

A triangle of blocked cells. Each row may only look at itself and everything to its left.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.