Skip to content

Conversation

@john-wagster
Copy link
Contributor

Initial pass at a preconditioning utils and wiring through for the disk bbq next format so we can iterate to see it's impact on quantization.

final FloatVectorValues floatVectorValues = getFloatVectorValues(fieldWriter.fieldInfo, fieldWriter.delegate, maxDoc);
FloatVectorValues floatVectorValues = getFloatVectorValues(fieldWriter.fieldInfo, fieldWriter.delegate, maxDoc);
// precondition the vectors if necessary
floatVectorValues = preconditionVectors(floatVectorValues);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can precondition just immediately before quantization and precondition the centroids after clustering. Maybe applying it before clustering works ok...I need to think about that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried both; seems to work fine to precondition before creating the centroids; still worth thinking about though. I will post numbers for review.

@john-wagster
Copy link
Contributor Author

Ran on a variety of datasets so we could see the impact of preconditioning on QPS in both scenarios where we expect to see improvements and scenarios where we don't.

My quick assessment from running these is we generally seem to get the best result out of using the variance-based permutation matrix. For equivalent recall it has reasonable QPS. And in general when attempting to recover recall there are some dataset where it's absolutely necessary to use preconditioning. It would seem this is valuable even at a segment level imo.

Thinking that it makes sense to follow up here by investigating if I can sample the average variances across dimensions as a mechanism to determine when to use preconditioning automatically.

Below are all the discussed datasets except for mnist.

dbpedia
# dbpedia

## config
[{
  "num_docs" : 4000000,
  "num_queries" : 400,
  "visit_percentage": 17,
  "ivf_cluster_size": 384,
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : -1,
  "do_precondition": true
}]
block size: 32
dims: 384


## candidate - variance-based
index_name                             index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
-------------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
corpus-dbpedia-entity-E5-small-0.fvec         ivf   4000000             15247                236569                397265             1

index_name                             index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count    QPS  recall     visited  filter_selectivity
-------------------------------------  ----------  -------------------  -----------  ----------------  -------------  -----  ------  ----------  ------------------  
corpus-dbpedia-entity-E5-small-0.fvec         ivf                17.00        18.67              0.00           0.00  53.57    0.94  1360414.06                1.00


## candidate - random
index_name                             index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
-------------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
corpus-dbpedia-entity-E5-small-0.fvec         ivf   4000000             21713                228102                374009             1

index_name                             index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count    QPS  recall     visited  filter_selectivity
-------------------------------------  ----------  -------------------  -----------  ----------------  -------------  -----  ------  ----------  ------------------  
corpus-dbpedia-entity-E5-small-0.fvec         ivf                17.00        18.70              0.00           0.00  53.46    0.93  1360412.12                1.00


## baseline
index_name                             index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
-------------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
corpus-dbpedia-entity-E5-small-0.fvec         ivf   4000000              7371                 61254                178212             1

index_name                             index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count    QPS  recall     visited  filter_selectivity
-------------------------------------  ----------  -------------------  -----------  ----------------  -------------  -----  ------  ----------  ------------------  
corpus-dbpedia-entity-E5-small-0.fvec         ivf                17.00        17.95              0.00           0.00  55.72    0.93  1360414.84                1.00
cohere
# cohere

## config
{
  "num_docs" : 10000000,
  "num_queries" : 300,
  "visit_percentage": [0.1, 0.3, 0.5, 0.7, 1, 1.2, 1.5, 2],
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : 768,
  "do_precondition": true
}]
block size: 32
dims: 768


# candidate - variance-based
index_name                          index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
----------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
cohere-wikipedia-10m-docs-768d.vec         ivf  10000000            894481               1273708               3419774             1

