CruxTok Architecture

The architecture of CruxTok, the residual text tokenizer from my preprint, from the whole model down to one level.
Research
GenAI
NLP
Machine Learning
Author
Published

November 5, 2026

CruxTok is a discrete text tokenizer built on the multiscale residual VQ-VAE from Next-Concept Modeling. NCM builds each coarse level by averaging fixed windows of the text. CruxTok replaces that with learned attention, so each code can choose which words it reads. Why I tried this, and what came out of it, is in CruxTok: Letting the First Level Choose What Matters.

The diagrams show the tokenizer exactly as it was trained for the preprint: 48-token windows of XSum news summaries, GPT-2 token ids, and vectors of width 384. The code and configs are on GitHub.

The whole tokenizer

Token ids go to an encoder, then levels 1 to 9 in sequence, each producing codes and adding to a running sum read by the decoder.

Token ids pass through an encoder, then nine levels in order. Each level receives what the earlier levels failed to capture and adds to a running sum, which the decoder reads at a cutoff level.

Slots rise with level

Nine bars. Slots per level are 4, 6, 10, 14, 20, 26, 32, 40 and 48, and total codes reach 200, or 2,400 bits.

Each bar spans the same 48 tokens, with one block per slot, showing where each slot starts. Slots rise from 4 to 48. Each slot picks one 12-bit code from its level’s codebook.

Level 1 is only 4 codes for the whole sentence, so at most it can hold the gist.

Inside one level

Four bands. Pool: queries attend to the residual, with a learnable prior added to the scores before softmax. Quantize: nearest code from the codebook with a straight-through estimator. Expand: positions attend to the code vectors, again with a prior. Update: add to the running sum and subtract from H with stop-gradient to form the next residual.

One level pools the residual into slots, snaps each slot to its nearest code, expands the codes back to 48 positions, and adds the result to the running sum. Only the number of slots changes across levels 1 to 8.

The prior is added to the raw scores before the softmax: \(\text{attention} = \text{softmax}(qk^\top/8 + B)\). It starts each slot as a soft Gaussian centred on NCM’s window for that slot. It is the same for every input, so it carries no information about the text itself.

The prior is soft on purpose. At level 1, about a quarter of each slot’s starting weight already falls outside its own window, and the queries are free to move it further. Adding a prior this way is studied in You Need Better Attention Priors.

Queries and keys are RMS-normalised per head before the dot product. Without that, the attention logits grew to about \(10^7\) and training diverged.

The last level

Levels 1 to 8 go through pool, codebook and expand. Level 9 goes straight from the residual to the codebook to its output.

Levels 1 to 8 pool, quantize and expand. Level 9 has one slot per token, so it skips pooling and expansion and quantizes each position directly.