hoops_ai.ml.embeddings.FaissVectorStore

class hoops_ai.ml.embeddings.FaissVectorStore(dim)

Bases: VectorStore

FAISS (in-memory) storage and retrieval of high-dimensionalvector store implementation.

Efficient storage and retrieval of high-dimensional vectors with support for similarity search, metadata filtering, and CRUD operations.

Parameters:

dim (int)

close()

Close the vector store and release resources.

Return type:

None

count()

Return total number of vectors in the store.

Returns:

Number of stored vectors

Return type:

int

delete(ids)

Delete vectors by their ids.

Parameters:

ids (Sequence[str]) – Sequence of vector ids to delete

Return type:

None

get_ids()

Return list of all indexed vector IDs.

Returns:

List of all vector IDs currently in the store

Return type:

List[str]

classmethod load(path)

Load a persisted vector store from disk or restore connection.

For local stores (e.g., FAISS): Deserializes index and metadata from file. For cloud stores (e.g., Weaviate, Qdrant): Restores connection to existing index.

Parameters:

path (str) – File path for local stores, or identifier for cloud stores

Returns:

Restored vector store instance

Return type:

VectorStore

query(query_vector, top_k=10, filters=None, include_metadata=True)

Search for similar vectors.

Parameters:
  • query_vector (numpy.ndarray) – Query vector of shape (dim,), typically from Embedding.values

  • top_k (int) – Maximum number of results to return

  • filters (Dict[str, Any] | None) – Optional metadata filters (key-value pairs)

  • include_metadata (bool) – Whether to include metadata in results

Returns:

List of VectorHit objects sorted by similarity score (descending)

Return type:

List[VectorHit]

save(path)

Save FAISS index and metadata to disk.

Parameters:

path (str)

Return type:

None

upsert(records)

Insert or update vector records.

Parameters:

records (Sequence[VectorRecord]) – Sequence of VectorRecord objects to store

Return type:

None

property dim: int

Dimensionality of vectors stored in this vector store.

Returns:

Vector dimension

Return type:

int