SimVQ: Addressing Representation Collapse in Vector Quantized Models with One Linear Layer

December 5, 2024 · View on GitHub

arXiv

News

  • Checkpoints are released.
Some other projects about Discrete Tokenizer based Multimodal GenAI from our team may interest you.

[NeurIPS 2024] Stabilize the Latent Space for Image Autoregressive Modeling: A Unified Perspective
Yongxin Zhu, Bocheng Li, Hang Zhang, Xin Li, Linli Xu, Lidong Bing
github github arXiv

[ACL 2024] Generative Pre-Trained Speech Language Model with Efficient Hierarchical Transformer
Yongxin Zhu, Dan Su, Liqiang He, Linli Xu, Dong Yu
github github arXiv (Adopted by Moshi)

[EMNLP 2023] DiffS2UT: A Semantic Preserving Diffusion Model for Textless Direct Speech-to-Speech Translation
Yongxin Zhu, Zhujin Gao, Xinyuan Zhou, Zhongyi Ye, Linli Xu
arXiv

Algorithm for SimVQ

You can find the core code here https://github.com/youngsheen/SimVQ/blob/main/taming/modules/vqvae/quantize.py#L28-L33

Note: Optimizing both the codebook C and the linear layer W can work as well.

Quantitative Comparison

Table 1. Reconstruction performance of different tokenizers on $128 \times 128$ ImageNet 50k validation set.

MethodCodebook SizeCodebook UtilizationrFIDLPIPSPSNRSSIMCheckpoint
VQGAN65,5361.4%3.740.1722.2070.6-
VQGAN65,5364.5%3.230.1522.8972.3-
VQGAN-FC65,536100.0%2.630.1323.7977.5-
FSQ64,000100.0%2.800.1323.6375.8-
LFQ65,536100.0%2.880.1323.6077.2-
VQGAN-LC65,536100.0%2.400.1323.9877.3-
SimVQ (ours)1024100.0%3.670.1622.3470.8huggingface
SimVQ (ours)8192100.0%2.980.1423.2374.7huggingface
SimVQ (ours)65,536100.0%2.240.1224.1578.4huggingface
SimVQ (ours)262,144100.0%1.990.1124.6880.3huggingface

Table 2. Reconstruction performance of different tokenizers on LibriTTS test clean/other set.

MethodBandwidthCodebook UtilizationUTMOSPESQSTOIV/UV F1Checkpoint
Encodec3.0kbps-/-%2.31/2.092.05/2.050.90/0.880.92/0.89-
Vocos3.0kbps-/-%3.53/3.062.40/2.190.92/0.900.94/0.91-
SpeechTokenizer3.0kbps-/-%3.56/3.021.93/1.740.88/0.840.93/0.89-
WavTokenizer0.9kbps100/100%3.74/3.432.01/2.260.89/0.890.92/0.92-
WavTokenizer1.05kbps27/-%4.00/-2.36/-0.81/-0.94/--
SimVQ (ours)0.9kbps100.0/100.0%4.00/3.512.33/2.080.91/0.880.94/0.91huggingface
SimVQ (ours)0.975kbps99.4/99.4%4.03/3.522.42/2.150.92/0.880.94/0.92huggingface
SimVQ (ours)1.2kbps99.4/99.0%4.03/3.522.54/2.260.93/0.900.94/0.92huggingface
SimVQ (ours)1.35kbps95.6/94.7%4.03/3.532.61/2.310.93/0.900.95/0.93huggingface

Implementations

Installation

  • Dependencies: pip install -r requirements.txt
  • Extra dependencies for audio evaluation: pip install -r requirements_audio.txt
  • Datasets
imagenet
└── train/
    ├── n01440764
        ├── n01440764_10026.JPEG
        ├── n01440764_10027.JPEG
        ├── ...
    ├── n01443537
    ├── ...
└── val/
    ├── ...
LibriTTS
└── train-clean-100/
    ├── 103/
        ├── 1241/
            ├── 103_1241_000000_000001.wav
            ├── ...
    ├── 1034
    ├── ...
└── train-clean-360/
    ├── ...
└── train-other-500/
    ├── ...
└── dev-other/
    ├── ...
└── dev-clean/
    ├── ...
└── test-other/
    ├── ...
└── test-clean/
    ├── ...

Training Scripts

  • Image Tokenizer Training
XDG_CACHE_HOME="dataset/ILSVRC2012" python main.py fit --config configs/imagenet_simvq_128_B.yaml
  • Audio Tokenizer Training

You can get manifest .txt with generate_manifest.py

DATA_ROOT="/data3/yongxinzhu/libritts/LibriTTS" CUDA_VISIBLE_DEVICES=4,5,6,7 python main.py fit --config configs/libritts_24khz.yaml

Note: Some users have reported encountering NaN issues when training SimVQ on audio data. This appears to be a random occurrence, but we have found that using learning rate warmup can help mitigate the problem.

Evaluation Scripts

  • Image Tokenizer Evaluation
XDG_CACHE_HOME="dataset/ILSVRC2012" python evaluation.py --config_file vq_log/simvq_262k/size128/config.yaml --ckpt_path vq_log/simvq_262k/epoch=49-step=250250.ckpt
  • Audio Tokenizer Evaluation
DATA_ROOT="dataset/libritts" python evaluation_speech.py --config_file vq_audio_log/simvq_262k/1second/config.yaml --ckpt_path vq_audio_log/simvq_262k/epoch=49-step=138600.ckpt

Reconstruction Visualization

Figure 2. Visualization of the Open-MAGVIT2 tokenizer trained at $128 \times 128$ resolution (imagenet_simvq_128_Base version). (a) indicates the original images while (b) specifies the reconstruction images.

Figure 3. Visualization of the Open-MAGVIT2 tokenizer trained at LibriTTS (libritts_24khz version). (a) indicates the original images while (b) specifies the reconstruction images.

Acknowledgement

The codebase of SimVQ is adapted from Open-MAGVIT2 and WavTokenizer. Thanks for their wonderful work.