Residual entering level Sampled codeword Generated token grid

Residual Vector Quantization: 2D Codebook Cascade

This is a genuine, independently-computed 2D counterpart to the 3D residual-vector-quantization simulator behind AI music generators like MusicGen. Instead of orbiting spheres on a 3D ring, it plots the real coarse-to-fine RVQ cascade directly in its native 2D feature plane: one scatter panel per codebook level, each dot sized by its live softmax selection probability, with the residual vector's algebra — e_k = e_{k-1} − C_k[chosen] — traced frame by frame. A rate-distortion chart tracks the average residual magnitude after each level, and a scrolling token grid mirrors the resulting autoregressive token stream. Every codeword, probability and residual on this page is computed from scratch by this script (verified numerically against a reference implementation before shipping) — nothing is reprojected from the 3D scene.