index_name                          index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall    visited  filter_selectivity
----------------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ---------  ------------------  
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.10         0.71              0.00           0.00  1408.45    0.75   20721.94                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.30         1.36              0.00           0.00   735.29    0.89   60736.09                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.50         2.16              0.00           0.00   462.96    0.91  100812.65                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.70         2.86              0.00           0.00   349.65    0.94  140779.44                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.00         5.95              0.00           0.00   168.07    0.96  200834.76                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.20         5.70              0.00           0.00   175.44    0.96  240772.09                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.50         6.12              0.00           0.00   163.40    0.97  300753.17                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 2.00         7.76              0.00           0.00   128.87    0.98  400747.68                1.00


# candidate - random
index_name                          index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
----------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
cohere-wikipedia-10m-docs-768d.vec         ivf  10000000            875269               1153269               3380429             1

index_name                          index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall    visited  filter_selectivity
----------------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ---------  ------------------  
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.10         0.72              0.00           0.00  1388.89    0.73   20707.43                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.30         1.70              0.00           0.00   588.24    0.88   60735.37                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.50         2.76              0.00           0.00   362.32    0.92  100756.43                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.70         3.36              0.00           0.00   297.62    0.94  140727.58                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.00         4.77              0.00           0.00   209.64    0.95  200815.69                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.20         5.73              0.00           0.00   174.52    0.96  240757.71                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.50         7.02              0.00           0.00   142.45    0.96  300796.55                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 2.00        10.03              0.00           0.00    99.70    0.97  400775.30                1.00


# baseline
index_name                          index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
----------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
cohere-wikipedia-10m-docs-768d.vec         ivf  10000000            173953                352578               1778583             1

index_name                          index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall    visited  filter_selectivity
----------------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ---------  ------------------  
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.10         0.61              0.00           0.00  1639.34    0.72   20813.88                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.30         1.33              0.00           0.00   751.88    0.86   60816.45                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.50         2.06              0.00           0.00   485.44    0.90  100757.78                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 0.70         2.70              0.00           0.00   370.37    0.93  140780.49                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.00         3.83              0.00           0.00   261.10    0.95  200768.33                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.20         4.76              0.00           0.00   210.08    0.96  240828.24                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 1.50         5.61              0.00           0.00   178.25    0.97  300785.37                1.00
cohere-wikipedia-10m-docs-768d.vec         ivf                 2.00         7.38              0.00           0.00   135.50    0.98  400760.44                1.00
glove 100d
# glove 100d

## config
[{
  "num_docs" : 10000000,
  "num_queries" : 100,
  "visit_percentage": [0.5, 1, 3, 5, 7, 10, 20, 30, 40, 50],
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : 100,
  "do_precondition": true
}]
block size: 32
dims: 100

## candidate - variance-based
index_name                         index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
enwiki-20120502-lines-1k-100d.vec         ivf  10000000             57553                148015                218307             1

index_name                         index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count     QPS  recall      visited  filter_selectivity
---------------------------------  ----------  -------------------  -----------  ----------------  -------------  ------  ------  -----------  ------------------  
enwiki-20120502-lines-1k-100d.vec         ivf                 0.50         2.72              0.00           0.00  367.65    0.62    100892.73                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 1.00         5.20              0.00           0.00  192.31    0.67    200954.29                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 3.00        15.79              0.00           0.00   63.33    0.74    600919.91                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 5.00        27.07              0.00           0.00   36.94    0.76   1000941.60                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 7.00        34.03              0.00           0.00   29.39    0.77   1400956.62                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                10.00        48.94              0.00           0.00   20.43    0.79   2000941.36                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                20.00        98.36              0.00           0.00   10.17    0.81   4000975.13                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                30.00       145.90              0.00           0.00    6.85    0.82   6000911.07                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                40.00       196.73              0.00           0.00    5.08    0.82   8000878.32                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                50.00       241.51              0.00           0.00    4.14    0.83  10000921.86                1.00


## candidate - random
index_name                         index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
enwiki-20120502-lines-1k-100d.vec         ivf  10000000             57869                136933                211227             1

