Skip to content

Vector Indexes

A vector index is a collection of chunks with embeddings that allow for efficient nearest-neighbor search.

Create a Vector Index:

When creating a vector index you must specify the embedding model that will be used to produce the vectors. This ensures i) that only vectors of the correct dimensions are stored in the vector index, ii) the correct model is used for retrieval when querying the index.

from onecontext import OneContext

oc = OneContext()

# Create a new vector index with the specified name and model.
index = oc.create_vector_index('my_index', 'BAAI/bge-base-en-v1.5')

List all Vector Indexes:

A list of all vector indexes can be obtained as follow,

from onecontext import OneContext

oc = OneContext()

# Retrieve a list of vector indexes
indexes = oc.list_indexes()