-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_milvus.py
More file actions
25 lines (21 loc) · 890 Bytes
/
setup_milvus.py
File metadata and controls
25 lines (21 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from pymilvus import connections, Collection, FieldSchema, CollectionSchema, DataType
import numpy as np
# Connect to Milvus
connections.connect("default", host="localhost", port="19530", max_receive_message_length=514983574, max_send_message_length=514983574)
# Create Collection Schema
fields = [
FieldSchema(name="id", dtype=DataType.INT64, is_primary=True),
FieldSchema(name="vector", dtype=DataType.FLOAT_VECTOR, dim=1536),
]
schema = CollectionSchema(fields, "DiskANN Benchmark Collection")
# Create Collection
collection_name = "diskann_openai"
collection = Collection(name=collection_name, schema=schema)
# Create DiskANN Index
index_params = {
"index_type": "DISKANN",
"metric_type": "COSINE",
"params": {"M": 64, "efConstruction": 200},
}
collection.create_index("vector", index_params)
print(f"Collection '{collection_name}' created with DiskANN index.")