index_name                         index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count     QPS  recall      visited  filter_selectivity
---------------------------------  ----------  -------------------  -----------  ----------------  -------------  ------  ------  -----------  ------------------  
enwiki-20120502-lines-1k-100d.vec         ivf                 0.50         2.64              0.00           0.00  378.79    0.56    100888.39                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 1.00         5.01              0.00           0.00  199.60    0.64    201043.23                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 3.00        14.59              0.00           0.00   68.54    0.75    600939.43                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 5.00        24.06              0.00           0.00   41.56    0.77   1000920.25                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 7.00        34.11              0.00           0.00   29.32    0.79   1400902.02                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                10.00        48.60              0.00           0.00   20.58    0.82   2000889.50                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                20.00        97.70              0.00           0.00   10.24    0.85   4000932.09                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                30.00       145.30              0.00           0.00    6.88    0.86   6000918.75                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                40.00       193.15              0.00           0.00    5.18    0.86   8000910.19                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                50.00       240.73              0.00           0.00    4.15    0.87  10000908.41                1.00


## baseline
index_name                         index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
enwiki-20120502-lines-1k-100d.vec         ivf  10000000             16338                 41163                 91994             1

index_name                         index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count     QPS  recall      visited  filter_selectivity
---------------------------------  ----------  -------------------  -----------  ----------------  -------------  ------  ------  -----------  ------------------  
enwiki-20120502-lines-1k-100d.vec         ivf                 0.50         2.51              0.00           0.00  398.41    0.61    100879.24                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 1.00         5.69              0.00           0.00  175.75    0.67    200943.62                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 3.00        15.97              0.00           0.00   62.62    0.74    600924.39                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 5.00        25.13              0.00           0.00   39.79    0.77   1000931.15                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                 7.00        32.88              0.00           0.00   30.41    0.79   1400913.33                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                10.00        48.27              0.00           0.00   20.72    0.80   2000949.00                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                20.00        94.40              0.00           0.00   10.59    0.82   4001018.26                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                30.00       149.11              0.00           0.00    6.71    0.83   6000957.86                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                40.00       185.65              0.00           0.00    5.39    0.84   8000831.05                1.00
enwiki-20120502-lines-1k-100d.vec         ivf                50.00       233.95              0.00           0.00    4.27    0.84  10000823.48                1.00
hotpotqa
# hotpotqa

## config
[{
  "num_docs" : 5000000,
  "num_queries" : 400,
  "visit_percentage": [0.5, 1, 3, 5, 7, 10, 20, 30, 40, 50],
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : -1,
  "do_precondition": true
}]
block size: 32
dims: 384

## candidate - variance-based
index_name                       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
-------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
corpus-hotpotqa-E5-small-0.fvec         ivf   5000000              4155                 77699                189394             1

index_name                       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall     visited  filter_selectivity
-------------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ----------  ------------------  
corpus-hotpotqa-E5-small-0.fvec         ivf                 0.50         0.79              0.00           0.00  1261.83    0.70    50924.52                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 1.00         1.25              0.00           0.00   796.81    0.76   100981.46                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 3.00         4.08              0.00           0.00   244.95    0.84   300934.44                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 5.00         5.92              0.00           0.00   168.85    0.87   500940.69                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 7.00         8.23              0.00           0.00   121.47    0.88   700969.07                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                10.00        11.53              0.00           0.00    86.69    0.89  1000937.86                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                20.00        22.47              0.00           0.00    44.51    0.90  2000899.59                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                30.00        33.06              0.00           0.00    30.25    0.90  3000912.35                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                40.00        44.27              0.00           0.00    22.59    0.91  4000921.05                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                50.00        53.88              0.00           0.00    18.56    0.91  5000979.26                1.00


## candidate - random
index_name                       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
-------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
corpus-hotpotqa-E5-small-0.fvec         ivf   5000000             11777                242497                614041             1

