NVIDIA Morpheus (24.10.01)
(Latest Version)

morpheus.service.vdb.faiss_vdb_service.FaissVectorDBService

class FaissVectorDBService(local_dir, embeddings)[source]

Bases: morpheus.service.vdb.vector_db_service.VectorDBService

Service class for FAISS Vector Database implementation. This class provides functions for interacting with a FAISS vector database.

Parameters
local_dir

The local directory where the FAISS index files are stored.

embeddings

The embeddings object to use for embedding text.

Attributes
embeddings

Methods

close() Close the vector database service and release all resources.
count(name, **kwargs) Returns number of rows/entities in the given collection.
create(name[, overwrite]) Create a collection.
create_from_dataframe(name, df[, overwrite]) Create collections in the vector database.
delete(name, expr, **kwargs) Delete vectors from the collection using expressions.
delete_by_keys(name, keys, **kwargs) Delete vectors by keys from the collection.
describe(name, **kwargs) Describe the collection in the vector database.
drop(name, **kwargs) Drop a collection.
has_store_object(name) Check if specific index file name exists by attempting to load FAISS index, docstore, and index_to_docstore_id from disk with the index file name.
insert(name, data, **kwargs) Insert a collection specific data in the vector database.
insert_dataframe(name, df, **kwargs) Converts dataframe to rows and insert to the vector database.
list_store_objects(**kwargs) List the names of all resources in the vector database.
load_resource([name]) Loads a VDB resource into memory for use.
query(name[, query]) Query data in a vector database.
release_resource(name) Release a loaded collection from the memory.
retrieve_by_keys(name, keys, **kwargs) Retrieve the inserted vectors using their primary keys from the Collection.
similarity_search(name, **kwargs) Perform a similarity search within the collection.
transform(data, **kwargs) Transform data according to the specific vector database implementation.
update(name, data, **kwargs) Update data in the vector database.
close()[source]

Close the vector database service and release all resources.

count(name, **kwargs)[source]

Returns number of rows/entities in the given collection.

Parameters
name

Name of the collection.

**kwargs

Additional keyword arguments for the count operation.

Returns
int

Returns number of entities in the collection.

create(name, overwrite=False, **kwargs)[source]

Create a collection.

Parameters
name

Name of the collection to be created.

overwrite

If True, the collection will be overwritten if it already exists, by default False.

**kwargs

Additional keyword arguments containing collection configuration.

Raises
ValueError

If the provided schema fields configuration is empty.

create_from_dataframe(name, df, overwrite=False, **kwargs)[source]

Create collections in the vector database.

Parameters
name

Name of the collection.

df

The dataframe to create the collection from.

overwrite

Whether to overwrite the collection if it already exists. Default is False.

**kwargs

Extra keyword arguments specific to the vector database implementation.

delete(name, expr, **kwargs)[source]

Delete vectors from the collection using expressions.

Parameters
name

Name of the collection.

expr

Delete expression.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
dict[str, typing.Any]

Returns result of the given keys that are delete from the collection.

delete_by_keys(name, keys, **kwargs)[source]

Delete vectors by keys from the collection.

Parameters
name

Name of the collection.

keys

Primary keys to delete vectors.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
typing.Any

Returns result of the given keys that are delete from the collection.

describe(name, **kwargs)[source]

Describe the collection in the vector database.

Parameters
name

Name of the collection.

**kwargs

Additional keyword arguments specific to the vector database.

Returns
dict

Returns collection information.

drop(name, **kwargs)[source]

Drop a collection.

Parameters
name

Name of the collection, index, or partition to be dropped.

**kwargs

Additional keyword arguments for specifying the type and partition name (if applicable).

Raises
ValueError

If mandatory arguments are missing or if the provided ‘collection’ value is invalid.

has_store_object(name)[source]

Check if specific index file name exists by attempting to load FAISS index, docstore, and index_to_docstore_id from disk with the index file name.

Parameters
name

Name of the FAISS index file to check.

Returns
bool

True if the file exists, False otherwise.

insert(name, data, **kwargs)[source]

Insert a collection specific data in the vector database.

Parameters
name

Name of the collection to be inserted.

data

Data to be inserted in the collection.

**kwargs

Additional keyword arguments containing collection configuration.

Returns
dict

Returns response content as a dictionary.

Raises
RuntimeError

If the collection not exists exists.

insert_dataframe(name, df, **kwargs)[source]

Converts dataframe to rows and insert to the vector database.

Parameters
name

Name of the collection to be inserted.

df

Dataframe to be inserted in the collection.

**kwargs

Additional keyword arguments containing collection configuration.

Returns
dict

Returns response content as a dictionary.

Raises
RuntimeError

If the collection not exists exists.

list_store_objects(**kwargs)[source]

List the names of all resources in the vector database.

Returns
list[str]

A list of collection names.

load_resource(name='index', **kwargs)[source]

Loads a VDB resource into memory for use.

Parameters
name

The VDB resource to load. For FAISS, this corresponds to the index name, by default “index”

**kwargs

Additional keyword arguments specific to the resource service.

Returns
FaissVectorDBResourceService

The loaded resource service.

query(name, query=None, **kwargs)[source]

Query data in a vector database.

Parameters
name

Name of the collection to search within.

query

The search query, which can be a filter expression.

**kwargs

Additional keyword arguments for the search operation.

Returns
typing.Any

The search result, which can vary depending on the query and options.

release_resource(name)[source]

Release a loaded collection from the memory.

Parameters
name

Name of the collection to release.

retrieve_by_keys(name, keys, **kwargs)[source]

Retrieve the inserted vectors using their primary keys from the Collection.

Parameters
name

Name of the collection.

keys

Primary keys to get vectors for. Depending on pk_field type it can be int or str or a list of either.

**kwargs

Additional keyword arguments for the retrieval operation.

Returns
list[typing.Any]

Returns result rows of the given keys from the collection.

Perform a similarity search within the collection.

Parameters
name

Name of the collection.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
list[dict]

Returns a list of dictionaries representing the results of the similarity search.

transform(data, **kwargs)[source]

Transform data according to the specific vector database implementation.

Parameters
data

Data to be updated in the resource.

**kwargs

Extra keyword arguments specific to the vector database implementation.

Returns
typing.Any

Returns transformed data as per the implementation.

update(name, data, **kwargs)[source]

Update data in the vector database.

Parameters
name

Name of the collection.

data

Data to be updated in the collection.

**kwargs

Extra keyword arguments specific to upsert operation.

Returns
dict[str, typing.Any]

Returns result of the updated operation stats.

Previous morpheus.service.vdb.faiss_vdb_service.FaissVectorDBResourceService
Next morpheus.service.vdb.milvus_client
© Copyright 2024, NVIDIA. Last updated on Jul 8, 2024.