Abstract
Variational Auto-Encoders with Vector Quantization (VQ-VAEs) are foundational to modern generative models but are limited by codebook collapse and computational inefficiencies in nearest-neighbor searches. We introduce LL-VQ-VAE, which replaces the discrete lookup-table codebook with a learnable lattice defined by a basis matrix. This approach ensures $O(1)$ quantization complexity, eliminates codebook collapse through intrinsic regularization, and reduces quantization parameters to a fraction of traditional methods. Experimental results on high-resolution datasets demonstrate a 65% reduction in training time and superior reconstruction quality compared to standard VQ-VAE baselines.
Introduction
Vector Quantization (VQ) allows autoencoders to map continuous latent spaces into discrete representations, a prerequisite for many downstream generative tasks. However, traditional VQ-VAEs face two primary challenges. First, codebook collapse occurs when the model utilizes only a small subset of available vectors, leading to underutilized capacity. Second, the computational cost of finding the nearest neighbor in a codebook scales linearly ($O(K)$) with the codebook size $K$, hindering the use of large, high-capacity codebooks. While techniques like Exponential Moving Averages (EMA) can mitigate some issues, they often compromise quantization quality.
Methodology: Learnable Lattice Vector Quantization
The proposed Learnable Lattice Vector Quantization (LL-VQ) replaces the static list of $K$ independent vectors with a structured grid defined by a basis matrix $B$.
Lattice Definition and Quantization
Instead of searching a table, the model learns a basis matrix $B$ that spans a lattice in the latent space. To quantize an encoded vector $z_e(x)$, the model performs a mathematical rounding operation to the nearest lattice point. By restricting $B$ to a diagonal matrix, the quantization process—achieved via the Babai Rounding Estimate—becomes a simple element-wise operation with $O(1)$ complexity relative to the number of points in the lattice.
Training and Regularization
The diagonal elements of $B$ are learnable parameters updated during backpropagation. Because all points in the lattice are coupled through the basis matrix, moving one point shifts the entire grid. This provides an intrinsic regularization that prevents codebook collapse. To prevent the lattice from becoming infinitely dense, a sparsity loss term is introduced, encouraging the model to use a finite and efficient set of embeddings.
Experimental Results
The architecture was evaluated on standard benchmarks including FFHQ-1024, Celeb-A, and Fashion-MNIST.
Quantitative Performance
On the high-resolution FFHQ-1024 dataset, LL-VQ-VAE demonstrated significant improvements over standard VQ-VAE and its EMA variant:
- Efficiency: Training time was reduced by approximately 65%, dropping from 231 minutes to 79 minutes.
- Fidelity: The Mean Squared Error (MSE) improved from 0.0063 (standard VQ-VAE) to 0.0018.
- Codebook Utilization: While standard VQ-VAE collapsed to using only 36 unique embeddings, LL-VQ-VAE utilized 1,405 unique embeddings, indicating a much richer discrete representation.
Qualitative Analysis
Visual inspections of the reconstructed images confirm that LL-VQ-VAE maintains high-frequency details and color accuracy more effectively than traditional methods.
Discussion and Conclusion
LL-VQ-VAE decouples codebook size from computational speed, allowing for "virtual" codebooks of massive scale without a performance penalty. Furthermore, it is extremely parameter-efficient; for a dimension $D=64$, it requires only 64 parameters for the basis matrix, compared to tens of thousands in a standard lookup table.
Future work includes exploring non-diagonal basis matrices to leverage more efficient lattice geometries, such as hexagonal packing, and investigating the robustness of these representations under various image distortions. Despite the indirect control over the exact number of used embeddings via the sparsity coefficient, LL-VQ-VAE represents a significant step toward more scalable and robust discrete representation learning.
Summary updated