At an intuitive level, each token can look at earlier tokens when the model picks the next one. A pronoun can check the noun it refers to; a signal name can check its declaration.
Each such look is one pairwise comparison. The total number of comparisons is what makes long inputs costly.
Token position | Earlier tokens it may use | Looks, self included |
|---|---|---|
1st | Itself | 1 |
2nd | 1st and itself | 2 |
3rd | 1st, 2nd and itself | 3 |
nth | All n tokens so far | n |
Adding 1 + 2 + ... + n gives n(n + 1) / 2 comparisons. That closed form is exact for the basic causal form of attention.
causal pairs for n tokens, self included: n(n + 1) / 2
n = 8: 8 x 9 / 2 = 72 / 2 = 36
n = 1024: 1024 x 1025 / 2 = 1049600 / 2 = 524800
n = 2048: 2048 x 2049 / 2 = 4196352 / 2 = 2098176
double the length: 2098176 / 524800 = 3.998, just under 4Doubling the input roughly quadruples the basic attention work. Longer prompts therefore cost more compute and more waiting, with exact figures varying by model and service.
Efficient attention variants exist that scale better than the basic form. They change the constant factors and sometimes the scaling, not the advice to keep inputs lean.
36 pairs. 8 times 9 divided by 2 is 72 divided by 2.
By just under 4. 2098176 divided by 524800 is 3.998.