Improve model card: Add audio pipeline tag and comprehensive details
#2
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,3 +1,108 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: mit
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
pipeline_tag: audio-to-audio
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# SimVQ: Addressing Representation Collapse in Vector Quantized Models with One Linear Layer
|
| 7 |
+
|
| 8 |
+
<h5 align="center">
|
| 9 |
+
|
| 10 |
+
[](https://huggingface.co/papers/2411.02038)
|
| 11 |
+
[](https://github.com/youngsheen/SimVQ)
|
| 12 |
+
|
| 13 |
+
</h5>
|
| 14 |
+
|
| 15 |
+
## Introduction
|
| 16 |
+
Vector Quantization (VQ) is essential for discretizing continuous representations in unsupervised learning but suffers from representation collapse, causing low codebook utilization and limiting scalability. Existing solutions often rely on complex optimizations or reduce latent dimensionality, which compromises model capacity and fails to fully solve the problem.
|
| 17 |
+
|
| 18 |
+
This paper introduces **SimVQ**, a novel approach that reparameterizes code vectors through a learnable linear transformation layer over a latent basis, optimizing the *entire linear space* rather than nearest *individual code vectors*. Although the multiplication of two linear matrices is equivalent to applying a single linear layer, this simple approach effectively prevents collapse. Extensive experiments on image and audio tasks demonstrate that SimVQ improves codebook usage, is easy to implement, and generalizes well across modalities and architectures.
|
| 19 |
+
|
| 20 |
+
For more details on the method and implementation, please refer to the official resources:
|
| 21 |
+
- Paper: [Addressing Representation Collapse in Vector Quantized Models with One Linear Layer](https://huggingface.co/papers/2411.02038)
|
| 22 |
+
- Code: [https://github.com/youngsheen/SimVQ](https://github.com/youngsheen/SimVQ)
|
| 23 |
+
|
| 24 |
+
## Algorithm for SimVQ
|
| 25 |
+
The core idea of SimVQ is to reparameterize code vectors through a learnable linear transformation layer over a latent basis.
|
| 26 |
+
You can find the core code here: [https://github.com/youngsheen/SimVQ/blob/main/taming/modules/vqvae/quantize.py#L28-L33](https://github.com/youngsheen/SimVQ/blob/main/taming/modules/vqvae/quantize.py#L28-L33)
|
| 27 |
+
|
| 28 |
+
<p align="center">
|
| 29 |
+
<img src="https://github.com/youngsheen/SimVQ/raw/main/assets/Algorithm.png">
|
| 30 |
+
</p>
|
| 31 |
+
|
| 32 |
+
## Quantitative Comparison
|
| 33 |
+
|
| 34 |
+
**Table 1.** Reconstruction performance of different tokenizers on $128 \times 128$ ImageNet 50k validation set.
|
| 35 |
+
| Method | Codebook Size | Codebook Utilization | rFID | LPIPS | PSNR | SSIM | Checkpoint |
|
| 36 |
+
|:------:|:-------------:|:----:|:----:|:---------------------:|:----:|:----:|:----:|
|
| 37 |
+
|VQGAN | 65,536 | 1.4% | 3.74 | 0.17 | 22.20 | 70.6 | -|
|
| 38 |
+
|VQGAN | 65,536 | 4.5% | 3.23 | 0.15 | 22.89 | 72.3 | -|
|
| 39 |
+
|VQGAN-FC | 65,536 | 100.0% | 2.63 | 0.13 | 23.79 | 77.5 | - |
|
| 40 |
+
|FSQ | 64,000 | 100.0% | 2.80 | 0.13| 23.63 | 75.8 | - |
|
| 41 |
+
|LFQ | 65,536 | 100.0% | 2.88 | 0.13| 23.60 | 77.2 | - |
|
| 42 |
+
|VQGAN-LC | 65,536 | 100.0% | 2.40 | 0.13 | 23.98 | 77.3 | - |
|
| 43 |
+
|SimVQ (ours) | 1024 | 100.0% | 3.67 | 0.16 | 22.34 | 70.8 | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_log/simvq_1k) |
|
| 44 |
+
|SimVQ (ours) | 8192 | 100.0% | 2.98 | 0.14 | 23.23 | 74.7 | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_log/simvq_8k) |
|
| 45 |
+
|SimVQ (ours) | 65,536 | 100.0% | **2.24** | **0.12** | **24.15** | **78.4** | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_log/simvq_65k) |
|
| 46 |
+
|SimVQ (ours) | 262,144 | 100.0% | **1.99** | **0.11** | **24.68** | **80.3** | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_log/simvq_262k) |
|
| 47 |
+
|
| 48 |
+
**Table 2.** Reconstruction performance of different tokenizers on LibriTTS test clean/other set.
|
| 49 |
+
|
| 50 |
+
| Method | Bandwidth | Codebook Utilization | UTMOS | PESQ | STOI | V/UV F1 | Checkpoint |
|
| 51 |
+
|:------:|:-------------:|:----:|:----:|:---------------------:|:----:|:----:|:----:|
|
| 52 |
+
|Encodec | 3.0kbps | -/-% | 2.31/2.09 | 2.05/2.05 | 0.90/0.88 | 0.92/0.89 | - |
|
| 53 |
+
|Vocos | 3.0kbps | -/-% | 3.53/3.06 | 2.40/2.19 | 0.92/0.90 | 0.94/0.91 | - |
|
| 54 |
+
|SpeechTokenizer | 3.0kbps | -/-% | 3.56/3.02 | 1.93/1.74 | 0.88/0.84 | 0.93/0.89 | - |
|
| 55 |
+
|WavTokenizer | 0.9kbps | 100/100% | 3.74/3.43 | 2.01/2.26 | 0.89/0.89 | 0.92/0.92 | - |
|
| 56 |
+
|WavTokenizer | 1.05kbps | 27/-% | 4.00/- | 2.36/- | 0.81/- | 0.94/- | - |
|
| 57 |
+
|SimVQ (ours) | 0.9kbps | 100.0/100.0% | 4.00/3.51 | 2.33/2.08 | 0.91/0.88 | 0.94/0.91 | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_audio_log/simvq_4k) |
|
| 58 |
+
|SimVQ (ours) | 0.975kbps | 99.4/99.4% | 4.03/3.52 | 2.42/2.15 | 0.92/0.88 | 0.94/0.92 | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_audio_log/simvq_8k) |
|
| 59 |
+
|SimVQ (ours) | 1.2kbps | 99.4/99.0% | 4.03/3.52 | 2.54/2.26 | 0.93/0.90 | 0.94/0.92 | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_audio_log/simvq_65k) |
|
| 60 |
+
|SimVQ (ours) | 1.35kbps | 95.6/94.7% | 4.03/3.53 | 2.61/2.31 | 0.93/0.90 | 0.95/0.93 | [huggingface](https://huggingface.co/zyx123/SimVQ/tree/main/vq_audio_log/simvq_262k) |
|
| 61 |
+
|
| 62 |
+
## Implementations
|
| 63 |
+
For detailed instructions on installation, training, and evaluation scripts, please refer to the [GitHub repository](https://github.com/youngsheen/SimVQ).
|
| 64 |
+
|
| 65 |
+
### Installation
|
| 66 |
+
- **Dependencies**: `pip install -r requirements.txt`
|
| 67 |
+
- **Extra dependencies for audio evaluation**: `pip install -r requirements_audio.txt`
|
| 68 |
+
|
| 69 |
+
### Training Scripts
|
| 70 |
+
Example scripts are provided for:
|
| 71 |
+
* Image Tokenizer Training (`configs/imagenet_simvq_128_B.yaml`)
|
| 72 |
+
* Audio Tokenizer Training (`configs/libritts_24khz.yaml`)
|
| 73 |
+
|
| 74 |
+
**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.
|
| 75 |
+
|
| 76 |
+
### Evaluation Scripts
|
| 77 |
+
Example scripts are provided for:
|
| 78 |
+
* Image Tokenizer Evaluation
|
| 79 |
+
* Audio Tokenizer Evaluation
|
| 80 |
+
|
| 81 |
+
## Reconstruction Visualization
|
| 82 |
+
|
| 83 |
+
**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.
|
| 84 |
+
<p align="center">
|
| 85 |
+
<img src="https://github.com/youngsheen/SimVQ/raw/main/assets/case_image.png">
|
| 86 |
+
</p>
|
| 87 |
+
|
| 88 |
+
**Figure 3.** Visualization of the Open-MAGVIT2 tokenizer trained at LibriTTS (`libritts_24khz` version). (a) indicates the original audio spectrograms while (b) specifies the reconstruction spectrograms.
|
| 89 |
+
<p align="center">
|
| 90 |
+
<img src="https://github.com/youngsheen/SimVQ/raw/main/assets/case_audio.png">
|
| 91 |
+
</p>
|
| 92 |
+
|
| 93 |
+
## Acknowledgement
|
| 94 |
+
The codebase of SimVQ is adapted from [Open-MAGVIT2](https://github.com/TencentARC/Open-MAGVIT2) and [WavTokenizer](https://github.com/jishengpeng/WavTokenizer). Thanks for their wonderful work.
|
| 95 |
+
|
| 96 |
+
## Citation
|
| 97 |
+
If you find our work helpful or inspiring, please feel free to cite it.
|
| 98 |
+
```bibtex
|
| 99 |
+
@misc{zhu2024addressing,
|
| 100 |
+
title={Addressing Representation Collapse in Vector Quantized Models with One Linear Layer},
|
| 101 |
+
author={Yongxin Zhu and Bocheng Li and Hang Zhang and Xin Li and Linli Xu and Lidong Bing},
|
| 102 |
+
year={2024},
|
| 103 |
+
eprint={2411.02038},
|
| 104 |
+
archivePrefix={arXiv},
|
| 105 |
+
primaryClass={cs.LG},
|
| 106 |
+
url={https://arxiv.org/abs/2411.02038},
|
| 107 |
+
}
|
| 108 |
+
```
|