Back to Tools

Positional Encoding

Visualizing the sinusoidal waves that give Transformers a sense of order.

Mathematical Formula

PE(pos,2i)=sin(pos/100002i/dmodel)PE_{(pos, 2i)} = \sin(pos / 10000^{2i/d_{model}})PE(pos,2i+1)=cos(pos/100002i/dmodel)PE_{(pos, 2i+1)} = \cos(pos / 10000^{2i/d_{model}})

The wavelength increases geometrically from 2π2\pi to 100002π10000 \cdot 2\pi. This allows the model to easily learn to attend by relative positions.

Configuration

100
10500
256
161024
Loading Visualization...

Hover over the heatmap to see exact values.