NumPy allowed · plain Python earns 10 bonus points
Q · Kᵀ / √d scores normalized with softmax
Implement the original Transformer's sinusoidal positional encoding formula, the fixed (non-learned) position representation from 'Attention Is All You Need.'
Implement sinusoidal_pe(position, dim_index, d_model). Compute angle = position / (10000 ** (2*(dim_index//2)/d_model)). Return sin(angle) if dim_index is even, else cos(angle).
sinusoidal_pe(position: int, dim_index: int, d_model: int) -> float