From f8c4f2236a8024949f0456c3e059c6c906fd470c Mon Sep 17 00:00:00 2001 From: ChengZi Date: Tue, 4 Jun 2024 12:07:46 +0800 Subject: [PATCH] refine quickstart Signed-off-by: ChengZi --- .../tutorials/quickstart/quickstart.ipynb | 680 +++++++++++------- 1 file changed, 405 insertions(+), 275 deletions(-) diff --git a/bootcamp/tutorials/quickstart/quickstart.ipynb b/bootcamp/tutorials/quickstart/quickstart.ipynb index 16f088ad8..9516588a0 100644 --- a/bootcamp/tutorials/quickstart/quickstart.ipynb +++ b/bootcamp/tutorials/quickstart/quickstart.ipynb @@ -2,176 +2,241 @@ "cells": [ { "cell_type": "markdown", - "source": "\"Open", + "id": "cde9cd90b57efaaf", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "cde9cd90b57efaaf" + "source": [ + "\"Open" + ] }, { - "metadata": {}, "cell_type": "markdown", - "source": "# Quickstart with Milvus Lite", - "id": "a7ab72552b8d7e3a" + "id": "a7ab72552b8d7e3a", + "metadata": {}, + "source": [ + "# Quickstart with Milvus Lite" + ] }, { "cell_type": "markdown", + "id": "fa50f50f8c78cfe5", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "Vectors, the output data format of Neural Network models, can effectively encode information and serve a pivotal role in AI applications such as knowledge base, semantic search, Retrieval Augmented Generation (RAG) and more. \n", "\n", "Milvus is an open-source vector database that suits AI applications of every size from running a demo chatbot in Jupyter notebook to building web-scale search that serves billions of users. In this guide, we will walk you through how to set up Milvus locally within minutes and use the Python client library to generate, store and search vectors. " - ], - "metadata": { - "collapsed": false - }, - "id": "fa50f50f8c78cfe5" + ] }, { "cell_type": "markdown", + "id": "bc44bb33cc4950e3", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Install Milvus\n", "In this guide we use Milvus Lite, a python library included in `pymilvus` that can be embedded into the client application. Milvus also supports deployment on [Docker](https://milvus.io/docs/install_standalone-docker.md) and [Kubernetes](https://milvus.io/docs/install_cluster-milvusoperator.md) for production use cases.\n", "\n", "Before starting, make sure you have Python 3.7+ available in the local environment. Install `pymilvus` which contains both the python client library and Milvus Lite:" - ], - "metadata": { - "collapsed": false - }, - "id": "bc44bb33cc4950e3" + ] }, { "cell_type": "code", + "execution_count": null, "id": "initial_id", "metadata": { - "collapsed": true + "collapsed": true, + "jupyter": { + "outputs_hidden": true + } }, + "outputs": [], "source": [ "!pip install -U pymilvus" - ], - "outputs": [], - "execution_count": null + ] }, { - "metadata": {}, "cell_type": "markdown", - "source": "> If you are using Google Colab, to enable dependencies just installed, you may need to **restart the runtime**.", - "id": "f5fdf63111967483" + "id": "f5fdf63111967483", + "metadata": {}, + "source": [ + "> If you are using Google Colab, to enable dependencies just installed, you may need to **restart the runtime**." + ] }, { "cell_type": "markdown", + "id": "43237e11f0c52425", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Set Up Vector Database\n", "To create a local Milvus vector database, simply instantiate a `MilvusClient` by specifying a file name to store all data, such as \"milvus_demo.db\"." - ], - "metadata": { - "collapsed": false - }, - "id": "43237e11f0c52425" + ] }, { "cell_type": "code", + "execution_count": 1, + "id": "640b036a572d02fd", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [], "source": [ "from pymilvus import MilvusClient\n", "\n", "client = MilvusClient(\"milvus_demo.db\")" - ], - "metadata": { - "collapsed": false - }, - "id": "640b036a572d02fd", - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", + "id": "492e2ca1652be245", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Create a Collection\n", "In Milvus, we need a collection to store vectors and their associated metadata. You can think of it as a table in traditional SQL databases. When creating a collection, you can define schema and index params to configure vector specs such as dimensionality, index types and distant metrics. There are also complex concepts to optimize the index for vector search performance. For now, let's just focus on the basics and use default for everything possible. At minimum, you only need to set the collection name and the dimension of the vector field of the collection." - ], - "metadata": { - "collapsed": false - }, - "id": "492e2ca1652be245" + ] }, { "cell_type": "code", - "source": [ - "client.create_collection(\n", - " collection_name=\"demo_collection\",\n", - " dimension=768, # The vectors we will use in this demo has 768 dimensions\n", - ")" - ], + "execution_count": 2, + "id": "566d03c34d7ca94", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-05-22T07:53:48.940418Z", "start_time": "2024-05-22T07:53:48.423742Z" + }, + "collapsed": false, + "jupyter": { + "outputs_hidden": false } }, - "id": "566d03c34d7ca94", "outputs": [], - "execution_count": 5 + "source": [ + "client.create_collection(\n", + " collection_name=\"demo_collection\",\n", + " dimension=768, # The vectors we will use in this demo has 768 dimensions\n", + ")" + ] }, { "cell_type": "markdown", + "id": "9d1498d5e5dc46a7", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "In the above setup, \n", "- The primary key and vector fields use their default names (\"id\" and \"vector\").\n", "- The metric type (vector distance definition) is set to its default value ([COSINE](https://milvus.io/docs/metric.md#Cosine-Similarity)).\n", "- The primary key field accepts integers and does not automatically increments (namely not using [auto-id feature](https://milvus.io/docs/schema.md))\n", "Alternatively, you can formally define the schema of the collection by following this [instruction](https://milvus.io/api-reference/pymilvus/v2.4.x/MilvusClient/Collections/create_schema.md)." - ], - "metadata": { - "collapsed": false - }, - "id": "9d1498d5e5dc46a7" + ] }, { "cell_type": "markdown", + "id": "18e6a979541b1254", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Prepare Data\n", "In this guide, we use vectors to perform semantic search on text. We need to generate vectors for text by downloading embedding models. This can be easily done by using the utility functions from `pymilvus[model]` library." - ], - "metadata": { - "collapsed": false - }, - "id": "18e6a979541b1254" + ] }, { "cell_type": "markdown", + "id": "865920755266b514", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Represent text with vectors\n", "First, install the model library. This package includes essential ML tools such as PyTorch. The package download may take some time if your local environment has never installed PyTorch." - ], - "metadata": { - "collapsed": false - }, - "id": "865920755266b514" + ] }, { "cell_type": "code", - "source": [ - "!pip install \"pymilvus[model]\"" - ], + "execution_count": null, + "id": "c63363f1d4b8532e", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "c63363f1d4b8532e", "outputs": [], - "execution_count": null + "source": [ + "!pip install \"pymilvus[model]\"" + ] }, { "cell_type": "markdown", - "source": [ - "Generate vector embeddings with default model. Milvus expects data to be inserted organized as a list of dictionaries, where each dictionary represents a data record, termed as an entity. " - ], + "id": "2f6df7d93414560f", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "2f6df7d93414560f" + "source": [ + "Generate vector embeddings with default model. Milvus expects data to be inserted organized as a list of dictionaries, where each dictionary represents a data record, termed as an entity. " + ] }, { "cell_type": "code", + "execution_count": 3, + "id": "a02a7ef763ef98a7", + "metadata": { + "collapsed": false, + "is_executing": true, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Dim: 768 (768,)\n", + "Data has 3 entities, each with fields: dict_keys(['id', 'vector', 'text', 'subject'])\n", + "Vector dim: 768\n" + ] + } + ], "source": [ "from pymilvus import model\n", "\n", @@ -202,28 +267,46 @@ "\n", "print(\"Data has\", len(data), \"entities, each with fields: \", data[0].keys())\n", "print(\"Vector dim:\", len(data[0][\"vector\"]))" - ], - "metadata": { - "collapsed": false, - "is_executing": true - }, - "id": "a02a7ef763ef98a7", - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", + "id": "d118f4fea6418e94", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## [Alternatively] Use fake representation with random vectors\n", "If you couldn't download the model due to network issues, as a walkaround, you can use random vectors to represent the text and still finish the example. Just note that the search result won't reflect semantic similarity as the vectors are fake ones. " - ], - "metadata": { - "collapsed": false - }, - "id": "d118f4fea6418e94" + ] }, { "cell_type": "code", + "execution_count": 2, + "id": "8d41beeb9dfb3f84", + "metadata": { + "ExecuteTime": { + "end_time": "2024-05-22T07:53:05.724689Z", + "start_time": "2024-05-22T07:53:05.718610Z" + }, + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Data has 3 entities, each with fields: dict_keys(['id', 'vector', 'text', 'subject'])\n", + "Vector dim: 768\n" + ] + } + ], "source": [ "import random\n", "\n", @@ -242,53 +325,36 @@ "\n", "print(\"Data has\", len(data), \"entities, each with fields: \", data[0].keys())\n", "print(\"Vector dim:\", len(data[0][\"vector\"]))" - ], + ] + }, + { + "cell_type": "markdown", + "id": "b65418003fe51a1d", "metadata": { "collapsed": false, - "ExecuteTime": { - "end_time": "2024-05-22T07:53:05.724689Z", - "start_time": "2024-05-22T07:53:05.718610Z" + "jupyter": { + "outputs_hidden": false } }, - "id": "8d41beeb9dfb3f84", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Data has 3 entities, each with fields: dict_keys(['id', 'vector', 'text', 'subject'])\n", - "Vector dim: 768\n" - ] - } - ], - "execution_count": 2 - }, - { - "cell_type": "markdown", "source": [ "## Insert Data\n", "Let's insert the data into the collection:" - ], - "metadata": { - "collapsed": false - }, - "id": "b65418003fe51a1d" + ] }, { "cell_type": "code", - "source": [ - "res = client.insert(collection_name=\"demo_collection\", data=data)\n", - "\n", - "print(res)" - ], + "execution_count": 4, + "id": "49e17b12831018f3", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-05-22T07:53:57.061772Z", "start_time": "2024-05-22T07:53:56.995602Z" + }, + "collapsed": false, + "jupyter": { + "outputs_hidden": false } }, - "id": "49e17b12831018f3", "outputs": [ { "name": "stdout", @@ -298,88 +364,128 @@ ] } ], - "execution_count": 6 + "source": [ + "res = client.insert(collection_name=\"demo_collection\", data=data)\n", + "\n", + "print(res)" + ] }, { "cell_type": "markdown", + "id": "cc955d6f66fa7b26", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Semantic Search\n", "Now we can do semantic searches by representing the search query text as vector, and conduct vector similarity search on Milvus." - ], - "metadata": { - "collapsed": false - }, - "id": "cc955d6f66fa7b26" + ] }, { "cell_type": "markdown", + "id": "9c51c7dc6c1bec2f", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "### Vector search\n", "Milvus accepts one or multiple vector search requests at the same time. The value of the query_vectors variable is a list of vectors, where each vector is an array of float numbers." - ], - "metadata": { - "collapsed": false - }, - "id": "9c51c7dc6c1bec2f" + ] }, { "cell_type": "code", - "source": [ - "query_vectors = embedding_fn.encode_queries([\"Who is Alan Turing?\"])\n", - "# If you don't have the embedding function you can use a fake vector to finish the demo:\n", - "# query_vectors = [ [ random.uniform(-1, 1) for _ in range(768) ] ]\n", - "\n", - "res = client.search(\n", - " collection_name=\"demo_collection\", # target collection\n", - " data=query_vectors, # query vectors\n", - " limit=2, # number of returned entities\n", - " output_fields=[\"text\", \"subject\"], # specifies fields to be returned\n", - ")\n", - "\n", - "print(res)" - ], + "execution_count": 5, + "id": "9331e044d109d8a9", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-05-22T07:54:09.960354Z", "start_time": "2024-05-22T07:54:01.056095Z" + }, + "collapsed": false, + "jupyter": { + "outputs_hidden": false } }, - "id": "9331e044d109d8a9", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "data: [\"[{'id': 0, 'distance': 0.03993444889783859, 'entity': {'text': 'Artificial intelligence was founded as an academic discipline in 1956.', 'subject': 'history'}}, {'id': 1, 'distance': -0.008267653174698353, 'entity': {'text': 'Alan Turing was the first person to conduct substantial research in AI.', 'subject': 'history'}}]\"] , extra_info: {'cost': 0}\n" + "data: [\"[{'id': 2, 'distance': 0.5859944820404053, 'entity': {'text': 'Born in Maida Vale, London, Turing was raised in southern England.', 'subject': 'history'}}, {'id': 1, 'distance': 0.5118255615234375, 'entity': {'text': 'Alan Turing was the first person to conduct substantial research in AI.', 'subject': 'history'}}]\"] , extra_info: {'cost': 0}\n" ] } ], - "execution_count": 7 + "source": [ + "query_vectors = embedding_fn.encode_queries([\"Who is Alan Turing?\"])\n", + "# If you don't have the embedding function you can use a fake vector to finish the demo:\n", + "# query_vectors = [ [ random.uniform(-1, 1) for _ in range(768) ] ]\n", + "\n", + "res = client.search(\n", + " collection_name=\"demo_collection\", # target collection\n", + " data=query_vectors, # query vectors\n", + " limit=2, # number of returned entities\n", + " output_fields=[\"text\", \"subject\"], # specifies fields to be returned\n", + ")\n", + "\n", + "print(res)" + ] }, { "cell_type": "markdown", - "source": [ - "The output is a list of results, each mapping to a vector search query. Each query contains a list of results, where each result contains the entity primary key, the distance to the query vector, and the entity details with specified `output_fields`." - ], + "id": "aa7edf57d1b67710", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "aa7edf57d1b67710" + "source": [ + "The output is a list of results, each mapping to a vector search query. Each query contains a list of results, where each result contains the entity primary key, the distance to the query vector, and the entity details with specified `output_fields`." + ] }, { "cell_type": "markdown", + "id": "229fc50d34ca6130", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Vector Search with Metadata Filtering\n", "You can also conduct vector search while considering the values of the metadata (called \"scalar\" fields in Milvus, as scalar refers to non-vector data). This is done with a filter expression specifying certain criteria. Let's see how to search and filter with the `subject` field in the following example." - ], - "metadata": { - "collapsed": false - }, - "id": "229fc50d34ca6130" + ] }, { "cell_type": "code", + "execution_count": 6, + "id": "a8bf39cbc3ee9d13", + "metadata": { + "ExecuteTime": { + "end_time": "2024-05-22T07:54:18.582486Z", + "start_time": "2024-05-22T07:54:17.405245Z" + }, + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "data: [\"[{'id': 4, 'distance': 0.27030569314956665, 'entity': {'text': 'Computational synthesis with AI algorithms predicts molecular properties.', 'subject': 'biology'}}, {'id': 3, 'distance': 0.16425910592079163, 'entity': {'text': 'Machine learning has been used for drug design.', 'subject': 'biology'}}]\"] , extra_info: {'cost': 0}\n" + ] + } + ], "source": [ "# Insert more docs in another subject.\n", "docs = [\n", @@ -389,7 +495,7 @@ "]\n", "vectors = embedding_fn.encode_documents(docs)\n", "data = [\n", - " {\"id\": 2 + i, \"vector\": vectors[i], \"text\": docs[i], \"subject\": \"biology\"}\n", + " {\"id\": 3 + i, \"vector\": vectors[i], \"text\": docs[i], \"subject\": \"biology\"}\n", " for i in range(len(vectors))\n", "]\n", "\n", @@ -405,242 +511,266 @@ ")\n", "\n", "print(res)" - ], + ] + }, + { + "cell_type": "markdown", + "id": "25c791ec71c7ec7e", "metadata": { "collapsed": false, - "ExecuteTime": { - "end_time": "2024-05-22T07:54:18.582486Z", - "start_time": "2024-05-22T07:54:17.405245Z" + "jupyter": { + "outputs_hidden": false } }, - "id": "a8bf39cbc3ee9d13", - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "data: [\"[{'id': 3, 'distance': 0.27030572295188904, 'entity': {'text': 'Computational synthesis with AI algorithms predicts molecular properties.', 'subject': 'biology'}}, {'id': 2, 'distance': 0.16425888240337372, 'entity': {'text': 'Machine learning has been used for drug design.', 'subject': 'biology'}}]\"] , extra_info: {'cost': 0}\n" - ] - } - ], - "execution_count": 8 - }, - { - "cell_type": "markdown", "source": [ "By default, the scalar fields are not indexed. If you need to perform metadata filtered search in large dataset, you can consider using fixed schema and also turn on the [index](https://milvus.io/docs/scalar_index.md) to improve the search performance. \n", "\n", "In addition to vector search, you can also perform other types of searches:" - ], - "metadata": { - "collapsed": false - }, - "id": "25c791ec71c7ec7e" + ] }, { "cell_type": "markdown", + "id": "d45b9796b5a84931", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "### Query\n", "A query() is an operation that retrieves all entities matching a cretria, such as a [filter expression](https://milvus.io/docs/boolean.md) or matching some ids.\n", "\n", "For example, retrieving all entities whose scalar field has a particular value:" - ], - "metadata": { - "collapsed": false - }, - "id": "d45b9796b5a84931" + ] }, { "cell_type": "code", + "execution_count": 7, + "id": "b1421d2f94b591c5", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [], "source": [ "res = client.query(\n", " collection_name=\"demo_collection\",\n", " filter=\"subject == 'history'\",\n", " output_fields=[\"text\", \"subject\"],\n", ")" - ], - "metadata": { - "collapsed": false - }, - "id": "b1421d2f94b591c5", - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", - "source": [ - "Directly retrieve entities by primary key:" - ], + "id": "d1c5fd1eac35e5d7", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "d1c5fd1eac35e5d7" + "source": [ + "Directly retrieve entities by primary key:" + ] }, { "cell_type": "code", + "execution_count": 8, + "id": "8f87707ba48df498", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [], "source": [ "res = client.query(\n", " collection_name=\"demo_collection\",\n", " ids=[0, 2],\n", " output_fields=[\"vector\", \"text\", \"subject\"],\n", ")" - ], - "metadata": { - "collapsed": false - }, - "id": "8f87707ba48df498", - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", + "id": "881cb50a42d7f506", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Delete Entities\n", "If you'd like to purge data, you can delete entities specifying the primary key or delete all entities matching a particular filter expression." - ], - "metadata": { - "collapsed": false - }, - "id": "881cb50a42d7f506" + ] }, { "cell_type": "code", - "source": [ - "# Delete entities by primary key\n", - "res = client.delete(collection_name=\"demo_collection\", ids=[0, 2])\n", - "\n", - "print(res)\n", - "\n", - "# Delete entities by a filter expression\n", - "res = client.delete(\n", - " collection_name=\"demo_collection\",\n", - " filter=\"subject == 'biology'\",\n", - ")\n", - "\n", - "print(res)" - ], + "execution_count": 9, + "id": "32f93de9bd68aa74", "metadata": { - "collapsed": false, "ExecuteTime": { "end_time": "2024-05-22T07:54:32.290105Z", "start_time": "2024-05-22T07:54:32.271384Z" + }, + "collapsed": false, + "jupyter": { + "outputs_hidden": false } }, - "id": "32f93de9bd68aa74", "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[0, 2, 2]\n", - "[3, 4]\n" + "[0, 2]\n", + "[3, 4, 5]\n" ] } ], - "execution_count": 9 + "source": [ + "# Delete entities by primary key\n", + "res = client.delete(collection_name=\"demo_collection\", ids=[0, 2])\n", + "\n", + "print(res)\n", + "\n", + "# Delete entities by a filter expression\n", + "res = client.delete(\n", + " collection_name=\"demo_collection\",\n", + " filter=\"subject == 'biology'\",\n", + ")\n", + "\n", + "print(res)" + ] }, { "cell_type": "markdown", + "id": "dfba75a81b8a80b1", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Load Existing Data\n", "Since all data of Milvus Lite is stored in a local file, you can load all data into memory even after the program terminates, by creating a `MilvusClient` with the existing file. For example, this will recover the collections from \"milvus_demo.db\" file and continue to write data into it." - ], - "metadata": { - "collapsed": false - }, - "id": "dfba75a81b8a80b1" + ] }, { "cell_type": "code", + "execution_count": null, + "id": "8bd995809ec6e25d", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, + "outputs": [], "source": [ "from pymilvus import MilvusClient\n", "\n", "client = MilvusClient(\"milvus_demo.db\")" - ], - "metadata": { - "collapsed": false - }, - "id": "8bd995809ec6e25d", - "outputs": [], - "execution_count": null + ] }, { "cell_type": "markdown", + "id": "ff2ba854e8980606", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "## Drop the collection\n", "If you would like to delete all the data in a collection, you can drop the collection with" - ], - "metadata": { - "collapsed": false - }, - "id": "ff2ba854e8980606" + ] }, { "cell_type": "code", - "source": [ - "# 15. Drop collection\n", - "client.drop_collection(collection_name=\"demo_collection\")" - ], + "execution_count": null, + "id": "5f1480c2c9bdfb35", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "5f1480c2c9bdfb35", "outputs": [], - "execution_count": null + "source": [ + "# Drop collection\n", + "client.drop_collection(collection_name=\"demo_collection\")" + ] }, { "cell_type": "markdown", + "id": "72a3e10144cc6981", + "metadata": { + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } + }, "source": [ "Learn More\n", "Milvus Lite is great for getting started with a local python program. If you have large scale data or would like to use Milvus in production, you can learn about deploying Milvus on [Docker](https://milvus.io/docs/install_standalone-docker.md) and [Kubernetes](https://milvus.io/docs/install_cluster-milvusoperator.md). All deployment modes of Milvus share the same API, so your client side code doesn't need to change much if moving to another deployment mode. Simply specify the [URI and Token](https://milvus.io/api-reference/pymilvus/v2.4.x/MilvusClient/Client/MilvusClient.md) of a Milvus server deployed anywhere:" - ], - "metadata": { - "collapsed": false - }, - "id": "72a3e10144cc6981" + ] }, { "cell_type": "code", - "source": [ - "client = MilvusClient(uri=\"http://localhost:19530\", token=\"root:Milvus\")" - ], + "execution_count": null, + "id": "9d821310ac435b64", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "9d821310ac435b64", "outputs": [], - "execution_count": null + "source": [ + "client = MilvusClient(uri=\"http://localhost:19530\", token=\"root:Milvus\")" + ] }, { "cell_type": "markdown", - "source": [ - "Milvus provides REST and gRPC API, with client libraries in languages such as [Python](https://milvus.io/docs/install-pymilvus.md), [Java](https://milvus.io/docs/install-java.md), [Go](https://milvus.io/docs/install-go.md), C# and [Node.js](https://milvus.io/docs/install-node.md)." - ], + "id": "1d32ff4fe58e97eb", "metadata": { - "collapsed": false + "collapsed": false, + "jupyter": { + "outputs_hidden": false + } }, - "id": "1d32ff4fe58e97eb" + "source": [ + "Milvus provides REST and gRPC API, with client libraries in languages such as [Python](https://milvus.io/docs/install-pymilvus.md), [Java](https://milvus.io/docs/install-java.md), [Go](https://milvus.io/docs/install-go.md), C# and [Node.js](https://milvus.io/docs/install-node.md)." + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" + "pygments_lexer": "ipython3", + "version": "3.9.15" } }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file