Skip to main content

DBConfig

The DBConfig class specifies the storage location for the index, with options for in-memory storage, databases, or file-based storage.

Parameters

The supported location options are:
  • "rocksdb": Use for persistent local storage with no network dependency (recommended for embedded/local deployments).
  • "redis": Use for high-speed, in-memory storage (recommended for index_location).
  • "postgres": Use for reliable, SQL-based storage (recommended for config_location).
  • "memory": Use for temporary in-memory storage (for benchmarking and evaluation purposes).
  • "threadsafememory": Use for thread-safe in-memory storage (for multi-threaded benchmarking and evaluation).
memory is deprecated and will be removed in a future release. Please use threadsafememory instead.

Example Usage

For more info, you can read about supported backing stores here.

GPUConfig

The GPUConfig class configures which operations should use GPU acceleration. GPU acceleration requires CUDA support.

Parameters

Properties (Read-Only)

Example Usage


DistanceMetric

DistanceMetric is a string representing the distance metric used for the index. Options include:
  • "cosine": Cosine similarity.
  • "euclidean": Euclidean distance.
  • "squared_euclidean": Squared Euclidean distance.

IndexConfig

The IndexConfig class defines the parameters for the type of index to be created. Each index type (e.g., ivf, ivfflat, ivfpq) has unique configuration options:

IndexIVF

The IndexIVF type is deprecated and will be removed in a future release.
Ideal for large-scale datasets where fast retrieval is prioritized over high recall:

Parameters

Properties (Read-Only)

Example Usage

IndexIVFFlat

Suitable for applications requiring high recall with less concern for memory usage:

Parameters

Properties (Read-Only)

Example Usage

IndexIVFPQ

Product Quantization compresses embeddings, making it suitable for balancing memory use and recall:

Parameters

Properties (Read-Only)

Methods

Example Usage

If dimension or pq_dim is not provided, it will be auto-determined based on the first vector embedding added to the index.

IndexIVFSQ

Scalar Quantization compresses embeddings, providing a good balance of speed, recall, and index size:

Parameters

Properties (Read-Only)

Methods

Example Usage

IndexIVFSQ is the default index configuration (with sq_bits=16) and is suitable for most use cases. It provides a good balance of recall, speed, and index size.