OptVQ: Add a New VQ Method via Optimal Transport #181
+367
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are excited to propose a pull request (PR) for the integration of OptVQ, a new approach to Vector Quantization (VQ) that elegantly tackles the notorious issue of training instability, especially index collapse, by employing optimal transport theory in place of the conventional nearest neighbor search. This method, as described in the research paper "Preventing Local Pitfalls in Vector Quantization via Optimal Transport," remarkably boosts codebook utilization, reaching nearly 100% efficiency in most scenarios without the need for special initialization or additional regularization techniques.
We allow users to activate this feature by simply setting
optimal_transport = True
within the VectorQuantize class. Users can also reach the original code at the GitHub repository zbr17/OptVQ. For those who are curious about the visual impact of OptVQ compared to standard VQ in a 2D context, we have included a notebook that demonstrates this comparison. Additionally, we provide an example of training a VQ-VAE model with OptVQ seamlessly integrated into the framework, showcasing its practical application.We hope that this PR will be well-received and contribute to the community's efforts in advancing vector quantization techniques. Thank you for considering our proposal, and we look forward to any feedback or suggestions you may have.