Same Tokenizer, Better Tokens: Choosing Image Tokens by MAP Inference

Piotr Kubaty, Jacek Tabor, Łukasz StruskiarXiv 2026

TL;DR

When turning images into discrete tokens for GPT-style visual generators, the standard rule of snapping each image patch to its "nearest-neighbor" code in isolation leaves surprising quality on the table. By instead searching for token sequences that work together through the decoder—and nudging them toward sequences a language model expects to see—we can get sharper reconstructions and train downstream image generators much faster, without changing a single weight in the tokenizer itself.

What Problem Does This Paper Address?

Autoregressive image generators (think GPT, but predicting image patches instead of words) rely on visual tokenizers like VQGAN to compress continuous images into grids of discrete numbers, or codes, drawn from a fixed codebook.

Traditionally, after an encoder maps an image into continuous features, the tokenizer picks codes using Nearest-Neighbour (NN) assignment: each patch independently grabs whichever codebook vector sits closest in Euclidean space.

Here is the catch: the decoder doesn't read those codes in isolation. It blends them together spatially, and it cares much more about subtle shifts in some feature directions than others. Picking the closest code for each patch individually is like assembling a choir by hiring singers who sound loudest solo, without checking if they harmonize. Furthermore, because many different token combinations can reconstruct essentially the same image, arbitrary tie-breaking can produce jagged, unpredictable sequences that a downstream generator struggles to learn.

Methods

Instead of retraining bigger tokenizers, the authors freeze existing pretrained models and reframe token selection as Maximum A Posteriori (MAP) inference. Their method, RecaP (Reconstruction and Predictability), searches for a grid of tokens that balances two goals:

  1. Likelihood (Reconstruction): Passing the candidate tokens through the frozen decoder must faithfully recreate the original image. (When run without a prior, this reconstruction-only baseline is called $\text{RecaP}_0$).
  2. Prior (Predictability): The sequence of tokens should have high probability under a frozen, pretrained autoregressive generator—meaning each token makes sense in the context of its preceding neighbors.

Because discrete search over an entire grid is intractable, RecaP uses annealed relaxation. For each image position, it takes the 16 closest codebook entries and feeds a soft, weighted mixture of them into the frozen decoder and prior. Using Adam for 50 gradient steps, it optimizes the mixture weights while gradually lowering a softmax temperature ($\tau: 1 \to 0.01$) until the soft mixtures harden into crisp, discrete token choices.

Overview of the RecaP pipeline and resulting training speedup on GPT-B.

Datasets

The authors evaluate image reconstruction on ImageNet-1k validation images, COCO, and DIV2K. Downstream class-conditional image generation experiments are conducted on ImageNet-1k and a 100-class subset (IN-100). No new benchmark datasets are introduced.

Key Insights and Ideas

  • Why nearest-neighbor falls short mathematically: Using a local quadratic approximation of the decoder's loss, the authors prove that independent Euclidean lookup is only guaranteed to be optimal if the encoder lands directly on the loss minimum and the decoder treats every feature direction identically without mixing neighboring patches. Real neural decoders violate all three conditions.
  • Spatial cooperation is real: When $\text{RecaP}_0$ updates tokens on LlamaGen, patches whose own token didn't even change still account for 32% of the total squared-error reduction—proof that neighboring tokens actively help each other across patch boundaries.
  • Equivalent images, wildly different tokens: Two reconstruction-only searches starting from slightly perturbed points achieve equal image quality (PSNR) while agreeing on only 55% of their chosen tokens. That massive redundancy is exactly what gives RecaP room to pick predictable tokens without sacrificing visual fidelity.
  • The predictability sweet spot: Weighting the prior too heavily ($\lambda = 0.03$) makes tokens super easy for a generator to predict, yet actually hurts final image generation quality compared to a balanced weight ($\lambda = 0.01$). Tokens must stay anchored to visual reality.

Key Results

  • Universal reconstruction gains: Across 12 frozen tokenizers (including LlamaGen, SimVQ, Open-MAGVIT2, TiTok, and GigaTok), $\text{RecaP}_0$ boosts PSNR by 0.9 to 1.9 dB—improving at least 99.7% of individual images—and lowers reconstruction FID (rFID) by 11–42% on 11 of the 12 models.
  • 3x faster generator convergence (against training distribution): On ImageNet-1k, a LlamaGen GPT-B model trained on RecaP tokens reaches the 300-epoch training-reference FID of a standard NN-trained model in just 100 epochs. At epoch 100, generation FID (gFID-50k) drops by 16% on ImageNet-1k (6.90 to 5.77) and 9.5% on IN-100.
  • Nuance on held-out data: Improvements are smaller when evaluated against held-out validation images (a 0.60 FID drop at epoch 100, and roughly tied by epoch 300).

Limitations and Future Work

  • Encoding overhead: Running 50 gradient steps through a decoder and prior adds a one-time upfront compute cost. For a single training run, RecaP costs more total compute than standard tokenization, though reusing the saved tokens across three or more generator runs makes it a net saver.
  • Domain dependence & texture smoothing: Generation tests were limited to ImageNet, and extending RecaP to new domains requires having a capable prior already on hand. Additionally, optimizing standard reconstruction losses tends to smooth out ultra-fine textures (like bird feathers), though the authors show a promising fix by adding a local finest-scale energy term to the search objective.

Summary updated

Abstract

Discrete visual tokens encode images for reconstruction and serve as training targets for autoregressive image generators. Vector-quantized tokenizers typically assign each encoder feature its nearest code independently. The decoder uses these codes jointly, so a sequence of individually nearest codes can reconstruct an image less faithfully than an alternative assignment. A local model of the reconstruction loss yields a closest-vector problem with a decoder-dependent target and metric. Reconstruction-only search improves PSNR across the frozen tokenizers we test. Different code sequences can achieve similar reconstruction quality, leaving room to favour more predictable ones. We introduce RecaP (Reconstruction and Predictability), which selects codes for a frozen tokenizer by balancing how faithfully they reconstruct the image with how likely their sequence is under a pretrained autoregressive prior. On ImageNet, LlamaGen GPT-B trained on RecaP tokens achieves lower early-checkpoint FID against training images than GPT-B trained on nearest-neighbour tokens. The difference is smaller against held-out images. On an ImageNet subset, the prior improves generation at comparable reconstruction FID. Our code is available at: https://github.com/gmum/recap
BibTeX
@misc{kubaty2026same,
  author = {Piotr Kubaty and Jacek Tabor and Łukasz Struski},
  title = {{Same Tokenizer, Better Tokens: Choosing Image Tokens by MAP Inference}},
  year = {2026},
  eprint = {2611.33261},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33261},
}
Figure