Qdrant¶
Qdrant is a high-performance vector similarity search engine and database. It offers a robust, production-ready service with an intuitive API that allows users to store, search, and manage vectors, along with additional payloads.
Qdrant supports advanced filtering, making it ideal for applications involving neural network or semantic-based matching, faceted search, and more. Its capabilities are particularly beneficial for developing applications that require efficient and scalable vector search solutions.
Configuration¶
To use the Qdrant vector database, you need to configure it in your YAML configuration file. Here’s an example configuration:
- name: openai_embed_3_large
db_type: qdrant
embedding_model: openai_embed_3_large
collection_name: openai_embed_3_large
client_type: docker
embedding_batch: 50
similarity_metric: cosine
dimension: 1536
embedding_model: str
Purpose: Specifies the name or identifier of the embedding model to be used.
Example: “openai_embed_3_large”
Note: This should correspond to a valid embedding model that your system can use to generate vector embeddings. For more information see custom your embedding model documentation.
collection_name: str
Purpose: Sets the name of the Qdrant collection where the vectors will be stored.
Example: “my_vector_collection”
Note: If the collection doesn’t exist, it will be created. If it exists, it will be loaded.
embedding_batch: int = 100
Purpose: Determines the number of embeddings to process in a single batch.
Default: 100
Note: Adjust this based on your system’s memory and processing capabilities. Larger batches may be faster but require more memory.
similarity_metric: str = "cosine"
Purpose: Specifies the metric used to calculate similarity between vectors.
Default: “cosine”
Options: “cosine”, “l2” (Euclidean distance), “ip” (Inner Product)
Note: Choose the metric that best suits your use case and data characteristics.
Not support “manhattan”
client_type = "docker"
Purpose: Specifies the type of client you’re using to connect to Weaviate.
Default: “docker”
Options: “docker”, “cloud”
Note: Choose the appropriate client type based on your deployment.
url: str = "http://localhost:6333"
Purpose: The URL of the Qdrant server.
Default: “http://localhost:6333”
Note: Use only
client_type: docker
. You can see full information at here
host: str
Purpose: The host of the Qdrant server.
Default: “”
Note: Use only
client_type: cloud
. You can see full information at here
api_key: str
Purpose: The API key for authentication with the Qdrant server.
Default: “”
Note: Use only
client_type: cloud
. You can see full information at here
dimension: int = 1536
Purpose: Specifies the dimension of the vector embeddings.
Default: 1536
Note: This should correspond to the dimension of the embeddings generated by the specified embedding model.
ingest_batch: int = 64
Purpose: Determines the number of vectors to ingest in a single batch.
Default: 64
Note: Adjust this based on your system’s memory and processing capabilities. Larger batches may be faster but require more memory.
parallel: int = 1
Purpose: Determines the number of parallel requests to the Qdrant server.
Default: 1
Note: Adjust this based on your system’s processing capabilities. Increasing parallel requests can improve performance.
max_retries: int = 3
Purpose: Specifies the maximum number of retries for failed requests to the Qdrant server.
Default: 3
Note: Set this based on your system’s network reliability and the expected failure rate.
Usage¶
Here’s a brief overview of how to use the main functions of the Qdrant vector database:
Adding Vectors:
await qdrant_db.add(ids, texts)
This method adds new vectors to the database. It takes a list of IDs and corresponding texts, generates embeddings, and inserts them into the Qdrant collection.
Querying:
ids, distances = await qdrant_db.query(queries, top_k)
Performs a similarity search on the stored vectors. It returns the IDs of the most similar vectors and their distances.
Fetching Vectors:
vectors = await qdrant_db.fetch(ids)
Retrieves the vectors associated with the given IDs.
Checking Existence:
exists = await qdrant_db.is_exist(ids)
Checks if the given IDs exist in the database.
Deleting Vectors:
await qdrant_db.delete(ids)
Deletes the vectors associated with the given IDs from the database.
Deleting the Collection:
qdrant_db.delete_collection()
Deletes the collection from the Qdrant server.