index_name                       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall     visited  filter_selectivity
-------------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ----------  ------------------  
corpus-hotpotqa-E5-small-0.fvec         ivf                 0.50         0.67              0.00           0.00  1498.13    0.68    50929.24                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 1.00         2.90              0.00           0.00   344.53    0.75   100880.07                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 3.00         3.46              0.00           0.00   289.23    0.84   300968.04                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 5.00         5.69              0.00           0.00   175.82    0.87   500866.42                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 7.00         7.95              0.00           0.00   125.83    0.88   700892.44                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                10.00        11.09              0.00           0.00    90.17    0.89  1000925.71                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                20.00        22.57              0.00           0.00    44.31    0.90  2000951.19                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                30.00        32.35              0.00           0.00    30.91    0.91  3000947.82                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                40.00        43.79              0.00           0.00    22.83    0.91  4000927.96                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                50.00        55.00              0.00           0.00    18.18    0.91  5000891.76                1.00


## baseline
index_name                       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
-------------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
corpus-hotpotqa-E5-small-0.fvec         ivf   5000000              6981                 61143                154925             1

index_name                       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall     visited  filter_selectivity
-------------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ----------  ------------------  
corpus-hotpotqa-E5-small-0.fvec         ivf                 0.50         0.66              0.00           0.00  1520.91    0.68    50933.84                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 1.00         1.19              0.00           0.00   840.34    0.75   100876.30                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 3.00         3.30              0.00           0.00   303.49    0.84   301010.85                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 5.00         5.53              0.00           0.00   180.91    0.87   500936.22                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                 7.00         7.60              0.00           0.00   131.54    0.89   700925.52                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                10.00        11.02              0.00           0.00    90.74    0.90  1000931.30                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                20.00        21.49              0.00           0.00    46.54    0.90  2000871.79                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                30.00        32.06              0.00           0.00    31.19    0.91  3000934.72                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                40.00        42.41              0.00           0.00    23.58    0.91  4000906.74                1.00
corpus-hotpotqa-E5-small-0.fvec         ivf                50.00        52.63              0.00           0.00    19.00    0.91  5000954.25                1.00
multi_tower
# multi_tower

## config
[{
  "num_docs" : 10000000,
  "num_queries" : 100,
  "visit_percentage": [0.5, 1, 3, 5, 7, 10, 20, 30, 40, 50],
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : 100,
  "do_precondition": true
}]
block size: 32
dims: 100

## candidate - variance-based
index_name                index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
multi_tower_v2_docs.fvec         ivf    100000                70                  2013                  1578             1

index_name                index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall    visited  filter_selectivity
------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ---------  ------------------  
multi_tower_v2_docs.fvec         ivf                 0.50         0.37              0.00           0.00  2702.70    0.22    1812.72                1.00
multi_tower_v2_docs.fvec         ivf                 1.00         0.19              0.00           0.00  5263.16    0.23    2908.06                1.00
multi_tower_v2_docs.fvec         ivf                 3.00         0.32              0.00           0.00  3125.00    0.25    6867.52                1.00
multi_tower_v2_docs.fvec         ivf                 5.00         0.35              0.00           0.00  2857.14    0.27   10848.08                1.00
multi_tower_v2_docs.fvec         ivf                 7.00         0.50              0.00           0.00  2000.00    0.26   14828.47                1.00
multi_tower_v2_docs.fvec         ivf                10.00         0.62              0.00           0.00  1612.90    0.25   20866.81                1.00
multi_tower_v2_docs.fvec         ivf                20.00         1.27              0.00           0.00   787.40    0.23   40776.68                1.00
multi_tower_v2_docs.fvec         ivf                30.00         1.33              0.00           0.00   751.88    0.23   60885.13                1.00
multi_tower_v2_docs.fvec         ivf                40.00         1.73              0.00           0.00   578.03    0.22   80805.59                1.00
multi_tower_v2_docs.fvec         ivf                50.00         2.12              0.00           0.00   471.70    0.22  100790.85                1.00


## candidate - random
index_name                index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
multi_tower_v2_docs.fvec         ivf    100000                65                  1945                  1639             1

