-
Here is my example: from qdrant_client.models import Distance, VectorParams
from qdrant_client import QdrantClient
# Initialize the client
client = QdrantClient(":memory:")
client.create_collection(
collection_name="test_collection",
vectors_config=VectorParams(size=384, distance=Distance.COSINE),
)
# Prepare your documents, metadata, and IDs
docs = [
"Qdrant has Langchain integrations",
"Qdrant also has Llama Index integrations",
] * 5
metadata = [
{"source": "Langchain-docs"},
{"source": "Linkedin-docs"},
] * 5
client.add(collection_name="test_collection", documents=docs, metadata=metadata) If I try to Traceback (most recent call last):
File "/Users/lev/Developer/poetry-demo/poetry_demo/qdrant.py", line 40, in <module>
client.add(collection_name="test_collection", documents=docs, metadata=metadata)
File "/Users/lev/.pyenv/versions/3.11.1/envs/testing-venv/lib/python3.11/site-packages/qdrant_client/qdrant_fastembed.py", line 496, in add
self._validate_collection_info(collection_info)
File "/Users/lev/.pyenv/versions/3.11.1/envs/testing-venv/lib/python3.11/site-packages/qdrant_client/qdrant_fastembed.py", line 348, in _validate_collection_info
assert isinstance(
AssertionError: Collection have incompatible vector params: size=384 distance=<Distance.COSINE: 'Cosine'> hnsw_config=None quantization_config=None on_disk=None This is an issue because if I want to use the search_result = client.search(
collection_name="demo_collection", query_vector=[0.1, 0.2, 0.3, 0.4]
) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hello @bnkc With pure qdrant-client API (without fastembed mixin's methods like However, fastembed creates named vectors and operates with them. Names of the vectors are generated from the chosen model names. models.NamedVector(
name=client.get_vector_field_name(), vector=query_vector
) If collection was not created, then the first call to |
Beta Was this translation helpful? Give feedback.
-
Hi @joein Thanks! This worked for me :) |
Beta Was this translation helpful? Give feedback.
Hello @bnkc
With pure qdrant-client API (without fastembed mixin's methods like
add
andquery
), you can have unnamed vectors, which means that you don't need to provide a name.However, fastembed creates named vectors and operates with them. Names of the vectors are generated from the chosen model names.
Thus, to do
search
, you need to setquery_vector
to a some named vector, e.g.:If collection was not created, then the first call to
add
creates it.If you want to create it on your own, take a look at
get_fastembed_vector_params
method