Cornell CS 4782 / 5782 · Spring 2026 · Extra Credit Demo Author: Yung-Chia Chang
Double-click index.html, or from a terminal:
# From this directory
open index.html # macOS
xdg-open index.html # Linux
start index.html # WindowsThe demo is a static HTML page — no build step, no server, no network.
All dependencies (KaTeX, webfonts) are bundled under vendor/ so it runs
fully offline in any modern browser.
Tested on Chrome, Safari, and Firefox.
Four interactive panels that build up RoPE from first principles:
-
Panel 00 — Why we need this. Side-by-side attention matrices with a Shuffle button and a "position info" toggle. Demonstrates that raw attention is order-blind: shuffling tokens just permutes the same set of values. Once positional info is injected, every value changes, and each shuffle produces an entirely new pattern. Establishes the bug RoPE solves.
-
Panel 01 — The rotation idea. Slide position
mand watch a 2-D query vector rotate bym·θon the unit circle. Length stays fixed; only direction changes. Establishes "position = angle." -
Panel 02 — Many frequencies at once. Shows that a
d-dim vector is split intod/2planes, each rotating at its own frequencyθ_i = 10000^(-2i/d). Visualizes the multi-scale fast/slow structure that avoids periodicity in long contexts. -
Panel 03 — Relative position, for free. The punchline. A "Lock distance m−n" toggle lets the user shift both positions simultaneously while watching the inner product ⟨q_m, k_n⟩ stay fixed — a live demonstration that RoPE attention depends only on relative position.
- Open and go. Just open
index.html— no build, no install, no network required. - Day theme is default, optimized for projectors. Top-right toggle for night mode if students are viewing on their own.
- Each panel has one primary interaction — no hidden controls, no cognitive overhead.
- Suggested 5-minute classroom flow:
- Panel 0 with PE off → shuffle a few times → "attention is order-blind"
- Toggle PE on → shuffle again → "now order matters; every shuffle gives a new pattern"
- Panel 1 → drag slider → "RoPE = rotation, position = angle"
- Panel 2 → drag slider → "many clocks at different speeds avoid periodicity"
- Panel 3 → enable Lock distance → drag slider → "only relative distance matters"
- All assets bundled locally — works offline, no CDN dependencies, no external fonts.
rope-demo/
├── index.html # main page
├── styles.css # design system (editorial light/dark)
├── rope.js # canvas visualizations + math
├── vendor/
│ ├── katex/ # bundled KaTeX 0.16.9
│ └── fonts/ # Fraunces + Manrope + JetBrains Mono
└── README.md # this file
Su, J., Lu, Y., Pan, S., Murtadha, A., Wen, B., & Liu, Y. (2021). RoFormer: Enhanced Transformer with Rotary Position Embedding. arXiv:2104.09864