index_name                index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall    visited  filter_selectivity
------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ---------  ------------------  
multi_tower_v2_docs.fvec         ivf                 0.50         0.27              0.00           0.00  3703.70    0.25    1715.72                1.00
multi_tower_v2_docs.fvec         ivf                 1.00         0.20              0.00           0.00  5000.00    0.28    2724.37                1.00
multi_tower_v2_docs.fvec         ivf                 3.00         0.29              0.00           0.00  3448.28    0.28    6771.09                1.00
multi_tower_v2_docs.fvec         ivf                 5.00         0.35              0.00           0.00  2857.14    0.28   10799.53                1.00
multi_tower_v2_docs.fvec         ivf                 7.00         0.38              0.00           0.00  2631.58    0.28   14811.85                1.00
multi_tower_v2_docs.fvec         ivf                10.00         0.51              0.00           0.00  1960.78    0.29   20778.80                1.00
multi_tower_v2_docs.fvec         ivf                20.00         0.94              0.00           0.00  1063.83    0.27   40738.56                1.00
multi_tower_v2_docs.fvec         ivf                30.00         1.35              0.00           0.00   740.74    0.26   60799.35                1.00
multi_tower_v2_docs.fvec         ivf                40.00         1.77              0.00           0.00   564.97    0.25   80892.58                1.00
multi_tower_v2_docs.fvec         ivf                50.00         2.20              0.00           0.00   454.55    0.25  100793.26                1.00


## baseline
index_name                index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
multi_tower_v2_docs.fvec         ivf    100000                73                   867                   723             1

index_name                index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall    visited  filter_selectivity
------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ---------  ------------------  
multi_tower_v2_docs.fvec         ivf                 0.50         0.34              0.00           0.00  2941.18    0.23    1754.15                1.00
multi_tower_v2_docs.fvec         ivf                 1.00         0.17              0.00           0.00  5882.35    0.23    2800.67                1.00
multi_tower_v2_docs.fvec         ivf                 3.00         0.25              0.00           0.00  4000.00    0.22    6856.76                1.00
multi_tower_v2_docs.fvec         ivf                 5.00         0.37              0.00           0.00  2702.70    0.21   10932.76                1.00
multi_tower_v2_docs.fvec         ivf                 7.00         0.41              0.00           0.00  2439.02    0.21   15051.18                1.00
multi_tower_v2_docs.fvec         ivf                10.00         0.50              0.00           0.00  2000.00    0.20   20959.24                1.00
multi_tower_v2_docs.fvec         ivf                20.00         0.91              0.00           0.00  1098.90    0.18   40953.41                1.00
multi_tower_v2_docs.fvec         ivf                30.00         1.33              0.00           0.00   751.88    0.18   60849.72                1.00
multi_tower_v2_docs.fvec         ivf                40.00         1.74              0.00           0.00   574.71    0.18   80810.55                1.00
multi_tower_v2_docs.fvec         ivf                50.00         2.16              0.00           0.00   462.96    0.17  100821.79                1.00
fashion mnist
# fashion mnist dataset

## config
[{
  "num_docs" : 10000000,
  "num_queries" : 100,
  "visit_percentage": [0.5, 1, 3, 5, 7, 10, 20, 30, 40, 50],
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : 784,
  "do_precondition": true
}]
block size: 32
dims: 784

## candidate - variance-based
index_name                index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
fashion-mnist-train.fvec         ivf     60000                62                  5514                  5434             1

