Product Quantization (PQ) based in-partition scoring configuration.
tflite_model_maker.searcher.ScoreAH(
dimensions_per_block: int,
anisotropic_quantization_threshold: float = float('nan'),
training_sample_size: int = 100000,
training_iterations: int = 10
)
Used in the notebooks
In ScaNN we use PQ to compress the database embeddings, but not the query
embedding. We called it Asymmetric Hashing. See
https://research.google/pubs/pub41694/
Attributes |
dimensions_per_block
|
How many dimensions in each PQ block. If the embedding
vector dimensionality is a multiple of this value, there will be
number_of_dimensions / dimensions_per_block PQ blocks. Otherwise, the
last block will be the remainder. For example, if a vector has 12
dimensions, and dimensions_per_block is 2, then there will be 6
2-dimension blocks. However, if the vector has 13 dimensions and
dimensions_per_block is still 2, there will be 6 2-dimension blocks and
one 1-dimension block.
|
anisotropic_quantization_threshold
|
If this value is set, we will penalize
the quantization error that's parallel to the original vector differently
than the orthogonal error. A generally recommended value for this
parameter would be 0.2. For more details, please look at ScaNN's 2020 ICML
paper https://arxiv.org/abs/1908.10396 and the Google AI Blog post
https://ai.googleblog.com/2020/07/announcing-scann-efficient-vector.html
|
training_sample_size
|
How many database points to sample for training the
K-Means for PQ centers. A good starting value would be 100k or the whole
dataset if it's smaller than that.
|
training_iterations
|
How many iterations to run K-Means for PQ.
|
Methods
__eq__
__eq__(
other
)
Class Variables |
anisotropic_quantization_threshold
|
nan
|
training_iterations
|
10
|
training_sample_size
|
100000
|