Take the sinusoidal positional encoding with , ordered as pairs, and . What is the vector for position ?
Sequence models and transformers, Positional encoding
Level L2 Elementary. Length Short. Nature Mat Mathematical.
What's being asked
Whether you can evaluate the encoding formula and see that different dimensions use different wavelengths.
Key idea
Pair has angular frequency , so the encoding is .
Steps
- With there are two pairs, and .
- For : . For : .
- At the angles are radians and radians.
- .
- The first pair changes quickly with position (wavelength ); the second changes slowly (wavelength about ). Together they act like digits of different speed.
Common mistakes
- Evaluating sine and cosine in degrees instead of radians.
- Using exponent instead of .
- Swapping the sine and cosine order.
How long your answer should be
3–4 lines.
Last checked on 4 December 2026.
Read this
Previous in Sequence models and transformers: A scalar RNN has with , and . For inputs and , what are , and the gradient ?
Next in Sequence models and transformers: A transformer layer-norm sees the feature vector for one token, with , for every feature and . What is the output? How does the statistics axis of layer norm differ from batch norm?