Pyramid Product Quantization for Approximate Nearest Neighbor Search
Abstract
1. Introduction
2. Related Works
2.1. Vector Quantization (VQ)
2.2. Product Quantization (PQ)
3. The Proposed Pyramid Product Quantization (PPQ)
3.1. Motivation
3.2. Pyramid Encoding Structure
3.3. Database Encoding Strategy
- (1)
- In the product quantizer with M subspaces, is split between the 2i-th and (2i + 1)-th subspaces. The squared quantization error in this subspace is given as follows:
- (2)
- In the product quantizer with M/2 subspaces, resides entirely within the i-th subspace. The squared quantization error in these two subspaces is given as follows:
| Algorithm 1 Encoding the database vectors |
Input:
|
| 1. Output: 2. Indexes for the database vector = {, where ; the encoding pattern vector . 3. Initialize encoding pattern as a M-dimensional zero vector. 4. for do 5. for do 6. Decompose into sub-vectors ; 7. for do 8. Quantize with to obtain the PQ index and the squared quantization error ; 9. end for 10. end for 11. for do 12. for do 13. if 14. 15. end if 16. end for 17. end for 18. Return the indexes and the encoding pattern vector . |
3.4. Encoding and Searching Process
| Algorithm 2 Process of ANN search |
Input:
|
| Output: Top R nearest neighbors of in database. 1. for do 2. Decompose into sub-vectors ; 3. for do 4. Calculate the distance between and the codewords in . 5. end for 6. Build the look-up table by using the distances. 7. end for 8. for do 9. Read the n-th pattern vectors . 10. Initialize the squared distance between q and 11. for do 12. Read the squared distances from the entry in row , column of the look-up table ; 13. ; 14. end for 15. end for 16. Rank the database vectors in ascending order in terms of ; 17. Return R nearest neighbors of . |
4. Experiments
4.1. Setup
4.2. Experimental Results
4.3. Discussions
5. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
Abbreviations
| VQ | Vector quantization |
| PQ | Product quantization |
| ANN | Approximate nearest neighbor |
| ADC | Asymmetric distance computation |
References
- J’egou, H.; Douze, M.; Schmid, C. Product quantization for nearest neighbor search. IEEE Trans. Pattern Anal. Mach. Intell. 2018, 33, 117–128. [Google Scholar] [CrossRef] [PubMed]
- Sarwar, B.; Karypis, G.; Konstan, J.; Riedl, J. Item-based collaborative filtering recommendation algorithms. In Proceedings of the 10th International Conference on World Wide Web, Hong Kong, 1–5 May 2001. [Google Scholar]
- Ning, Q.; Zhu, J.; Zhong, Z.; Hoi, S.C.; Chen, C. Scalable image retrieval by sparse product quantization. IEEE Trans. Multimed. 2017, 19, 586–597. [Google Scholar] [CrossRef]
- Nister, D.; Stewenius, H. Scalable recognition with a vocabulary tree. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, New York, NY, USA, 17–22 June 2006. [Google Scholar]
- Wu, Z.; Yu, J. Vector quantization: A review. Front. Inf. Technol. Electron. Eng. 2019, 20, 507–524. [Google Scholar] [CrossRef]
- Babenko, A.; Lempitsky, V. Additive quantization for extreme vector compression. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Columbus, OH, USA, 23–28 June 2014. [Google Scholar]
- Wang, J.; Zhang, T. Composite quantization. IEEE Trans. Pattern Anal. Mach. Intell. 2018, 41, 1308–1322. [Google Scholar] [CrossRef] [PubMed]
- Zhang, T.; Qi, G.-J.; Tang, J.; Wang, J. Sparse composite quantization. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Boston, MA, USA, 7–12 June 2015. [Google Scholar]
- Brandt, J. Transform coding for fast approximate nearest neighbor search in high dimensions. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, San Francisco, CA, USA, 13–18 June 2010. [Google Scholar]
- Heo, J.-P.; Lin, Z.; Yoon, S.-E. Distance encoded product quantization for approximate k-nearest neighbor search in high-dimensional space. IEEE Trans. Pattern Anal. Mach. Intell. 2018, 41, 2084–2097. [Google Scholar] [CrossRef] [PubMed]
- Matsui, Y.; Uchida, Y.; J’egou, H.; Satoh, S. A survey of product quantization. ITE Trans. Media Technol. Appl. 2018, 6, 2–10. [Google Scholar] [CrossRef]
- Lowe, D.G. Distinctive image features from scale-invariant keypoints. Int. J. Comput. Vis. 2004, 60, 91–110. [Google Scholar] [CrossRef]
- Oliva, A.; Torralba, A. Modeling the shape of the scene: A holistic representation of the spatial envelope. Int. J. Comput. Vis. 2001, 42, 145–175. [Google Scholar] [CrossRef]
- Ge, T.; He, K.; Ke, Q.; Sun, J. Optimized product quantization. IEEE Trans. Pattern Anal. Mach. Intell. 2014, 36, 744–755. [Google Scholar] [CrossRef] [PubMed]
- Yang, J.; Chen, B.; Xia, S.-T. Mean-removed product quantization for large-scale image retrieval. Neurocomputing 2020, 406, 77–88. [Google Scholar] [CrossRef]



| Operation | Addition | Multiplication |
|---|---|---|
| Build squared-distance look-up tables | ||
| Computing the ADC (asymmetric distance computation) distances |
| Dataset | SIFT1M | GIST1M |
|---|---|---|
| Descriptor dimensionality D | 128 | 960 |
| Learning set size | 100,000 | 500,000 |
| Database set size | 1,000,000 | 1,000,000 |
| Query set size | 10,000 | 1000 |
| Dataset | SIFT1M | GIST1M | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Sub-codebook Size kp | 1024 | 2048 | 4096 | 8192 | 16,384 | 512 | 1024 | 2048 | 4096 | 8192 |
| Replacement ratio (%) | 35.24 | 55.90 | 73.61 | 88.51 | 98.99 | 53.73 | 68.01 | 75.68 | 88.88 | 94.14 |
| Dataset | SIFT1M | GIST1M | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Sub-codebook Size kp | 2048 | 4096 | 8192 | 16,384 | 32,768 | 1024 | 2048 | 4096 | 8192 | 16,384 |
| Replacement ratio (%) | 0.19 | 0.45 | 0.98 | 1.49 | 2.32 | 0.10 | 0.35 | 0.88 | 1.62 | 2.40 |
| Sub-codebook size kp | 1024 | 2048 | 4096 | 8192 | 16,384 | Baseline of PQ (M = 8, k = 256) |
| Replacement ratio (%) | 35.24 | 55.90 | 73.61 | 88.51 | 98.99 | 0 |
| Recall@1 | 26.30 | 26.71 | 26.49 | 26.68 | 26.61 | 26.56 |
| Recall@10 | 62.41 | 62.36 | 62.43 | 62.30 | 62.19 | 62.28 |
| Recall@100 | 92.49 | 92.70 | 92.45 | 92.45 | 92.53 | 92.50 |
| Sub-codebook size kp | 512 | 1024 | 2048 | 4096 | 8192 | Baseline of PQ (M = 8, k = 256) |
| Replacement ratio (%) | 53.73 | 68.01 | 75.68 | 88.88 | 94.14 | 0 |
| Recall@1 | 9.18 | 9.33 | 9.26 | 9.29 | 9.24 | 9.23 |
| Recall@10 | 18.83 | 18.97 | 18.89 | 18.75 | 18.93 | 18.89 |
| Recall@100 | 43.68 | 43.67 | 43.86 | 43.80 | 43.85 | 43.91 |
| Sub-codebook size kp | 1024 | 2048 | 4096 | 8192 | 16,384 | Baseline of PQ (M = 8, k = 256) |
| Replacement ratio (%) | 35.24 | 55.90 | 73.61 | 88.51 | 98.99 | N/A |
| Time required to build ADC look-up tables (ms) | 757 | 1239 | 2109 | 3674 | 6924 | 241 |
| Time required to compute ADC distances. | 12,524 | 11,426 | 10,701 | 10,562 | 10,596 | 15,125 |
| Total time (ms) | 13,281 | 12,665 | 12,810 | 14,236 | 17,520 | 15,366 |
| Method | Recall@100 | Build Look-Up Table (ms) | ADC Distance Computation (ms) | Other Operations (ms) | Total Time (ms) |
|---|---|---|---|---|---|
| PQ (M = 8, k = 256) | 92.50 | 241 | 15,125 | 0 | 15,366 |
| OPQ (M = 8, k = 256) | 94.01 | 249 | 15,817 | 2505 | 18,571 |
| MRPQ (M = 8, k = 256) | 96.51 | 247 | 15,698 | 6043 | 21,988 |
| PPQ-PQ (k1 = 256, k2 = 2048) | 92.70 | 1239 | 11,426 | 0 | 12,665 |
| PPQ-OPQ (k1 = 256, k2 = 2048) | 93.87 | 1257 | 11,378 | 3989 | 16,624 |
| PPQ-MRPQ (k1 = 256, k2 = 2048) | 96.49 | 1233 | 11,616 | 6945 | 19,794 |
| Method | Recall@100 | Build Look-Up Table (ms) | ADC Distance Computation (ms) | Other Operations (ms) | Total Time (ms) |
|---|---|---|---|---|---|
| PQ (M = 8, k = 256) | 43.91 | 1008 | 15,069 | 0 | 16,077 |
| OPQ (M = 8, k = 256) | 45.99 | 1071 | 14,898 | 4650 | 20,619 |
| MRPQ (M = 8, k = 256) | 47.06 | 1116 | 15,133 | 7722 | 23,971 |
| PPQ-PQ (k1 = 256, k2 = 1024) | 43.68 | 4068 | 10,942 | 0 | 15,010 |
| PPQ-OPQ (k1 = 256, k2 = 1024) | 46.12 | 4135 | 10,570 | 5569 | 20,274 |
| PPQ-MRPQ (k1 = 256, k2 = 1024) | 47.01 | 4084 | 10,845 | 8061 | 22,990 |
| Sub-codebook size kp | 512 | 1024 | 2048 | 4096 | 8192 | Baseline of PQ (M = 8, k = 256) |
| Replacement ratio (%) | 56.73 | 68.01 | 75.68 | 88.88 | 94.14 | N/A |
| Time required to build ADC look-up tables (ms) | 2609 | 4068 | 6944 | 12,844 | 24,421 | 1008 |
| Time required to compute ADC distances | 12,534 | 10,942 | 10,339 | 9345 | 8845 | 15,069 |
| Total time (ms) | 15,143 | 15,010 | 17,283 | 22,189 | 33,266 | 16,077 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Wang, Y.; Yu, L.; Zhang, J.; Zhang, Q. Pyramid Product Quantization for Approximate Nearest Neighbor Search. Appl. Sci. 2026, 16, 853. https://doi.org/10.3390/app16020853
Wang Y, Yu L, Zhang J, Zhang Q. Pyramid Product Quantization for Approximate Nearest Neighbor Search. Applied Sciences. 2026; 16(2):853. https://doi.org/10.3390/app16020853
Chicago/Turabian StyleWang, Yang, Lu Yu, Jinbin Zhang, and Qiyuan Zhang. 2026. "Pyramid Product Quantization for Approximate Nearest Neighbor Search" Applied Sciences 16, no. 2: 853. https://doi.org/10.3390/app16020853
APA StyleWang, Y., Yu, L., Zhang, J., & Zhang, Q. (2026). Pyramid Product Quantization for Approximate Nearest Neighbor Search. Applied Sciences, 16(2), 853. https://doi.org/10.3390/app16020853

