pymilvus icon indicating copy to clipboard operation
pymilvus copied to clipboard

(code=1, message=The data type of field vector doesn't match, expected: FLOAT_VECTOR, got DOUBLE)>

Open GzRichChen opened this issue 1 year ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

What is your question?

embeddings = outputs.last_hidden_state[0].mean(dim=0) print("embeddings:", embeddings) print("embeddings.len:", len(embeddings)) connections.connect(host='localhost', port='19530') law_id = FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True) law_vector = FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=768)

collection_schema = CollectionSchema(fields=[law_id, law_vector], auto_id=True) collection = Collection(name='law_key', schema=collection_schema) #collection = Collection(name='law_key') index_param = { "index_type": "IVF_FLAT", "params": {"nlist": 1024}, "metric_type": "IP" } collection.create_index(field_name='vector', index_params=index_param)

embeddings_float = embeddings.float() #here is change type collection.insert([embeddings_float.tolist()]) #but expected: FLOAT_VECTOR, got DOUBLE

Anything else?

Please help me

GzRichChen avatar Oct 12 '23 03:10 GzRichChen

@GzRichChen We need a list[list[float]] for vector field, seems like embemddings_float.tolist() isn't a list[list[float]] but a list[double]

XuanYang-cn avatar Oct 16 '23 07:10 XuanYang-cn