graphragzen.text_embedding.vector_databases.VectorDatabase

class graphragzen.text_embedding.vector_databases.VectorDatabase[source]

Attributes

distance_measure

vector_size

Methods

add_vectors(vectors)

Add vectors to the database

search(query_vectors, k[, score_threshold, ...])

Similarity search for each of the query vectors

abstract __init__()[source]

Initialize the client to communicate to the vector DB backend of your choice

Return type:

None

abstract add_vectors(vectors)[source]

Add vectors to the database

Parameters:

vectors (List[dict]) – Each dict containing {“uuid”: …, “vector”: …}. Each dict may also contain the key and values {“metadata”: …}, which will be store with the vector and retrieved upon search.

Return type:

None

distance_measure: str
abstract search(query_vectors, k, score_threshold=0.0, filters={})[source]

Similarity search for each of the query vectors

Parameters:
  • query_vectors (np.ndarray) – Vectors for n queries, shaped (n x embedding_size)

  • k (int) – Max number of results to return per query vector.

  • score_threshold (float, optional) – Exclude all vector search results with a score worse than his. Defaults to 0.0

  • filters (dict, optional) – {“key”: “value_it_should_have”, “key2”: “value_it …..

Returns:

Per query List[dict] with each dict containing

{“uuid”: …, “score”: …, “metadata”: …}

Return type:

List[List[dict]]

vector_size: int