Variable-Bitrate Neural Compression via Bayesian Arithmetic Coding

Yibo Yang, Robert Bamler, Stephan MandtarXiv 2020

Abstract

We propose a novel algorithm for quantizing continuous latent representations in trained models. Our approach applies to deep probabilistic models, such as variational autoencoders (VAEs), and enables both data and model compression. Unlike current end-to-end neural compression methods that cater the model to a fixed quantization scheme, our algorithm separates model design and training from quantization. Consequently, our algorithm enables "plug-and-play" compression with variable rate-distortion trade-off, using a single trained model. Our algorithm can be seen as a novel extension of arithmetic coding to the continuous domain, and uses adaptive quantization accuracy based on estimates of posterior uncertainty. Our experimental results demonstrate the importance of taking into account posterior uncertainties, and show that image compression with the proposed algorithm outperforms JPEG over a wide range of bit rates using only a single standard VAE. Further experiments on Bayesian neural word embeddings demonstrate the versatility of the proposed method.

The Challenge: Fixed-Rate Inefficiency

In deep neural compression, state-of-the-art models are typically "fixed-rate." This necessitates training, storing, and deploying a separate neural network for every desired quality level (bitrate), creating significant storage and deployment overhead. Furthermore, standard quantization methods often treat every dimension of a model's internal representation as equally important, failing to account for the fact that some features are critical for reconstruction while others are noisy or redundant.

Variational Bayesian Quantization (VBQ)

The authors introduce Variational Bayesian Quantization (VBQ), a method that bridges the gap between Variational Inference (VI) and Arithmetic Coding (AC). VBQ generalizes traditional arithmetic coding to the continuous domain by using the Prior Cumulative Distribution Function (CDF) to map continuous latent variables into the $[0, 1]$ interval space.

Illustration of VBQ: Mapping continuous latents to discrete codes via the prior CDF and posterior uncertainty.

The core innovation lies in Posterior-Informed Quantization. Instead of using a fixed grid, VBQ leverages the variational posterior—the model's estimate of uncertainty. If the model is uncertain about a latent variable (high variance), VBQ represents it with a shorter, "blurry" bitstring. This rate-distortion trade-off is controlled by a single penalty parameter, $\lambda$, which can be adjusted at test-time to change the compression level instantly without retraining.

Key Insights

  • Anisotropy Awareness: Latent spaces are often "stretched," with the model being more sensitive to changes in certain directions. VBQ naturally adapts to this anisotropy, allocating more bits to sensitive directions.
  • Automatic Self-Pruning: VBQ handles "posterior collapse" gracefully by assigning near-zero bits to useless latent dimensions, effectively pruning the model during compression.
  • Sharpness over Blockiness: Unlike JPEG's blocky artifacts, VBQ-compressed images remain sharp at low bitrates by replacing specific details with "average" features from the learned prior.
  • Decoupled Training: By separating training from compression, VBQ allows the use of off-the-shelf probabilistic models as a post-processing step.

Key Results

The authors evaluated VBQ on image compression (Kodak dataset) and model compression (Bayesian neural word embeddings).

VBQ performance on Bayesian word embeddings compared to baselines.

On the Kodak dataset, a single VAE using VBQ outperformed JPEG across a wide range of bitrates in terms of PSNR and MS-SSIM. For Bayesian word embeddings, VBQ achieved the same accuracy as standard uniform quantization but at less than half the bitrate. Most significantly, these results were achieved using a single set of model weights, demonstrating unprecedented versatility.

Conclusion and Future Directions

While VBQ outperforms JPEG, it still performs slightly below "end-to-end" neural compression models optimized for a single fixed bitrate. Future improvements could involve relaxing the "mean-field" assumption to incorporate correlations between latent variables, further improving compression density. Additionally, as Variational Inference techniques improve, the quality of the posterior will directly enhance VBQ's performance.

Summary updated

BibTeX
@misc{yang2020variable,
  author = {Yibo Yang and Robert Bamler and Stephan Mandt},
  title = {{Variable-Bitrate Neural Compression via Bayesian Arithmetic Coding}},
  year = {2020},
  eprint = {2002.08158},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2002.08158},
}
Figure