NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Kepler codebook

Junrong Lian, Ziyue Dong, Pengxu Wei, Wei Ke, Chang Liu, Qixiang Ye, Xiangyang Ji, Liang Lin

Introduction

Researchers have developed the Kepler Codebook, a novel approach to vector quantization that treats latent space organization as a sphere-packing problem. By enforcing a structured, hexagonal-inspired distribution, this method eliminates "dead tokens" and achieves 100% codebook usage, significantly outperforming state-of-the-art models like VQGAN in both image reconstruction and generation.

The Problem: Codebook Collapse in Vector Quantization

In the world of generative AI, many models rely on Vector Quantization (VQ). Think of VQ as a "digital palette": instead of storing every possible color or texture, the model learns a "codebook"—a collection of discrete tokens—to represent images.

However, VQ-based models suffer from a persistent headache known as codebook collapse. This occurs when the model only uses a tiny fraction of its available palette, leaving the rest of the tokens "dead" and untrained. While recent methods have tried to force the model to use more tokens through random sampling, they often result in a messy, disordered distribution. This leads to a "quantity over quality" paradox: even if a model uses 90% of its codebook, if those tokens are poorly organized, the resulting images will suffer from artifacts, blurry textures, and poor fine details.

The Solution: 17th-Century Geometry Meets AI

The authors step back from pure machine learning and look toward 17th-century geometry. They argue that codebook training is essentially a version of Kepler’s Conjecture, which describes the most efficient way to pack spheres (like oranges in a crate) to achieve maximum density.

To translate this into a neural network, they introduced three key innovations:

  1. Kepler Distribution: They derived a compact, structured distribution for the codebook. In 2D, this looks like a perfect hexagonal grid. In high-dimensional latent space, it ensures that every token is "relatively far apart" from its neighbors but "tightly packed" overall.
  2. Irwin-Hall Distribution (IHD) Regularization: To keep the codebook from drifting into chaos during training, they used the Irwin-Hall distribution—a mathematical model for the sum of independent uniform variables—as a "prior" or target template. They used KL divergence to penalize the model if its codebook distribution strayed from this ideal structure.
  3. Codebook Partitioning: High-dimensional spaces suffer from the "curse of dimensionality," making it hard to calculate probabilities accurately. The authors split the high-dimensional tokens into smaller "partitions" to simplify the learning process without losing representational power.
Comparison of latent space distributions: Initialization, VQGAN, Reg-VQ, and the highly structured, hexagonal-inspired Kepler Codebook (Ours).

Key Insights

  • Usage $\neq$ Quality: High codebook usage does not guarantee good images. Previous models like Reg-VQ achieved high usage but had high "active frequency variance"—meaning some tokens were still used far more than others, leading to repetitive textures.
  • Order over Randomness: While previous "fixes" for codebook collapse relied on stochastic (random) sampling, the Kepler Codebook proves that a deterministic, mathematically structured layout is far superior for capturing fine image details.
  • Resolution Resilience: Because the codebook is so well-structured, it generalizes remarkably well. The model can reconstruct images at resolutions it was never trained on (e.g., training at 256x256 but testing at 2032x1280) with much higher fidelity than its predecessors.

Experimental Results

The model was rigorously tested on standard benchmarks including ADE20K, CelebA-HQ, and cross-domain sets like MS-COCO, LSDIR, and DIV2K. The Kepler Codebook achieved dominant results across the board:

  • 100% Codebook Usage: Unlike VQGAN (which often hovers around 35% usage), the Kepler method utilizes every single token in its palette.
  • Reconstruction Accuracy: On the complex ADE20K dataset, it improved PSNR (a measure of image quality) by 1.39 to 2.9 dB over VQ-VAE and VQGAN.
  • Visual Fidelity: It achieved significantly lower rFID scores (8.59 on CelebA-HQ vs. VQGAN's 12.74), indicating that the generated images look much more realistic to the human eye.
  • Super-Resolution: When plugged into a Latent Diffusion Model (LDM), the Kepler Codebook produced sharper text and more accurate architectural details in super-resolution tasks compared to standard LDM baselines.

Limitations and Future Work

While the paper presents a robust mathematical framework, it notes that the core sphere-packing problem is NP-hard, meaning the researchers had to use a "relaxed" version of the objective rather than a perfect mathematical solution.

In terms of impact, the authors acknowledge the ethical risks common to all high-fidelity generative models: the potential for creating misleading content or deepfakes. Future work may involve exploring how this structured codebook approach scales to even larger models or different modalities like video and audio synthesis.

Summary updated

BibTeX
@inproceedings{lian2024kepler,
  author = {Junrong Lian and Ziyue Dong and Pengxu Wei and Wei Ke and Chang Liu and Qixiang Ye and Xiangyang Ji and Liang Lin},
  title = {{Kepler codebook}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
}
Figure