Parameters
Parameter | Type | Description |
---|---|---|
vectors | List[Dict[str, Union[int, List[float], bytes, Dict[str, Union[str, int, bool, float]]]]] | A list of dictionaries, where each dictionary has the format {"id": int, "vector": List[float], "item": bytes} . |
vector
dictionary has the following fields:
id
(int
): Unique integer identifier for the vector.vector
(List[float]
): Embedding vector as a list of floats.item
(bytes
): Item contents in bytes (optional)
Exceptions
ValueError
ValueError
- Throws if the vector dimensions are incompatible with the index configuration.
- Throws if the index was not created or loaded yet.
RuntimeError
RuntimeError
- Throws if the vectors could not be upserted.
Example Usage
You can pass the
id
and vector
fields as tuples, if you wish to skip the dictionary. On big datasets, this can make a signficant difference in memory usage.Upsert
Secondary Overload: NumPy Array Format
This format is optimal for large batches due to its memory efficiency and compatibility with batch processing optimizations.
- A 2D array of floats for the vector embeddings.
- A 1D array of integers for the unique IDs.
Parameters
Parameter | Type | Description |
---|---|---|
ids | np.ndarray | 1D NumPy array of shape (num_items,) with dtype=int , containing unique integer identifiers for each vector. Length must match vectors . |
vectors | np.ndarray | 2D NumPy array of shape (num_items, vector_dim) with dtype=float , representing vector embeddings. |
Exceptions
ValueError
ValueError
- Throws if the vector dimensions are incompatible with the index configuration.
- Throws if the index was not created or loaded yet.
RuntimeError
RuntimeError
- Throws if the vectors could not be upserted.