Skip to content

Commit

Permalink
misread
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Nov 7, 2024
1 parent caf11b7 commit 8cbdfb4
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,6 @@ quantized, indices, commit_loss = residual_vq(x)
# (1, 1024, 256), (2, 1, 1024, 8), (2, 1, 8)
```


<a href="https://arxiv.org/abs/2305.05065">This paper</a> out of Google Deepmind claims that residual vector quantization can induce hierarchical semantic ids for building a recommender system. In their scheme, they use increasing number of codes across depth for it to work. This repository supports that scheme as so

```python
import torch
from vector_quantize_pytorch import ResidualVQ

residual_vq = ResidualVQ(
dim = 256,
codebook_size = (5, 128, 256), # from top most hierarchy to lowest, 5 codes, 128 codes, then 256 codes
)

x = torch.randn(2, 16, 256)

quantized, indices, commit_loss = residual_vq(x)

# (2, 16, 256), (2, 16, 3), (2, 3)
```

## Initialization

The SoundStream paper proposes that the codebook should be initialized by the kmeans centroids of the first batch. You can easily turn on this feature with one flag `kmeans_init = True`, for either `VectorQuantize` or `ResidualVQ` class
Expand Down Expand Up @@ -733,14 +714,3 @@ assert loss.item() >= 0
url = {https://api.semanticscholar.org/CorpusID:273229218}
}
```

```bibtex
@article{Rajput2023RecommenderSW,
title = {Recommender Systems with Generative Retrieval},
author = {Shashank Rajput and Nikhil Mehta and Anima Singh and Raghunandan H. Keshavan and Trung Hieu Vu and Lukasz Heldt and Lichan Hong and Yi Tay and Vinh Q. Tran and Jonah Samost and Maciej Kula and Ed H. Chi and Maheswaran Sathiamoorthy},
journal = {ArXiv},
year = {2023},
volume = {abs/2305.05065},
url = {https://api.semanticscholar.org/CorpusID:258564854}
}
```

0 comments on commit 8cbdfb4

Please sign in to comment.