Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
n_lists | int | None | (Optional) Number of inverted index lists to create in the index. When None, auto-determines based on the number of vectors in the index (equivalent to 0). |
batch_size | int | None | (Optional) Size of each batch for training. When None, defaults to 0 (auto — the optimal batch size is selected automatically). |
max_iters | int | None | (Optional) Maximum number of iterations for training. When None, defaults to 100. |
tolerance | float | None | (Optional) Convergence tolerance for training. When None, defaults to 1e-6. |
max_memory | int | None | (Optional) Maximum memory to use for training. When None, defaults to 0 (no limit). |
index_key | bytes | None | (Optional, keyword-only) Override the per-operation index key. See Per-operation key override. |
user_id | bytes | None | (Optional, keyword-only) 16-byte RBAC user identifier. See Per-operation key override. |
Exceptions
ValueError
ValueError
- Raises an exception if the index was not created or loaded yet.
RuntimeError
RuntimeError
- 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
Per-operation key override
The calls above reuse the key supplied atcreate_index() / load_index(). You may instead pass index_key= (and user_id= for an RBAC user) to override the per-operation key. This is required in stateless/service deployments that reload the index per request:
Training requires write permission. An RBAC user without a write wrap cannot train the index.