Positions: Order Is Invisible Until You Add It
The same words can mean different things in another order. Content comparisons need position information. Learned position rows provide it, but their fixed range and mixed representation create limitations.
#Section 15The Blind Spot
“Dog bites man” is not news. “Man bites dog” is. The two sentences contain exactly the same three words, and the only thing that separates a boring headline from a front page is order. Any model of language must care about order. Attention on its own does not.
We have not built attention yet (that is Part VI), so take one property on trust for now and we will prove it there. Attention works by letting each token look at every other token and blend in information from the ones it finds relevant. The amount each token takes from another depends only on what the two tokens are, never on where they are. If you shuffle the input tokens, attention shuffles its outputs in exactly the same way and changes nothing else. Mathematicians call this being permutation equivariant: rearrange the input, and the output is rearranged identically.
In other words, without help, attention sees a sentence as a bag of words. Every word knows which other words are present, but not where they are. So we must add position information somehow. The rest of this part, and the next two, are three different answers to “how?”.
#Section 16Two Kinds of “Where”
Before we stamp anything, we should decide what “position” means, because there are two quite different answers.
Absolute position is a fixed seat number counted from the start: “I am token number 4.” Relative position is a distance between two tokens: “the word I care about is three steps behind me.” In our sentence, it is at absolute position 4 and cat is at absolute position 1, so cat is three positions behind it.
A relative gap can describe the same local relationship anywhere in a document. Encoding it directly makes that relationship available without relying only on absolute-position patterns.
#Section 17Learned Absolute Positions
The simplest fix borrows the idea from Part II. We already have a table with one row per token. Make a second table, called the position embedding table , with one row per position instead. Look up the row for each position and add it, number by number, to the token's vector:
Add the token's embedding to its learned position row. Both tables receive training updates, but the position table has a fixed range.
Adding a position row changes the input for the same word at different locations. The figure illustrates the entry-by-entry addition.
Adding preserves model width; concatenating would enlarge downstream layers. The trade-off is that the same features now carry both content and position. RoPE instead changes the attention comparison.
GPT-2 used exactly this scheme with a table of 1,024 rows, as did BERT with 512, and Finch-19 copies GPT-2.
#Section 18What the Learned Table Ends Up Looking Like
Nobody told the model anything about how positions relate. Position 7 and position 8 got two independent random rows at the start, exactly as unrelated as position 7 and position 900. So what do the rows look like after training?
Compare position rows by cosine similarity. A bright diagonal is inevitable because each row matches itself; similarity near the diagonal reveals whether neighboring positions learned related representations.
That pattern was learned, not designed. The model discovered on its own that nearby positions should look alike, which is a crude form of relative position: if positions 7 and 8 have similar vectors, then "the token right before me" looks roughly the same wherever you are. The model is trying to reinvent relative position from absolute parts. That is a hint that we should give it relative position directly.
#Section 19Where Learned Positions Break
The learned table works. GPT-2 shipped with it and so did many models after. But it has two real weaknesses, and they are why newer models moved on.
The maximum-length wall
A learned position table has a hard final row. Extending it requires new rows and training, rather than merely evaluating the same rule at a later position.
There is a softer version of the same problem inside the limit. If most training documents are short, the rows for high positions are trained on far fewer examples than the rows for low positions. The model then behaves a little worse near the end of long inputs, even before the wall.
The same relationship, learned many times
The second weakness is the one Section 16 warned about. Put the pair the cat at positions 2 and 3, then put it again at positions 102 and 103. The gap is one step both times, so the relationship is the same. But rows 2, 3, 102 and 103 of are four independent vectors. Nothing in their numbers says "these two pairs are one step apart in the same way". The model has to learn the "one step back" relationship separately at every offset it could appear at, and it only generalizes to offsets it has seen enough.
#Section 20Three Answers, Three Injection Points
The next two parts cover three main position schemes, distinguished by where they inject position into the model.
Learned absolute positions (this part) add a trained table to the token vectors once, at the very bottom, before the first layer. Sinusoidal positions (Part IV) also add a vector at the bottom, but compute it from a fixed formula of sine and cosine waves instead of learning it, so there are no parameters and no table to run out of. RoPE (Part V) does something different in kind. It never touches the input at all. Instead, inside every attention layer, it rotates the vectors used for comparing tokens by an angle that depends on their positions, in such a way that the comparison only sees the distance between them.
| Learned | Sinusoidal | RoPE | |
|---|---|---|---|
| Where | added at the bottom | added at the bottom | inside every attention layer |
| Parameters | (524,288 for Finch-19) | none | none |
| Past training length | hard wall, no rows | computable, but untrained | computable, and can be stretched |
| Relative position | learned indirectly | implicit in the waves | exact, by construction |
| Used by | GPT-2, BERT | original 2017 Transformer | Llama, Mistral, Qwen, Gemma |
Sharp edges of positions
Left padding shifts positions. When you batch prompts of different lengths for generation, you often pad short prompts on the left so that all of them end at the same place. The first real word of a padded prompt then sits at position 3 or 4 instead of 0, and the model thinks the text started later than it did. Compute position ids from the attention mask (count only real tokens), never from the raw index.
Packed documents need a decision. To avoid wasting compute on padding, training often packs several short documents end to end into one long row. Should the second document’s positions restart at 0, or continue from where the first ended? Both work, but the attention mask must agree with your choice, so that tokens from one document cannot see the previous one.
No positions is not quite zero information. A surprising result: a model with the causal mask of Part VIII and no position scheme at all can still infer some order, because each token can see a different number of earlier tokens, and it can learn to count them. This is a curiosity worth knowing for interviews, not a replacement for real positions.