index_name                index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall   visited  filter_selectivity
------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  --------  ------------------  
fashion-mnist-train.fvec         ivf                 0.50         0.28              0.00           0.00  3571.43    0.64   1317.65                1.00
fashion-mnist-train.fvec         ivf                 1.00         0.21              0.00           0.00  4761.90    0.70   1796.26                1.00
fashion-mnist-train.fvec         ivf                 3.00         0.20              0.00           0.00  5000.00    0.88   4329.34                1.00
fashion-mnist-train.fvec         ivf                 5.00         0.27              0.00           0.00  3703.70    0.94   6936.96                1.00
fashion-mnist-train.fvec         ivf                 7.00         0.31              0.00           0.00  3225.81    0.95   9170.80                1.00
fashion-mnist-train.fvec         ivf                10.00         0.41              0.00           0.00  2439.02    0.97  12687.53                1.00
fashion-mnist-train.fvec         ivf                20.00         0.73              0.00           0.00  1369.86    0.97  24849.79                1.00
fashion-mnist-train.fvec         ivf                30.00         1.00              0.00           0.00  1000.00    0.98  36863.33                1.00
fashion-mnist-train.fvec         ivf                40.00         1.33              0.00           0.00   751.88    0.98  48886.69                1.00
fashion-mnist-train.fvec         ivf                50.00         1.60              0.00           0.00   625.00    0.98  60918.79                1.00


## candidate - random
index_name                index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
fashion-mnist-train.fvec         ivf     60000                62                  5478                  5145             1

index_name                index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall   visited  filter_selectivity
------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  --------  ------------------  
fashion-mnist-train.fvec         ivf                 0.50         0.25              0.00           0.00  4000.00    0.63   1619.34                1.00
fashion-mnist-train.fvec         ivf                 1.00         0.23              0.00           0.00  4347.83    0.64   2003.42                1.00
fashion-mnist-train.fvec         ivf                 3.00         0.32              0.00           0.00  3125.00    0.80   4587.33                1.00
fashion-mnist-train.fvec         ivf                 5.00         0.26              0.00           0.00  3846.15    0.88   7130.47                1.00
fashion-mnist-train.fvec         ivf                 7.00         0.31              0.00           0.00  3225.81    0.92   9276.48                1.00
fashion-mnist-train.fvec         ivf                10.00         0.40              0.00           0.00  2500.00    0.93  12799.19                1.00
fashion-mnist-train.fvec         ivf                20.00         0.70              0.00           0.00  1428.57    0.97  25093.91                1.00
fashion-mnist-train.fvec         ivf                30.00         1.04              0.00           0.00   961.54    0.98  36829.15                1.00
fashion-mnist-train.fvec         ivf                40.00         1.37              0.00           0.00   729.93    0.98  49164.33                1.00
fashion-mnist-train.fvec         ivf                50.00         1.66              0.00           0.00   602.41    0.98  60940.57                1.00


## baseline
index_name                index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
------------------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
fashion-mnist-train.fvec         ivf     60000                73                  1564                  1744             1

index_name                index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall   visited  filter_selectivity
------------------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  --------  ------------------  
fashion-mnist-train.fvec         ivf                 0.50         0.36              0.00           0.00  2777.78    0.42   1588.27                1.00
fashion-mnist-train.fvec         ivf                 1.00         0.32              0.00           0.00  3125.00    0.44   1971.72                1.00
fashion-mnist-train.fvec         ivf                 3.00         0.32              0.00           0.00  3125.00    0.51   4320.97                1.00
fashion-mnist-train.fvec         ivf                 5.00         0.22              0.00           0.00  4545.45    0.54   6951.69                1.00
fashion-mnist-train.fvec         ivf                 7.00         0.27              0.00           0.00  3703.70    0.54   9408.11                1.00
fashion-mnist-train.fvec         ivf                10.00         0.35              0.00           0.00  2857.14    0.56  12745.87                1.00
fashion-mnist-train.fvec         ivf                20.00         0.61              0.00           0.00  1639.34    0.58  24794.58                1.00
fashion-mnist-train.fvec         ivf                30.00         0.87              0.00           0.00  1149.43    0.59  36895.41                1.00
fashion-mnist-train.fvec         ivf                40.00         1.14              0.00           0.00   877.19    0.59  48866.17                1.00
fashion-mnist-train.fvec         ivf                50.00         1.37              0.00           0.00   729.93    0.59  60909.34                1.00
gist
# gist dataset

## config
[{
  "num_docs" : 10000000,
  "num_queries" : 100,
  "visit_percentage": [0.5, 1, 3, 5, 7, 10, 20, 30, 40, 50],
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : -1,
  "do_precondition": true
}]
block size: 32
dims: 960


