slides: https://bit.ly/2P0KuW1 Reconfigurable Inverted Index Yusuke Matsui 1 Ryota Hinami 2 Shinβichi Satoh 1 1 National Institute of Informatics 2 The University of Tokyo
slides: https://bit.ly/2P0KuW1 Approximate nearest neighbor search Approximate NN search Result 0.23 0.20 2 3.15 3.25 argmin π β π π Query 2 ANN system 0.65 0.72 πβ 1,β¦,π 1.43 1.68 π β β πΈ π 74 hash-table, trees, inverted-index, etc Add Database vectors 4.63 0.86 5.22 β¦ 0.54 6.21 3.44 1.66 0.72 1.12 0.74 0.31 0.04 π 1 π 2 π π
slides: https://bit.ly/2P0KuW1 Approximate nearest neighbor search Approximate NN search Result 0.23 0.20 2 3.15 3.25 argmin π β π π Query 2 ANN system 0.65 0.72 πβ 1,β¦,π 1.43 1.68 π β β πΈ π 74 hash-table, trees, inverted-index, etc Add Database vectors 4.63 0.86 5.22 β¦ 0.54 6.21 3.44 1.66 0.72 1.12 0.74 0.31 0.04 π 1 π 2 π π
slides: https://bit.ly/2P0KuW1 Approximate nearest neighbor search Approximate NN search Result 0.23 0.20 2 3.15 3.25 argmin π β π π Query 2 ANN system 0.65 0.72 πβ 1,β¦,π 1.43 1.68 π β β πΈ π 74 hash-table, trees, inverted-index, etc Add Database vectors 4.63 0.86 5.22 β¦ 0.54 6.21 3.44 1.66 0.72 1.12 0.74 0.31 0.04 π 1 π 2 π π
slides: https://bit.ly/2P0KuW1 Related work β’ Locality-sensitive-hashing (LSH) - FALCONN [Andoni+, 15] [Razenshteyn+, 18] β’ Project/tree-based - FLANN [Muja+, 14] - Annoy [Bernhardsson, 18] β’ Graph traversal - NSW/HNSW on NMSLIB [Malkov+, 16][Boytsov+, 13] β’ Product quantization (PQ) - IVFPQ on Faiss [JΓ©gou+, 11][Johnson+, 17] etc. - Our Reconfigurable Inverted Index
slides: https://bit.ly/2P0KuW1 Approximate NN Search Result 0.23 0.20 2 3.15 3.25 argmin π β π π Query 2 ANN system 0.65 0.72 πβπ― 1.43 1.68 π β β πΈ π 74 Subset search problem β’ Existing ANN systems are fast for the all vectors Search is over π― = 1, β¦ , π - β’ However, it is hard to run the search for a subset Search is over π― β 1, β¦ , π - e.g., searching from π 1000 , β¦ , π 2000 - - Why? Systems are usually optimized for π― = 1, β¦ , π
slides: https://bit.ly/2P0KuW1 There is a demand for subset search!
slides: https://bit.ly/2P0KuW1 There is a demand for subset search! Propose: Reconfigurable inverted index (Rii) β Subset search β A comparative performance with IVFPQ (Faiss) β 10 ms for billion-scale data
slides: https://bit.ly/2P0KuW1 Reconfigurable inverted index (Rii) β’ Preliminary Fast if |π―| Runtime is small - PQ linear scan π― - IVFPQ Fast if |π―| Runtime is large β’ Data structure π― β’ Search Cherry pick! Runtime Always fast π―
slides: https://bit.ly/2P0KuW1 Reconfigurable inverted index (Rii) β’ Preliminary Fast if |π―| Runtime is small - PQ linear scan π― - IVFPQ Fast if |π―| Runtime is large β’ Data structure π― β’ Search Cherry pick! Runtime Always fast π―
slides: https://bit.ly/2P0KuW1 Preliminary: Product quantization (PQ) [JΓ©gou+, TPAMI 11] PQ : Compress a vector All database vectors are PQ-encoded beforehand π 1 π 2 π π into a short code 5.22 4.63 0.86 5.22 β¦ 0.54 6.21 3.44 0.54 1.66 0.72 1.12 1.66 0.31 0.04 0.74 0.74 PQ PQ PQ β 4 β β¦ 2 , , 1 2 N β¦
slides: https://bit.ly/2P0KuW1 Preliminary: Product quantization (PQ) [JΓ©gou+, TPAMI 11] β’ The subset search is possible with a linear cost of π― π e.g., π― = 2, 4, 5, 8 argmin π π, πβπ― β β β 1 2 3 4 5 6 N 0.23 β¦ 3.15 Linearly compared 0.65 1.43 π β β πΈ Runtime β’ The search is efficient only if π― is small π π―
slides: https://bit.ly/2P0KuW1 Reconfigurable inverted index (Rii) β’ Preliminary Fast if |π―| Runtime is small - PQ linear scan π― - IVFPQ Fast if |π―| Runtime is large β’ Data structure π― β’ Search Cherry pick! Runtime Always fast β’ Evaluation π―
slides: https://bit.ly/2P0KuW1 Preliminary: Inverted Index + PQ (IVFPQ) [JΓ©gou+, TPAMI 11] β’ Current basic data structure for a large-scale search β’ Subset-search is possible only if π― is large 126 225 π 1 π 2 π 13 13 92 188 π 5 Space partitioning β¦
slides: https://bit.ly/2P0KuW1 Preliminary: Inverted Index + PQ (IVFPQ) [JΓ©gou+, TPAMI 11] β’ Current basic data structure for a large-scale search β’ Subset-search is possible only if π― is large e.g., π― = 13, 92, 105, β¦ 126 225 π β π― or not 0.23 3.15 π 1 0.65 1.43 β Re-rank via β π β β πΈ π 2 π 13 13 92 188 92 PQ-linear scan π 5 Space partitioning β¦ 1.Find the closest space: π β = argmin π π β π π 2 2 2.Focus the π β th space, accept items β π― 3.Re-rank the items via PQ-linear scan
slides: https://bit.ly/2P0KuW1 Preliminary: Inverted Index + PQ (IVFPQ) [JΓ©gou+, TPAMI 11] β’ Current basic data structure for a large-scale search β’ Subset-search is possible only if π― is large e.g., π― = 13, 92, 105, β¦ 126 225 π β π― or not 0.23 3.15 π 1 0.65 1.43 β Re-rank via β π β β πΈ π 2 π 13 13 92 188 92 PQ-linear scan π 5 Space partitioning Runtime Why is it slow for small π― ? β¦ 1.Find the closest space: π β = argmin π π β π π 2 e.g., if π― is small and they are far away from 2 the query, we might need to scan all items 2.Focus the π β th space, accept items β π― π π― 3.Re-rank the items via PQ-linear scan
slides: https://bit.ly/2P0KuW1 Reconfigurable inverted index (Rii) β’ Preliminary Fast if |π―| Runtime is small - PQ linear scan π― - IVFPQ Fast if |π―| Runtime is large β’ Data structure π― β’ Search Cherry pick! Runtime Always fast π―
slides: https://bit.ly/2P0KuW1 Data structure β’ Store (1) PQ-codes linearly , and (2) IDs as an inverted index β’ Can run either PQ-linear-scan or IVFPQ with a single data structure 1 2 13 N Key: store codes linearly β¦ β¦ cf. IVFPQ β’ PQ-codes are also chunked. Natural 126 225 π 1 β’ Slight, but critical change 126 225 π 2 13 92 188 π 1 π 5 β¦ 13 92 188 π 2 π 5
slides: https://bit.ly/2P0KuW1 Reconfigurable inverted index (Rii) β’ Preliminary Fast if |π―| Runtime is small - PQ linear scan π― - IVFPQ Fast if |π―| Runtime is large β’ Data structure π― β’ Search Cherry pick! Runtime Always fast π―
slides: https://bit.ly/2P0KuW1 Search β’ If π― is small, run PQ-linear scan β’ If π― is large, run IVFPQ Runtime 1 2 13 N β¦ β¦ β¦ β¦ π― π 0.23 3.15 0.65 1.43 126 225 π 1 π β β πΈ Runtime π 2 13 92 188 π 5 β¦ π π―
slides: https://bit.ly/2P0KuW1 Search β’ If π― is small, run PQ-linear scan β’ If π― is large, run IVFPQ Runtime 1 2 13 N β¦ β¦ β¦ β¦ π― π 0.23 3.15 0.65 1.43 126 225 π 1 π β β πΈ Runtime π 2 13 92 188 π 5 β¦ π π―
slides: https://bit.ly/2P0KuW1 Search β’ If π― is small, run PQ-linear scan β’ If π― is large, run IVFPQ Runtime 1 2 13 N β¦ β¦ β¦ β¦ π― π 0.23 3.15 0.65 1.43 126 225 π 1 π β β πΈ fetch Runtime π 2 13 92 188 π 5 β¦ π π―
slides: https://bit.ly/2P0KuW1 Search β’ If π― is small, run PQ-linear scan β’ If π― is large, run IVFPQ Runtime 1 2 13 N β¦ β¦ β¦ β¦ π― π 0.23 3.15 0.65 1.43 126 225 π 1 π β β πΈ fetch Runtime π 2 13 92 188 π 5 β¦ π π―
slides: https://bit.ly/2P0KuW1 Search β’ Set a threshold π β’ If π― is small, run PQ-linear scan β’ Key: Switch two methods β’ If π― is large, run IVFPQ based on π― βΆ π 1 2 13 N β¦ β¦ β¦ β¦ Runtime 0.23 3.15 0.65 1.43 126 225 π 1 π π π β β πΈ fetch π― π 2 13 92 188 Use PQ-linear-scan Use IVFPQ π 5 β¦
slides: https://bit.ly/2P0KuW1 Search β’ Set a threshold π β’ If π― is small, run PQ-linear scan β’ Key: Switch two methods β’ If π― is large, run IVFPQ based on π― βΆ π 1 2 13 N β¦ β¦ β¦ β¦ Runtime 0.23 3.15 0.65 1.43 126 225 π 1 π π π β β πΈ fetch π― π 2 13 92 188 Use PQ-linear-scan Use IVFPQ π 5 β¦
slides: https://bit.ly/2P0KuW1 Evaluation β’ SIFT1M ( π = 10 6 , πΈ = 128 ). Results for top-R search
slides: https://bit.ly/2P0KuW1 β’ Existing system: Annoy Evaluation β’ Force to search a subset β’ SIFT1M ( π = 10 6 , πΈ = 128 ). Results for top-R search The existing system is slow, especially when π― is small Proposed Rii is always fast regardless of π― and π
slides: https://bit.ly/2P0KuW1 $ pip install rii https://github.com/matsui528/rii import rii import nanopq # Prepare a PQ/OPQ codec with M=32 sub spaces codec = nanopq.PQ(M=32).fit(vecs=Xt) # Trained using Xt # Instantiate a Rii class with the codec e = rii.Rii(fine_quantizer=codec) # Add vectors e.add_configure(vecs=X) # Search ids, dists = e.query(q=q, topk=3, target_ids=S) print(ids, dists) # e.g., [7484 8173 1556] [15.062 15.385 16.169]
Recommend
More recommend