WeaviateEx.API.Quantizer.PQConfig (WeaviateEx v0.7.4)

View Source

Product Quantization (PQ) configuration.

PQ compresses vectors by dividing them into segments and quantizing each segment independently. This provides significant memory reduction while maintaining reasonable search accuracy.

Fields

  • :enabled - Whether PQ is enabled (default: true)
  • :training_limit - Number of vectors to use for training the quantizer
  • :segments - Number of segments to divide vectors into (0 for auto)
  • :centroids - Number of centroids per segment (default: 256)
  • :encoder - Encoder configuration with type and distribution

Encoder Types

  • "kmeans" - Standard k-means clustering (default)
  • "tile" - Tile encoder for specific distributions

Encoder Distributions

  • "log-normal" - Log-normal distribution (default)
  • "normal" - Normal/Gaussian distribution

Summary

Functions

Parse a PQ configuration from API response.

Create a new PQ configuration.

Convert a PQ configuration to API format.

Types

t()

@type t() :: %WeaviateEx.API.Quantizer.PQConfig{
  centroids: non_neg_integer() | nil,
  enabled: boolean(),
  encoder: map() | nil,
  segments: non_neg_integer() | nil,
  training_limit: non_neg_integer() | nil
}

Functions

from_api(map)

@spec from_api(map()) :: t()

Parse a PQ configuration from API response.

Examples

iex> PQConfig.from_api(%{"pq" => %{"enabled" => true, "segments" => 128}})
%PQConfig{enabled: true, segments: 128}

new(opts \\ [])

@spec new(keyword()) :: t()

Create a new PQ configuration.

Options

  • :enabled - Enable PQ (default: true)
  • :training_limit - Number of vectors to train on
  • :segments - Number of segments (0 for auto)
  • :centroids - Number of centroids per segment
  • :encoder - Encoder configuration map

Examples

iex> PQConfig.new()
%PQConfig{enabled: true}

iex> PQConfig.new(segments: 128, centroids: 256)
%PQConfig{enabled: true, segments: 128, centroids: 256}

to_api(config)

@spec to_api(t()) :: map()

Convert a PQ configuration to API format.

Examples

iex> config = PQConfig.new(segments: 128)
iex> PQConfig.to_api(config)
%{"pq" => %{"enabled" => true, "segments" => 128}}