graphragzen.text_embedding.vector_databases.QdrantLocalVectorDatabase
- class graphragzen.text_embedding.vector_databases.QdrantLocalVectorDatabase[source]
Attributes
Methods
add_vectors(vectors)Add vectors to the database
save(location)This is specific to the Qdrant local VectorDatabae.
search(query_vectors, k[, score_threshold, ...])Similarity search for each of the query vectors
- __init__(vector_size=None, database_location=None, overwrite_existing_db=False, distance_measure='Cosine', on_disk=False)[source]
Create or load a local Qdrant vector database and a client for interaction.
- Parameters:
vector_size (int, optional) – Length of the vectors to store. If a new database is created this must be provided. If a database if loaded this will be read from that database and the value provided here ignored.
database_location (str, optional) – Location to load the DB from or store a new DB. If not provided a new database will be created in qdrant/databases/. Defaults to None.
overwrite_existing_db (str, optional) – If True and a database is found at database_location it will be overwritten by a new database, otherwise the database found at database_location will be loaded. Defaults to False.
distance_measure (Literal['Cosine', 'Euclid', 'Dot', 'Manhattan'], optional) – Method to calculate distances between vectors. Defaults to ‘Cosine’
on_disk (bool, optional) – If true, vectors are served from disk, improving RAM usage at the cost of latency. Defaults to False.
- Return type:
None
- 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
- save(location)[source]
This is specific to the Qdrant local VectorDatabae. This function just copies the DB to a new location. Does not work for :memory: qdrant client instances since they life in RAM.
- Parameters:
location (str) – path to store the DB
- Return type:
None
- 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