facebookresearch / Qinco

Residual Quantization with Implicit Neural Codebooks
https://arxiv.org/abs/2401.14732
Other
48 stars 2 forks source link

Quantization with Implicit Neural Codebooks (QINCo)

This code repository corresponds to the ICML'24 paper Residual Quantization with Implicit Neural Codebooks, in which Quantization with Implicit Neural Codebooks (QINCo) was proposed. Please see the paper, or this 5 minute video to learn more about Qinco.

QINCo is a neurally-augmented algorithm for multi-codebook vector quantization, specifically residual quantization (RQ). Instead of using a fixed codebook per quantization step, QINCo uses a neural network to predict a codebook for the next quantization step, conditioned upon the quantized vector so far. In other words, the codebooks to be used depend on the Voronoi cells selected previously. This greatly enhances the capacity of the compression system, without the need to store more codebook vectors explicitly.

An additional advantage of QINCo is its modularity. Thanks to training each quantization step with its own quantization error, the trained system for a certain compression rate, can also be exploited for lower compression rates, making QINCo a dynamic rate quantizer.

In the paper we propose three addtional variants of QINCo:

Find below the documentation on how to use QINCo and its variants:

Instructions for installation of the environment

Downloading data

Using pre-trained QINCo checkpoints for encoding and decoding

Training QINCo(-LR) from scratch

Training PQ-QINCo from scratch

Approximate AQ searching and QINCo re-ranking (Replicating Table 4)

IVF_search

QINCo encoding / decoding is also implemented in Faiss. See a demo here in the Faiss Github: demo_qinco.py.

Citation

If you use QINCo in a research work please cite our paper:

@inproceedings{huijben2024QINco,
  title={Residual Quantization with Implicit Neural Codebooks},
  author={Iris A.M. Huijben and Matthijs Douze and Matthew J. Muckley and Ruud J.G. van Sloun and Jakob Verbeek},
  year={2024},
  booktitle={International Conference on Machine Learning (ICML)},
  url={https://openreview.net/forum?id=NBAc36V00H}
}

Legal

Qinco is licenced under CC-BY-NC, please refer to the LICENSE file in the top level directory.

Copyright © Meta Platforms, Inc. See the Terms of Use and Privacy Policy for this project.