Skip to content

Conversation

@carlosdelest
Copy link
Member

Related to #129421

Creates a new ES910BinaryQuantizedVectorsFormat that accepts variable bit sizes for indexing and querying.

KnnIndexTester and related classes have been modified to allow testing with different bit sizes. Testing is possible via the following configuration file:

{
  "doc_vectors" : "/path_to_vectors",
  "query_vectors" : "/path_to_queries",
  "num_docs" : 100000,
  "num_queries" : 1000,
  "index_type" : "flat",
  "over_sampling_factor" : 1,
  "search_threads" : 40,
  "index_threads" : 40,
  "reindex" : true,
  "force_merge" : true,
  "vector_space" : "cosine",
  "quantize_bits" : 1,
  "vector_encoding" : "float32",
  "dimensions" : 768,
  "use_new_flat_vectors_format": true,
  "quantize_query_bits" : 4
}

Where:

  • quantize_bits determine the quantization for vectors at index time
  • quantize_query_bits determine the quantization for queries
  • use_new_flat_vectors_format: true to allow testing the variable bit sizes, false to fall back to the previous vector format (useful to compare quantize_bits:1 and quantize_query_bits: 4 to check the baseline)

…e-quantization-bits

# Conflicts:
#	qa/vector/src/main/java/org/elasticsearch/test/knn/CmdLineArgs.java
#	server/src/main/java/org/elasticsearch/index/mapper/vectors/DenseVectorFieldMapper.java
this.byteBuffer = ByteBuffer.allocate(dimension);
this.binaryValue = byteBuffer.array();
this.binaryQuantizer = quantizer;
this.discretizedDimensions = BQVectorUtils.discretize(dimension, 64);
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't seem needed, you are just storing the raw bytes.

Comment on lines 736 to 744
OffHeapBinarizedQueryVectorValues(IndexInput data, int dimension, int size) {
this.slice = data;
this.dimension = dimension;
this.size = size;
// 4x the quantized binary dimensions
int binaryDimensions = (BQVectorUtils.discretize(dimension, 64) / 8) * BQSpaceUtils.B_QUERY;
this.byteBuffer = ByteBuffer.allocate(binaryDimensions);
this.binaryValue = byteBuffer.array();
// + 1 for the quantized sum
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure if this is used, but its incorrect as you aren't packing the bits, binaryDimensions is just dimensions.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants