pymilvus
pymilvus copied to clipboard
[Bug]: COSINE metric type not supported
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
When I use the code below to create a collection and create index for it
from pymilvus import Collection, DataType, FieldSchema, CollectionSchema
collection_name = "some_collection"
id_field = FieldSchema(name="id", dtype=DataType.INT64,
is_primary=True, description="auto id")
category_field = FieldSchema(
name="category", dtype=DataType.VARCHAR, max_length=65535, description="description of object")
created_at_field = FieldSchema(
name="created_at", dtype=DataType.INT64, description="unix seconds, publish time")
vector_field = FieldSchema(
name="vector", dtype=DataType.FLOAT_VECTOR, dim=VISUAL_EMBEDDING_DIM)
schema = CollectionSchema(fields=[id_field, category_field, created_at_field, vector_field],
auto_id=True,
description="Knowledge base that contians ")
collection = Collection(
name=collection_name, schema=schema)
index_params = {"index_type": "FLAT", "metric_type": "COSINE", "params": {"nlist": self.nlist}}
collection.create_index(
field_name=vector_field.name, index_params=index_params)
I got error
RPC error: [create_index], <MilvusException: (code=1, message=metric type not found or not supported, supported: [L2 IP])>, <Time:{'RPC start': '2023-10-09 04:02:01.609395', 'RPC error': '2023-10-09 04:02:01.629531'}>
It seems to indicate "COSINE" is not supported.
Expected Behavior
From the doc, https://milvus.io/docs/metric.md#Cosine-Similarity, COSINE should be supported
Steps/Code To Reproduce behavior
Run the code below:
from pymilvus import Collection, DataType, FieldSchema, CollectionSchema
collection_name = "some_collection"
id_field = FieldSchema(name="id", dtype=DataType.INT64,
is_primary=True, description="auto id")
category_field = FieldSchema(
name="category", dtype=DataType.VARCHAR, max_length=65535, description="description of object")
created_at_field = FieldSchema(
name="created_at", dtype=DataType.INT64, description="unix seconds, publish time")
vector_field = FieldSchema(
name="vector", dtype=DataType.FLOAT_VECTOR, dim=VISUAL_EMBEDDING_DIM)
schema = CollectionSchema(fields=[id_field, category_field, created_at_field, vector_field],
auto_id=True,
description="Knowledge base that contians ")
collection = Collection(
name=collection_name, schema=schema)
index_params = {"index_type": "FLAT", "metric_type": "COSINE", "params": {"nlist": self.nlist}}
collection.create_index(
field_name=vector_field.name, index_params=index_params)
Environment details
- Hardware/Softward conditions (OS, CPU, GPU, Memory):
MacOS
- Method of installation (Docker, or from source):
Docker
- Milvus version (v0.3.1, or v0.4.0):
pymilvus is v2.3.1, milvus version is v2.2.9
- Milvus configuration (Settings you made in `server_config.yaml`):
Anything else?
Did more research by creating the index from Attu, got the same result:
Is there anything I can do to enable COSINE metrics?
No response