Balance of Number of Embedding and their Dimensions in Vector Quantization
Hang Chen, Sankepally Sainath Reddy, Ziwei Chen, Dianbo Liu
TL;DR
The paper tackles the challenge of balancing the codebook size $N$ and embedding dimension $D$ in VQ-VAE under a fixed capacity $W=ND$ by showing that larger $N$ with smaller $D$ can enhance reconstruction. It introduces an adaptive dynamic quantization mechanism based on attention and $Gumbel$-Softmax to select an optimal codebook per data point, coupled with EMA-updated codebooks. Through six benchmark datasets, it demonstrates that the adaptive approach outperforms the best fixed-codebook configurations at the same capacity and reveals a two-stage learning dynamic where the model initially leverages larger codebooks and later specializes. This work highlights the value of flexible, per-instance discretization for improving discrete latent representations and offers a scalable path to better VQ-based reconstruction and generation tasks.
Abstract
The dimensionality of the embedding and the number of available embeddings ( also called codebook size) are critical factors influencing the performance of Vector Quantization(VQ), a discretization process used in many models such as the Vector Quantized Variational Autoencoder (VQ-VAE) architecture. This study examines the balance between the codebook sizes and dimensions of embeddings in VQ, while maintaining their product constant. Traditionally, these hyper parameters are static during training; however, our findings indicate that augmenting the codebook size while simultaneously reducing the embedding dimension can significantly boost the effectiveness of the VQ-VAE. As a result, the strategic selection of codebook size and embedding dimensions, while preserving the capacity of the discrete codebook space, is critically important. To address this, we propose a novel adaptive dynamic quantization approach, underpinned by the Gumbel-Softmax mechanism, which allows the model to autonomously determine the optimal codebook configuration for each data instance. This dynamic discretizer gives the VQ-VAE remarkable flexibility. Thorough empirical evaluations across multiple benchmark datasets validate the notable performance enhancements achieved by our approach, highlighting the significant potential of adaptive dynamic quantization to improve model performance.
