Same Tokenizer, Better Tokens: Choosing Image Tokens by MAP Inference
Organizations: Faculty of Mathematics and Computer Science, Jagiellonian University, Kraków, Poland · Doctoral School of Exact and Natural Sciences, Jagiellonian University, Kraków, Poland · Centre for Credible Artificial Intelligence, Warsaw University of Technology, Poland
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
Figures & tables
| rFID-50k | FID ∞ | |||||||
|---|---|---|---|---|---|---|---|---|
| Tokenizer | , tokens | NN | RecaP 0 | change | NN | RecaP 0 | PSNR (dB) | LPIPS-A |
| LlamaGen VQ-16 [ 63 ] | , 16 16 | 2.25 | 1.30 | 42% | 1.73 | 0.86 | +1.27 | 5.4% |
| SimVQ [ 79 ] (128 px) | , 16 16 | 3.67 | 2.60 | 29% | 3.54 | 2.51 | +1.22 | 9.2% |
| SimVQ (128 px) | , 16 16 | 2.00 | 1.43 | 28% | 1.91 | 1.34 | +1.04 | 13.1% |
| Open-MAGVIT2-L [ 46 ] | LFQ, 16 16 | 1.25 | 1.01 | 19% | 0.89 § | 0.64 § | +1.06 | 1.1% |
| IBQ [ 61 ] | , 16 16 | 1.38 | 1.08 | 21% | 0.97 § | 0.69 § | +1.17 | 0.2% |
| tokens | bits | gFID-50k | held-out gFID | FID ∞ | FID(X,R) | Prec. | Rec. | |
|---|---|---|---|---|---|---|---|---|
| IN-100 | NN | 12.22 | 12.05 0.15 | 16.57 0.20 | 11.55 | 2.95 | 0.73 | 0.35 |
| RecaP 0 ( ) | 12.66 | 11.54 0.13 | 16.41 0.14 | 11.04 | 1.48 | 0.72 | 0.36 | |
| RecaP ( ) | 12.09 | 10.90 0.16 | 15.97 0.16 | 10.40 | 1.51 | 0.73 | 0.36 | |
| IN-1k | NN | 11.07 | 6.90 0.19 | 6.79 0.06 | 6.35 | 1.93 | 0.87 | 0.48 |
| RecaP ( ) | 10.89 | 5.77 0.21 | 6.19 0.27 | 5.20 | 0.99 | 0.84 | 0.53 | |
| released GPT-B, 300 epochs | 10.97 | 5.20 | 5.86 | 4.63 | 1.88 | 0.83 | 0.55 | |
| IN-1k , GPT-B, epoch 100 | NN | RecaP | |
|---|---|---|---|
| gFID-50k (registered) | 6.90 0.19 | 5.77 0.21 | 0.003 |
| OpenAI’s evaluator, FID | 6.92 0.21 | 5.73 0.22 | 0.002 |
| second sampling seed | 6.84 0.14 | 5.81 0.23 | 0.005 |
| FID-10k, no guidance | 34.51 1.12 | 29.55 0.69 | 0.005 |
| held-out, cfg 2.0 † | 6.79 0.06 | 6.19 0.27 | 0.057 |
| FD DINOv2 , cfg 2.0 † | 327.7 7.3 | 299.9 4.0 | 0.009 |
| arm | tokens: prior, | gFID-50k | held-out | bits |
|---|---|---|---|---|
| NN | none (NN) | 12.05 0.15 | 16.57 0.20 | 12.22 |
| RecaP 0 | none, 0 | 11.54 0.13 | 16.41 0.14 | 12.66 |
| RecaP | released, 0.01 | 10.90 0.16 | 15.97 0.16 | 12.09 |
| RecaP | released, 0.03 | 11.36 0.05 | 16.55 0.06 | 11.35 |
| RecaP own | own, 0.01 | 11.54 0.31 | 16.54 0.14 | 12.13 |
| RecaP cross | cross-fitted, 0.01 | 12.02 0.28 | 16.90 0.29 | 12.25 |
| Prior | NLL advantage (bits/token) | gFID-50k change (%) |
|---|---|---|
| Cross-fitted GPT-B | 0.16 | |
| Our GPT-B | 0.40 | |
| Released GPT-B | 1.21 | |
| Our GPT-L | 1.23 | |
| Released GPT-L | 1.49 |
| IN-100 | IN-1k | ||||
| tokens | views | gFID-50k | held-out | gFID-50k | held-out |
| NN | 2 | 12.05 0.15 | 16.57 | 6.90 0.19 | 7.482 |
| RecaP | 2 | 10.90 0.16 | 15.97 | 5.77 0.21 | 6.193 |
| RecaP , 3 maps | 2 | 8.81 0.22 | 13.75 | 5.57 0.06 | 6.186 |
| NN | 10 | 8.26 0.05 | 13.31 | 6.23 0.08 | 6.436 |
| RecaP | 10 | 7.61 0.19 | 13.12 | not run ∗ | |
Appendix figures & tables29 assets
Supplementary material from the paper’s appendix.
Appendix
| result | needs | evidence |
|---|---|---|
| Lem. 1 (CVP) | (A1) | (A1) only qualitative |
| Lem. 2 (NN exact) | (A1) | fails on trained encoders |
| Prop. 1 | (A1), (A2) | derivation checked by MC |
| Cor. 1 | (A1), (A2) | factors from measured |
| Lem. 3 (near-ties) | (A2) | fits run overlap |
| Prop. 2 | applies via (A3) |
| tokenizer | PSNR (dB) | images better | LPIPS-A [95% CI] | rFID SE ( ) | KID ( ) | |
|---|---|---|---|---|---|---|
| LlamaGen VQ-16 | 50k | +1.269 0.002 | 99.99% | 5.37% [ 5.44, 5.29] | 0.951 0.091 ( 10.4) | 0.954 ( 13.4) |
| SimVQ- | 50k | +1.222 0.002 | 99.99% | 9.15% [ 9.28, 9.03] | 1.072 0.077 ( 14.0) | 1.303 ( 16.6) |
| SimVQ- | 50k | +1.042 0.002 | 99.996% | 13.11% [ 13.23, 12.98] | 0.566 0.039 ( 14.3) | 0.684 ( 16.7) |
| Open-MAGVIT2-L | 50k | +1.060 0.001 | 99.99% | 1.06% [ 1.14, 0.98] | 0.237 0.033 ( 7.2) | 0.308 ( 11.0) |
| IBQ- | 50k | +1.166 0.002 | 99.86% | 0.20% [ 0.29, 0.12] | 0.296 0.046 ( 6.4) | 0.348 ( 10.5) |
| IBQ- | 50k | +1.090 0.001 | 99.99% | 0.03% [ 0.11, +0.06] | 0.159 0.027 ( 5.8) | 0.203 ( 10.0) |
| tokenizer | FD DINOv2 NN RecaP 0 | SE ( ) | change | FD ∞ NN RecaP 0 ( ) | rFID change |
|---|---|---|---|---|---|
| SimVQ- (128 px) | 96.83 85.23 | 11.61 0.51 ( 22.7) | 12.0% | 68.75 59.87 ( 18.7) | 26% |
| SimVQ- (128 px) | 182.2 160.5 | 21.8 0.8 ( 26.5) | 11.9% | 141.0 122.8 ( 23.5) | 26% |
| Open-MAGVIT2-L | 43.07 38.12 | 4.96 0.27 ( 18.2) | 11.5% | 23.05 20.17 ( 14.8) | 22% |
| TiTok-S-128 | 201.5 190.2 | 11.3 1.2 ( 9.1) | 5.6% | 164.3 156.4 ( 6.9) | 12% |
| FVQ- | 44.40 42.30 | 2.09 0.34 ( 6.1) | 4.7% | 25.42 24.85 ( 1.9) | 30% |
| IBQ- | 33.57 32.12 | 1.45 0.35 ( 4.2) | 4.3% | 15.95 15.88 ( 0.2) | 19% |
| COCO val2017 (5,000 images) | DIV2K (100 images) | ||||||
|---|---|---|---|---|---|---|---|
| tokenizer | PSNR (dB) | of ImageNet’s | LPIPS-A | rFID-5k NN RecaP 0 | FID ∞ ( ) | PSNR (dB) | LPIPS-A |
| LlamaGen VQ-16 | +1.23 | 0.97 | 6.0% | 8.22 6.90 | 32.5% ( 6.4) | +1.12 | 2.9% |
| IBQ- | +1.12 | 0.96 | 1.7% | 7.30 6.75 | 6.8% ( 1.0) | +1.08 | +3.3% |
| TiTok-S-128 | +1.99 | 1.07 | 10.4% | 9.31 8.88 | +25.8% (+4.5) | +1.68 | 6.0% |
| GigaTok B-L-2D | +1.21 | 0.97 | 4.9% | 6.16 5.57 | 36.1% ( 4.5) | +1.15 | 3.4% |
| tokens | finest | middle | PSNR | LPIPS-A | bits |
|---|---|---|---|---|---|
| NN | 0.90 | 0.99 | 20.86 | 0.137 | 10.96 |
| RecaP 0 ( ) | 0.54 | 0.71 | 22.12 | 0.130 | 11.50 |
| 0.54 | 0.72 | 22.12 | 0.129 | 11.22 | |
| RecaP ( ) | 0.54 | 0.72 | 22.07 | 0.130 | 10.72 |
| 0.56 | 0.74 | 21.82 | 0.134 | 9.91 | |
| 0.65 | 0.82 | 21.09 | 0.145 | 9.18 |
| objective | PSNR | LPIPS-A | finest | middle |
|---|---|---|---|---|
| NN | n/a | 0.138 | 0.93 | 0.97 |
| RecaP 0 ’s objective (no polish) | +1.31 | 0.130 | 0.54 | 0.71 |
| + price per moved token, | +0.98 | 0.129 | 0.65 | 0.79 |
| LPIPS weight 3 (not 1) | +0.86 | 0.128 | 0.63 | 0.77 |
| + local energy, | +1.07 | 0.126 | 0.74 | 0.80 |
| + local energy, | +0.83 | 0.125 | 0.87 | 0.85 |
| tokens | PSNR | LPIPS-A | finest | FD | FD DINOv2 |
|---|---|---|---|---|---|
| NN | n/a | 0.138 | 0.92 | 4.32 | 108.9 |
| RecaP 0 | +1.27 | 0.131 | 0.54 | 3.07 | 106.2 |
| + energy, | +1.01 | 0.126 | 0.74 | 3.00 | 98.5 |
| + energy, | +0.79 | 0.125 | 0.89 | 3.04 | 96.2 |
| tokenizer | preprocessing | codes, candidates | rFID | batch | s/image | |
|---|---|---|---|---|---|---|
| LlamaGen VQ-16 | ADM resize, centre crop 256 | L2 + LPIPS | unit norm; 16 nearest | clean-fid | 32 | 0.55 |
| SimVQ- / | resize, centre crop 128 | L1 + LPIPS | projected codes; 16 nearest | authors’ | 64 / 32 | 0.13 / 0.12 |
| Open-MAGVIT2-L | shorter side 256 (bilinear), centre crop | L1 + LPIPS | LFQ signs; 16 nearest | authors’ | 8 | 1.71 |
| IBQ- / | as Open-MAGVIT2 | L1 + LPIPS | 16 largest | authors’ | 8 | 1.98 / 2.05 |
| TiTok-S-128 / SL-256 | bicubic resize, centre crop 256 | L2 + LPIPS | unit norm / Euclidean; 16 nearest | clean-fid | 8 | 0.97 / 1.73 |
| GigaTok B-L / + DINO | LlamaGen’s centre crop 256 | L2 + LPIPS | unit norm; 16 nearest | clean-fid | 8 | 2.12 / 2.48 |
| experiment | GPUs | GPU-h |
|---|---|---|
| Table 1 : LlamaGen, SimVQ- , , 150k encodings with NN, metrics | GH200 | 11.1 |
| Table 1 : Open-MAGVIT2-L / IBQ- / IBQ- , 50k each | RTX 4090 | 23.7 / 28.5 / 27.5 |
| TiTok-S-128 / SL-256, 10k each | RTX 4090 | 2.7 / 4.8 |
| GigaTok B-L / B-L + DINO / with its discriminator in , 50k each | RTX 4090 | 29.4 / 34.4 / 30.8 |
| FVQ / GigaTok B-L-2D, 50k each | several | 22.3 / 34.8 |
| Cost and rate, LlamaGen: cost / rate group, 10k each | RTX 5090, A100 | 14.5 / 10.8 |
| arm | seed 0 | seed 1 | seed 2 | |
|---|---|---|---|---|
| IN-100 | NN | 12.18 | 12.09 | 11.88 |
| RecaP 0 | 11.41 | 11.56 | 11.66 | |
| RecaP | 10.81 | 10.81 | 11.08 | |
| RecaP own | 11.20 | 11.61 | 11.80 | |
| IN-1k | NN | 7.11 (2.5) | 6.82 (2.0) | 6.76 (2.5) |
| RecaP | 5.93 | 5.85 | 5.53 |
| IN-1k , GPT-B, epoch 300 | NN | RecaP | |
|---|---|---|---|
| gFID-50k (registered) | 5.92 0.40 | 5.21 0.15 | 0.079 |
| OpenAI’s evaluator, FID | 5.89 0.43 | 5.18 0.15 | 0.093 |
| second sampling seed | 5.93 0.45 | 5.17 0.13 | 0.089 |
| FID-10k, no guidance | 31.68 0.26 | 26.05 2.31 | 0.050 |
| held-out, cfg 2.0 | 6.03 0.25 | 6.09 0.27 | 0.80 |
| FD DINOv2 , cfg 2.0 † | 296.4 4.5 | 268.1 8.3 | 0.013 |
| run (cfg) | IS | FID | sFID | Prec. | Rec. | CMMD | |
|---|---|---|---|---|---|---|---|
| epoch 100 | NN seed 0 (2.5) | 202.2 | 7.15 | 6.70 | 0.885 | 0.358 | 0.467 |
| NN seed 1 (2.0) | 163.4 | 6.76 | 5.93 | 0.850 | 0.424 | 0.533 | |
| NN seed 2 (2.5) | 204.1 | 6.86 | 6.25 | 0.888 | 0.357 | 0.475 | |
| RecaP seed 0 (2.0) | 178.9 | 5.91 | 6.36 | 0.848 | 0.433 | 0.530 | |
| RecaP seed 1 (2.0) | 180.2 | 5.80 | 5.81 | 0.852 | 0.427 | 0.517 | |
| RecaP seed 2 (2.0) | 178.5 | 5.49 | 5.76 | 0.843 | 0.447 | 0.539 |
| generator | params | training | FID-50k |
| ours (OpenAI’s evaluator in brackets) | |||
| GPT-B, NN tokens | 111M | 100 ep. | 6.90 (6.92) |
| GPT-B, RecaP tokens | 111M | 100 ep. | 5.77 (5.73) |
| GPT-B, NN tokens | 111M | 300 ep. | 5.92 (5.89) |
| GPT-B, RecaP tokens | 111M | 300 ep. | 5.21 (5.18) |
| GPT-L, NN tokens | 343M | 100 ep. | 4.15 |
| arm (cfg) | FD DINOv2 | held-out | P / R | |
|---|---|---|---|---|
| IN-100 | NN (2.5) | 542.0 4.9 | 615.2 | 0.474 / 0.141 |
| RecaP 0 (2.5) | 564.0 4.1 | 636.4 | 0.473 / 0.131 | |
| RecaP (2.5) | 525.6 4.2 | 598.6 | 0.477 / 0.126 | |
| RecaP +energy (2.5) | 522.9 7.5 | 596.1 | 0.479 / 0.131 | |
| IN-1k | NN (registered) | 291.2 24.3 | 301.2 | 0.630 / 0.413 |
| NN (2.0) | 327.7 7.3 | 336.5 | 0.602 / 0.439 |
| prior | NN | RecaP | difference |
|---|---|---|---|
| released GPT-B (search’s prior) | 0.22 | ||
| released GPT-L | 0.50 | 0.39 | |
| IN-100 GPT-B, NN tokens 1 | 0.49 | 0.42 | |
| IN-100 GPT-B, RecaP tokens | 0.61 | 0.49 |
| NN | RecaP , prior: | |||
|---|---|---|---|---|
| generator | GPT-B r | GPT-L r | GPT-L o | |
| IN-100 : prior bits | n/a | 11.01 | 10.73 | 10.99 |
| GPT-B | 12.05 0.15 | 10.90 0.16 | 11.25 0.18 | 11.21 0.08 |
| IN-1k : prior bits | n/a | 10.97 | 10.69 | 10.96 |
| GPT-B | 6.90 0.19 | 5.77 0.21 | 5.85 0.05 | – |
| GPT-L 1 | 4.15 | 4.13 | 3.95 | – |
| tokens | gFID-50k | cfg | held-out | bits | against NN/ RecaP (Holm) |
|---|---|---|---|---|---|
| NN | 12.05 0.15 | 2.5 | 16.57 | 12.22 | – |
| RecaP ( , 50 steps, two views) | 10.90 0.16 | 2.5 | 15.97 | 12.09 | better / – |
| RecaP , | 11.36 0.05 | 2.5 | 16.55 | 11.35 | – / worse |
| RecaP , | 11.31 0.11 | 2.5 | 16.24 | 12.47 | better / worse |
| RecaP , 35 steps | 11.17 0.28 | 2.5 | 16.23 | 12.09 | better / tie |
| L2 only, at RecaP ’s rate | 15.13 0.18 | 3.0 | 20.14 | 11.97 | worse / worse |
Image Tokenization
Image tokenization converts images into compact discrete or continuous visual units for efficient generation, compression, and multimodal reasoning.
See all 59 papers