Learned Absolute Position Vectors
A learned table adds one trainable model-width vector to each supported index. Calculate repeated-token examples, count parameters, and audit maximum length, padding, index origins, shifts, swaps, and zero-position ablations.
A learned absolute-position method stores one trainable vector for each supported position. Before the first Transformer block, the model combines the token vector and the position vector for that row.
If token ID has embedding and position has vector , then the initial representation is commonly
Both vectors must have width so addition preserves the layer interface.
The Same Token Can Enter Differently
Suppose the token blue has embedding
and appears at positions 0 and 2. Let
The two input records are
The token lookup is identical, but the records supplied to the projections are not. Training can adjust and through the same loss that adjusts the token embeddings and the rest of the model.
Parameter Shape and Index Range
For a table supporting positions through ,
It contributes trainable entries. A batch of position IDs with shape indexes the table and returns position vectors with shape .
The table has no row at index . Extending the context therefore requires a declared policy, such as enlarging and training the table or using a different method. Silently wrapping indices would make distant positions share rows and would change the model's position convention.
Position IDs Must Match the Records
For an unpadded three-token sequence, position IDs may be
Padding makes the convention more visible. Consider two batch rows:
[PAD, PAD, A, B]
[C, D, E, F]
Possible policies include assigning the real tokens in the first row IDs or retaining their physical columns . Either can be implemented, but training, evaluation, masks, and cached decoding must agree. Padding tokens must also be excluded by the padding mask; a convenient position ID does not replace visibility masking.
Controlled Changes Reveal the Role
Useful ablations include:
- set every to zero while keeping token embeddings and all other parameters fixed;
- swap two position rows while leaving the token sequence unchanged;
- use the same position row at every index;
- shift every valid position ID by one, if the table range permits it.
These interventions answer different questions. Zeroing removes the explicit absolute vectors. Swapping corrupts selected index associations. A global shift tests sensitivity to the index origin. None isolates position information that may also arise from a causal mask or the data.
Q1. Count learned position entries
A learned absolute-position table supports positions with . How many trainable scalar entries does the table contain?
Compute it first, then check your number.
Hint
Solution
Learned Does Not Mean Arbitrary
Learned rows do not start with a guaranteed notion of distance or direction. Their useful structure must arise through training. Conversely, a fixed formula that can calculate a vector for a new index does not guarantee that a model trained only on shorter sequences will use that vector successfully. Parameter availability and length generalization are separate questions.
Reference
- Ashish Vaswani et al., Attention Is All You Need, 2017. The original Transformer used sinusoidal encodings and reported similar results for a learned positional alternative in its stated translation experiments.