## candidate - variance-based
index_name       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
gist_base.fvecs         ivf   1000000             56921                127353                199369             1

index_name       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall   visited  filter_selectivity
---------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  --------  ------------------  
gist_base.fvecs         ivf                 0.10         0.26              0.00           0.00  3846.15    0.98   2469.97                1.00
gist_base.fvecs         ivf                 0.20         0.26              0.00           0.00  3846.15    0.98   4601.36                1.00
gist_base.fvecs         ivf                 0.30         0.30              0.00           0.00  3333.33    0.98   6572.25                1.00
gist_base.fvecs         ivf                 0.40         0.34              0.00           0.00  2941.18    0.98   8547.98                1.00
gist_base.fvecs         ivf                 0.50         0.39              0.00           0.00  2564.10    0.98  10525.00                1.00


## candidate - random
index_name       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
gist_base.fvecs         ivf   1000000             36249                118749                192504             1

index_name       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall   visited  filter_selectivity
---------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  --------  ------------------  
gist_base.fvecs         ivf                 0.10         0.25              0.00           0.00  4000.00    0.81   2422.61                1.00
gist_base.fvecs         ivf                 0.20         0.22              0.00           0.00  4545.45    0.92   4483.41                1.00
gist_base.fvecs         ivf                 0.30         0.29              0.00           0.00  3448.28    0.96   6498.38                1.00
gist_base.fvecs         ivf                 0.40         0.34              0.00           0.00  2941.18    0.97   8505.26                1.00
gist_base.fvecs         ivf                 0.50         0.37              0.00           0.00  2702.70    0.98  10525.65                1.00


## baseline
index_name       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
gist_base.fvecs         ivf   1000000              9348                 27398                 58893             1

index_name       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall   visited  filter_selectivity
---------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  --------  ------------------  
gist_base.fvecs         ivf                 0.10         0.27              0.00           0.00  3703.70    0.84   2499.27                1.00
gist_base.fvecs         ivf                 0.20         0.22              0.00           0.00  4545.45    0.88   4500.37                1.00
gist_base.fvecs         ivf                 0.30         0.24              0.00           0.00  4166.67    0.88   6565.95                1.00
gist_base.fvecs         ivf                 0.40         0.29              0.00           0.00  3448.28    0.88   8629.59                1.00
gist_base.fvecs         ivf                 0.50         0.32              0.00           0.00  3125.00    0.88  10584.67                1.00
sift
# sift dataset

## config
[{
  "num_docs" : 10000000,
  "num_queries" : 100,
  "visit_percentage": [0.5, 1, 3, 5, 7, 10, 20, 30, 40, 50],
  "over_sampling_factor": 5,
  "index_type" : "ivf",
  "k" : 10,
  "index_threads" : 4,
  "quantize_bits": 1,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "maximum_inner_product",
  "dimensions" : -1,
  "do_precondition": true
}]
block size: 32
dims: 128


## candidate - variance-based
index_name       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
sift_base.fvecs         ivf   1000000               194                 21573                 23030             1

index_name       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall     visited  filter_selectivity
---------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ----------  ------------------  
sift_base.fvecs         ivf                 0.50         0.36              0.00           0.00  2777.78    0.78    11008.15                1.00
sift_base.fvecs         ivf                 1.00         0.22              0.00           0.00  4545.45    0.88    21042.54                1.00
sift_base.fvecs         ivf                 3.00         0.49              0.00           0.00  2040.82    0.93    61009.94                1.00
sift_base.fvecs         ivf                 5.00         0.73              0.00           0.00  1369.86    0.94   100990.42                1.00
sift_base.fvecs         ivf                 7.00         0.99              0.00           0.00  1010.10    0.94   140930.61                1.00
sift_base.fvecs         ivf                10.00         1.38              0.00           0.00   724.64    0.94   201009.60                1.00
sift_base.fvecs         ivf                20.00         2.66              0.00           0.00   375.94    0.94   401033.18                1.00
sift_base.fvecs         ivf                30.00         4.36              0.00           0.00   229.36    0.94   600969.82                1.00
sift_base.fvecs         ivf                40.00         5.50              0.00           0.00   181.82    0.94   800923.72                1.00
sift_base.fvecs         ivf                50.00         6.59              0.00           0.00   151.75    0.94  1000948.40                1.00


