Representation Collapsing Problems in Vector Quantization

Wenhao Zhao, Qiran Zou, Rushi Shah, Dianbo Liu

TL;DR

This paper tackles the critical but underexplored issue of "representation collapse" in Vector Quantization (VQ), a key technique for discretizing data in generative models. The authors identify two main types of collapse—token collapse and embedding collapse—and propose effective pretraining-based solutions to mitigate them, leading to more diverse and accurate representations.

What Problem Does This Paper Address?

Vector Quantization (VQ) is a powerful technique for converting continuous data representations into discrete tokens, essential for models like large language models and diffusion models. However, VQ can suffer from "representation collapse," where the learned discrete representations become degenerate. This leads to a loss of diversity and accuracy in generated outputs. The paper specifically addresses two forms of this collapse:

  1. Tokens Collapse: A situation where a disproportionate number of input data points are mapped to only a few discrete tokens (codebook entries), leaving many tokens unused and failing to capture the full diversity of the data.
  2. Embeddings Collapse: Where the continuous representations produced by the encoder cluster too closely together, even after quantization, leading to a limited set of learned embeddings and a loss of fine-grained information.

These issues hinder the effectiveness and scalability of VQ in various machine learning applications.

Methods

The authors systematically investigate the causes of representation collapse and propose solutions.

  • Identifying Collapse Types: They categorize collapses into "Tokens Collapse" and "Embeddings Collapse," providing visual and conceptual explanations for each.
  • Analyzing Causes:
    • For Tokens Collapse, they identify that initializing VQ codebooks using the output of an untrained encoder is a primary cause. This untrained encoder produces clustered, semantically undifferentiated embeddings, leading to tokens that also cluster.
  • For Embeddings Collapse, they hypothesize that insufficient encoder capacity (i.e., too few parameters) leads to the encoder failing to learn distinct representations, causing them to collapse.
  • Proposed Solution (Tokens Collapse): A key contribution is a pretraining strategy. Instead of directly training a VQ-VAE, they first pretrain an autoencoder (without VQ). This autoencoder learns to produce semantically meaningful and dispersed embeddings. The VQ-VAE is then initialized with the weights of this pretrained autoencoder, allowing for a more robust initialization of tokens and mitigating tokens collapse.
  • Proposed Solution (Embeddings Collapse): For embeddings collapse, the solution is straightforward: ensure the encoder has sufficient capacity (e.g., by increasing its hidden layer size).

Datasets

The authors use both synthetic and real-world datasets for their experiments:

  • Synthetic Dataset: A custom dataset with 10 clusters, each containing 1,000 data points sampled from a Gaussian distribution. This dataset is generated in various dimensions (2, 3, 4, and 8) to study the impact of data complexity.
  • Real-world Dataset: CIFAR-10, a standard benchmark dataset for image classification, consisting of 60,000 32x32 color images across 10 classes.

Key Insights and Ideas

  • Two Faces of Collapse: The paper clearly delineates two distinct but related problems in VQ: tokens collapse (codebook underutilization) and embeddings collapse (encoder output degeneracy). This provides a more nuanced understanding of VQ limitations.
  • The Peril of Untrained Initialization: A crucial insight is that initializing VQ codebooks directly from an untrained encoder's output is a recipe for tokens collapse. The encoder needs to "understand" the data's semantics before quantization to guide token assignment effectively.
  • Pretraining as a Panacea for Token Collapse: The proposed pretraining strategy (pretrain without VQ, then fine-tune with VQ) is shown to be highly effective. It leverages the semantic learning of an autoencoder to provide a much better starting point for VQ.
  • Encoder Capacity is Key for Embeddings: The paper reinforces a fundamental machine learning principle: model capacity matters. Insufficient encoder capacity directly leads to embeddings collapse, highlighting the importance of appropriate model design.

Key Results

  • Tokens Collapse Mitigation: Experiments on both synthetic and CIFAR-10 datasets demonstrate that the proposed pretraining solution significantly reduces tokens collapse, leading to more uniform token distribution and improved reconstruction quality compared to standard VQ-VAE. For instance, on CIFAR-10, the pretrained VQ-VAE shows continually decreasing MSE and increasing perplexity as token numbers increase, while the original VQ-VAE stagnates due to collapse.
  • Embeddings Collapse Prevention: Experiments show that increasing the encoder's hidden size (e.g., from 4 to 32 on synthetic data) effectively prevents embeddings collapse, leading to better reconstruction and more distinct embeddings. On CIFAR-10, reducing encoder capacity leads to increased MSE, confirming the link to embeddings collapse.
  • Scalability: The pretraining solution shows effectiveness across various input and token dimensions, suggesting its general applicability.

Limitations and Future Work

  • Representation Gap: The authors acknowledge a potential "representation gap" that might arise from the transition between the continuous representations learned during pretraining and the discrete representations during VQ fine-tuning. They suggest this is a worthy avenue for further investigation.
  • Generative Models: While the paper focuses on VQ itself, they plan to explore the impact and solutions for these collapses in larger generative models like LLMs and diffusion models in future work.
  • Specific Applications: For practical VQ applications, they suggest ensuring sufficient encoder capacity as a guiding principle to avoid embeddings collapse.

Summary updated

BibTeX
@inproceedings{zhao2024representation,
  author = {Wenhao Zhao and Qiran Zou and Rushi Shah and Dianbo Liu},
  title = {{Representation Collapsing Problems in Vector Quantization}},
  booktitle = {SafeGenAi @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=2aOEiTfcZ4},
}
Figure