Skip to main content
This function is only present in the embedded library version of Cyborg Vector Search. In other versions (microservice, serverless), it is automatically called once enough vector embeddings have been indexed.
Builds the index using the specified training configuration. Required before efficient querying. Prior to calling this, all queries will be conducted using encrypted exhaustive search. After, they will be conducted using encrypted ANN search.
def train(self, batch_size: int = 2048, max_iters: int = 100, tolerance: float = 1e-6)

Parameters

ParameterTypeDefaultDescription
batch_sizeint2048(Optional) Size of each batch for training.
max_itersint100(Optional) Maximum number of iterations for training.
tolerancefloat1e-6(Optional) Convergence tolerance for training.
There must be at least 2 * n_lists vector embeddings in the index prior to to calling this function.

Exceptions

  • Raises an exception if the index was not created or loaded yet.
  • Raises an exception if there are not enough vector embeddings in the index for training (must be at least 2 * n_lists).
  • Raises an exception if the index could not be trained.

Example Usage

# Load index
index = client.load_index(index_name=index_name, index_key=index_key)

# Train the index with custom settings
index.train(batch_size=128, max_iters=10, tolerance=1e-4)

# Train with default settings (auto-selected configuration)
index.train()
I