Skip to content

Commit f7dbed4

Browse files
Milvus-doc-botMilvus-doc-bot
authored andcommitted
Translate blogs
1 parent b9c2a41 commit f7dbed4

25 files changed

+3261
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"codeList":["...\ncredential:\n aksk1:\n access_key_id: # Your access_key_id\n secret_access_key: # Your secret_access_key\n apikey1:\n apikey: \"***********************\" # Edit this section\n gcp1:\n credential_json: # base64 based gcp credential data\n# Any configuration related to functions\nfunction:\n textEmbedding:\n providers:\n ...\n cohere: # Edit the section below\n credential: apikey1 # The name in the crendential configuration item\n enable: true # Whether to enable cohere model service\n url: \"https://api.cohere.com/v2/embed\" # Your cohere embedding url, Default is the official embedding url\n ...\n...\n","from pymilvus import MilvusClient, DataType, Function, FunctionType\n# Initialize Milvus client\nclient = MilvusClient(\n uri=\"http://localhost:19530\",\n)\n# Create a new schema for the collection\nschema = client.create_schema()\n# Add primary field \"id\"\nschema.add_field(\"id\", DataType.INT64, is_primary=True, auto_id=False)\n# Add scalar field \"document\" for storing textual data\nschema.add_field(\"document\", DataType.VARCHAR, max_length=9000)\n# Add vector field \"dense\" for storing embeddings.\n# IMPORTANT: Set `dim` to match the exact output dimension of the embedding model.\n# For instance, OpenAI's text-embedding-3-small model outputs 1536-dimensional vectors.\n# For dense vector, data type can be FLOAT_VECTOR or INT8_VECTOR\nschema.add_field(\"dense\", DataType.FLOAT_VECTOR, dim=1536) # Set dim according to the embedding model you use.\n","# Define embedding function (example: OpenAI provider)\ntext_embedding_function = Function(\n name=\"cohere_embedding\", # Unique identifier for this embedding function\n function_type=FunctionType.TEXTEMBEDDING, # Type of embedding function\n input_field_names=[\"document\"], # Scalar field to embed\n output_field_names=[\"dense\"], # Vector field to store embeddings\n params={ # Provider-specific configuration (highest priority)\n \"provider\": \"cohere\", # Embedding model provider\n \"model_name\": \"embed-v4.0\", # Embedding model\n # \"credential\": \"apikey1\", # Optional: Credential label\n # Optional parameters:\n # \"dim\": \"1536\", # Optionally shorten the vector dimension\n # \"user\": \"user123\" # Optional: identifier for API tracking\n }\n)\n# Add the embedding function to your schema\nschema.add_function(text_embedding_function)\n","# Prepare index parameters\nindex_params = client.prepare_index_params()\n# Add AUTOINDEX to automatically select optimal indexing method\nindex_params.add_index(\n field_name=\"dense\",\n index_type=\"AUTOINDEX\",\n metric_type=\"COSINE\" \n)\n","# Create collection named \"demo\"\nclient.create_collection(\n collection_name='demo', \n schema=schema, \n index_params=index_params\n)\n","# Insert sample documents\nclient.insert('demo', [\n {'id': 1, 'document': 'Milvus simplifies semantic search through embeddings.'},\n {'id': 2, 'document': 'Vector embeddings convert text into searchable numeric data.'},\n {'id': 3, 'document': 'Semantic search helps users find relevant information quickly.'},\n])\n","# Perform semantic search\nresults = client.search(\n collection_name='demo', \n data=['How does Milvus handle semantic search?'], # Use text query rather than query vector\n anns_field='dense', # Use the vector field that stores embeddings\n limit=1,\n output_fields=['document'],\n)\nprint(results)\n# Example output:\n# data: [\"[{'id': 1, 'distance': 0.8821347951889038, 'entity': {'document': 'Milvus simplifies semantic search through embeddings.'}}]\"]\n"],"headingContent":"","anchorList":[{"label":"ما هو إدخال البيانات وإخراج البيانات؟","href":"What-is-Data-in-Data-out","type":2,"isActive":false},{"label":"كيف يعمل إدخال البيانات وإخراج البيانات","href":"How-Data-in-Data-out-Works","type":2,"isActive":false},{"label":"كيفية تكوين إدخال البيانات وإخراج البيانات","href":"How-to-Configure-Data-in-Data-out","type":2,"isActive":false},{"label":"كيفية استخدام خاصية إدخال البيانات وإخراج البيانات","href":"How-to-Use-the-Data-in-Data-out-Feature","type":2,"isActive":false},{"label":"ابدأ مع ميلفوس 2.6","href":"Get-Started-with-Milvus-26","type":2,"isActive":false},{"label":"تعرف على المزيد حول ميزات Milvus 2.6","href":"Learn-More-about-Milvus-26-Features","type":2,"isActive":false}]}

0 commit comments

Comments
 (0)