Scaling the Codebook Size of VQGAN to 100,000 with a Utilization Rate of 99%

Lei Zhu, Fangyun Wei, Yanye Lu, Dong Chen · DOI

Introduction

In computer vision, quantization is the process of converting continuous image features into discrete "tokens," similar to words in a sentence. This is typically achieved using a Vector Quantized Generative Adversarial Network (VQGAN), which relies on a codebook—a dictionary of visual features. However, scaling these dictionaries has historically been difficult. While Large Language Models (LLMs) benefit from vocabularies exceeding 100,000 tokens, VQGANs often plateau at around 16,384 entries. Attempting to scale further usually results in "dead" codebook entries that are never utilized during training, leading to poor performance.

Standard VQGAN architecture showing the flow from image to reconstruction via a quantizer and codebook.

The VQGAN-LC Approach

Researchers have introduced VQGAN-LC (Large Codebook), which successfully scales codebooks to 100,000 entries—nearly 10x the typical limit—while maintaining a staggering 99% utilization rate. The core innovation lies in flipping the traditional training approach on its head through three key mechanisms:

  1. Static Initialization: Instead of learning every entry from scratch, VQGAN-LC uses a pre-trained vision encoder (like CLIP) to extract features from ImageNet. K-means clustering is then applied to find 100,000 representative "visual words," forming a frozen, static codebook.
  2. Learnable Projector: To align these static features with the rest of the network, a simple linear projector is introduced. During training, the encoder and decoder learn to map image features to the most relevant entries in the massive static codebook via this projector.
  3. Alignment over Optimization: Traditional methods attempt to move individual codebook entries to match image data. VQGAN-LC instead optimizes the mapping to the codebook. Since the codebook starts with high-quality features, almost every entry remains active and useful from the beginning.

Key Results and Scaling Performance

The model was evaluated on ImageNet-1K and FFHQ benchmarks, demonstrating that the "dead codebook" issue was an optimization failure rather than a capacity limitation. By using CLIP-based initialization, the model starts with a vocabulary that already understands visual concepts.

Comparison of codebook utilization rates across scales (left) and performance on downstream tasks (right).

As shown in the figures above, VQGAN-LC maintains near-perfect utilization even at 100,000 entries, whereas previous state-of-the-art variants like VQGAN-FC saw utilization drop to ~1.9%. This scaling translates directly to improved performance:

  • Superior Reconstruction: VQGAN-LC achieved a reconstruction FID (rFID) of 2.62 on ImageNet-1K, significantly outperforming VQGAN-EMA (3.46).
  • Generative Boost: When integrated into Latent Diffusion Models (LDM) or Diffusion Transformers (DiT), the 100k codebook led to superior image synthesis, improving the LDM FID score from 9.13 to 8.36.
  • Downstream Success: The more meaningful tokens produced by VQGAN-LC resulted in a 1.6% to 1.9% improvement in Top-1 accuracy for image classification tasks.

Conclusion and Future Work

VQGAN-LC demonstrates that scaling visual vocabularies is a viable path toward better image representation and generation. While the current codebook is tied to the distribution of the initialization dataset (ImageNet), future work aims to leverage even larger, uncurated datasets like LAION-5B to create a truly universal visual vocabulary. This "zero-cost scaling" approach proves that vision models can benefit from massive vocabularies just as LLMs have, without significant additional computational overhead during training.

Summary updated

BibTeX
@inproceedings{zhu2024scaling,
  author = {Lei Zhu and Fangyun Wei and Yanye Lu and Dong Chen},
  title = {{Scaling the Codebook Size of VQGAN to 100,000 with a Utilization Rate of 99\%}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=RbU10yvkk6},
}
Figure