## candidate - random
index_name       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
sift_base.fvecs         ivf   1000000               196                 21378                 22293             1

index_name       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall     visited  filter_selectivity
---------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ----------  ------------------  
sift_base.fvecs         ivf                 0.50         0.31              0.00           0.00  3225.81    0.72    10900.46                1.00
sift_base.fvecs         ivf                 1.00         0.23              0.00           0.00  4347.83    0.86    21036.21                1.00
sift_base.fvecs         ivf                 3.00         0.50              0.00           0.00  2000.00    0.92    60948.86                1.00
sift_base.fvecs         ivf                 5.00         0.74              0.00           0.00  1351.35    0.92   100858.72                1.00
sift_base.fvecs         ivf                 7.00         1.01              0.00           0.00   990.10    0.93   141024.22                1.00
sift_base.fvecs         ivf                10.00         1.37              0.00           0.00   729.93    0.93   200972.17                1.00
sift_base.fvecs         ivf                20.00         2.64              0.00           0.00   378.79    0.93   400965.73                1.00
sift_base.fvecs         ivf                30.00         3.89              0.00           0.00   257.07    0.93   600970.70                1.00
sift_base.fvecs         ivf                40.00         5.11              0.00           0.00   195.69    0.93   801004.88                1.00
sift_base.fvecs         ivf                50.00         6.31              0.00           0.00   158.48    0.93  1000930.18                1.00


## baseline
index_name       index_type  num_docs  doc_add_time(ms)  total_index_time(ms)  force_merge_time(ms)  num_segments
---------------  ----------  --------  ----------------  --------------------  --------------------  ------------  
sift_base.fvecs         ivf   1000000               199                  7224                  7069             1

index_name       index_type  visit_percentage(%)  latency(ms)  net_cpu_time(ms)  avg_cpu_count      QPS  recall     visited  filter_selectivity
---------------  ----------  -------------------  -----------  ----------------  -------------  -------  ------  ----------  ------------------  
sift_base.fvecs         ivf                 0.50         0.29              0.00           0.00  3448.28    0.63    11065.73                1.00
sift_base.fvecs         ivf                 1.00         0.23              0.00           0.00  4347.83    0.73    20985.78                1.00
sift_base.fvecs         ivf                 3.00         0.48              0.00           0.00  2083.33    0.79    60938.00                1.00
sift_base.fvecs         ivf                 5.00         0.68              0.00           0.00  1470.59    0.80   100838.95                1.00
sift_base.fvecs         ivf                 7.00         0.93              0.00           0.00  1075.27    0.80   140978.03                1.00
sift_base.fvecs         ivf                10.00         1.30              0.00           0.00   769.23    0.80   200945.79                1.00
sift_base.fvecs         ivf                20.00         2.52              0.00           0.00   396.83    0.80   400880.85                1.00
sift_base.fvecs         ivf                30.00         3.69              0.00           0.00   271.00    0.80   601014.00                1.00
sift_base.fvecs         ivf                40.00         4.88              0.00           0.00   204.92    0.80   800887.63                1.00
sift_base.fvecs         ivf                50.00         6.05              0.00           0.00   165.29    0.80  1000927.86                1.00

@benwtrent
Copy link
Member

My quick assessment from running these is we generally seem to get the best result out of using the variance-based permutation matrix.

I realize that this is likely best, in that its applying the permutation per segment already. But the huge benefit of random is that it can be applied once, globally for the query vector and conceivably random permutation will be much cheaper at index and merge as the permutation matrix doesn't need to evolve with the vector distributions, and instead is static.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants