TL;DR
This paper formalizes the connection between Vector Quantized Autoencoders (VQ-VAEs) and the Expectation-Maximization (EM) algorithm, introducing a novel "Soft EM" training framework. By replacing VQ-VAE's hard nearest-neighbor lookups with a probabilistic mixture via Monte Carlo sampling, the authors achieve more robust training, improved image generation, and a non-autoregressive machine translation model that nearly matches a strong autoregressive Transformer while delivering a 3.3x speedup at inference.
What Problem Does This Paper Address?
While continuous representations are the standard workhorse of deep learning, many real-world modalities—like language, speech, and structured reasoning—are inherently discrete. Discrete latent variable models offer better interpretability and data compression, but training them is notoriously difficult due to the non-differentiable nature of discrete bottlenecks.
The Vector Quantized Variational Autoencoder (VQ-VAE) bypassed this issue using a learned codebook and a hard nearest-neighbor lookup. However, VQ-VAE training can be unstable, often requiring complex heuristics like exponential moving averages (EMA) or product quantization to prevent "codebook collapse" (where only a few latent codes are ever used). This paper aims to put VQ-VAE on a firmer theoretical foundation and introduce a more robust, principled training algorithm.
Methods
The authors first demonstrate that standard VQ-VAE training is mathematically equivalent to a Hard EM or $K$-means clustering algorithm, where the encoder outputs act as data points and the codebook vectors act as cluster centers.
To improve on this, they propose Soft EM training using Monte-Carlo Expectation Maximization:
- E-step: Instead of deterministically picking the single closest codebook vector (hard assignment), the model defines a categorical distribution over all codebook vectors based on their $\ell_2$ distance to the encoder output. It then draws $m$ samples from this distribution.
- Decoder Input: The average of these $m$ sampled embeddings is passed to the decoder, allowing gradients to flow to multiple codebook vectors simultaneously during the backward pass.
- M-step: The codebook embeddings are updated using an EMA version of the cluster center updates.
For conditional tasks like machine translation, they combine this Soft EM VQ-VAE architecture with sequence-level knowledge distillation, training the non-autoregressive model on the outputs of a strong autoregressive teacher Transformer.
Datasets
The authors evaluated their approach on two standard benchmarks:
- CIFAR-10: Used for unconditional image generation.
- WMT'14 English-to-German: Used for conditional supervised machine translation.
Key Insights and Ideas
- VQ-VAE is Secretly Clustering: Showing that VQ-VAE updates converge to the M-step of a $K$-means style algorithm clarifies why it works and provides a framework for improvement.
- Soft EM Prevents Collapse: Hard EM is prone to bad local minima where cluster assignments collapse. By sampling from a distribution (Soft EM), the model explores the codebook space more effectively, leading to highly stable training.
- Architecture Simplification: The authors found that a previous state-of-the-art discrete translation model (the Latent Transformer) included an unnecessary attention step between the autoencoder's encoder and the source sentence. Removing this step actually stabilized training for large codebooks.
Key Results
Machine Translation (WMT'14 En-De)
- The Soft EM VQ-VAE combined with knowledge distillation achieved a 26.7 BLEU score.
- This nearly matches the performance of a strong greedy autoregressive Transformer baseline (27.0 BLEU), but runs 3.3x faster at inference because it generates the target sentence in parallel rather than token-by-token.
- Tuning the codebook size to $2^{12}$ vectors yielded the best results, significantly outperforming the $2^{16}$ size used in prior work.
Image Generation (CIFAR-10)
- The Soft EM model achieved a negative log-likelihood of 4.80 bits/dim, outperforming the baseline VQ-VAE's score of 4.83 bits/dim and producing high-quality image reconstructions.
Limitations and Future Work
While Soft EM improves stability and performance, drawing $m$ Monte Carlo samples introduces a minor computational overhead during the forward and backward training passes (though inference remains unaffected). Additionally, while the model successfully closes the gap with greedy autoregressive models, it still lags slightly behind autoregressive models using beam search (which achieve 28.1 BLEU on the translation task). Future work could explore scaling this method to larger datasets or optimizing the sampling efficiency.
Summary updated