rope -- rotary position embedding (per-pair 2-D rotation)

Attention on its own is blind to word order. Shuffle the words of a sentence and it computes exactly the same thing, which would make "dog bites man" and "man bites dog" identical to the model. Something has to tell it where each word sits. RoPE does that by rotating each word's numbers through an angle that depends on its position, like turning a dial one notch per word — and not one dial but many, some spinning fast enough to tell neighbours apart and some so slowly that they only register whole paragraphs. Two words five apart always end up at the same relative angle, so the model learns "five apart" rather than "word 12 and word 17" — and that is why you can stretch a model to longer documents than it was trained on by turning the slow dials slower still.

Interactive page: how RoPE encodes position by rotating each dimension-pair of a query/key vector by an angle proportional to position. Anchor: A1 RoPE shape (Family B8).

What it shows

A d-dim vector is split into d/2 pairs (x₂ᵢ, x₂ᵢ₊₁). At position p, pair i is rotated in its own 2-D plane by Δ = p · θᵢ, where the per-pair frequency θᵢ = base^(−2i/d). The main view is d/2 little 2-D planes — each shows the original pair (gray), the rotated pair (blue), and a spiral tracing the total sweep p·θᵢ. Low pairs (high frequency) spin fast as you scrub the position; high pairs (low frequency) barely move — the multi-scale positional code. A supporting [N×d] heatmap shows the rotated components across all positions (the RoPE "wave"), with the current position's row outlined.

Because rotations compose (R(mθ)ᵀR(nθ) = R((n−m)θ)), the query·key dot product ends up depending only on the relative position m−n — noted in the readout. Sliders for head_dim, the rotary base, and seed.

Render tier

T2 (WebGL2 heatmap for the across-positions wave; Canvas2D overlays for the rotation planes, arrows, and spirals).

Wiring

layout.mount + controls (head_dim, positions, base, seed) + a per-position Transport, drawn with render.heatmap/arrow + ctx tensor.rope/ropeAngles/seededRandn. Direct-manipulable per the interaction contract: drag horizontally (or the position track) to move the token position so every pair’s Δ = p·θᵢ updates live; hover a rotation plane for its θᵢ / Δ / (cos,sin) / rotated (x,y) or a heatmap cell for its value; when not dragging the position sweeps on its own (animate). Headless hooks: ?pos=N (set position + freeze the sweep), ?hover=x,y (fake the cursor for the tooltip), plus the existing ?step=N/?play=1/?theta. Source: page.js.