From d5c47c2d8bc7e5bac039574d9439da0f7699f481 Mon Sep 17 00:00:00 2001 From: Ryan Lin Date: Thu, 7 Nov 2024 09:55:12 -0500 Subject: [PATCH 1/3] movie recommendation updated --- .../movie_recommendation_with_milvus.ipynb | 112 +++++++++++------- 1 file changed, 69 insertions(+), 43 deletions(-) diff --git a/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb b/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb index c3c12a342..5693f53a5 100644 --- a/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb +++ b/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb @@ -71,8 +71,8 @@ "metadata": { "id": "E8LsgeBzDIv8", "ExecuteTime": { - "end_time": "2024-10-28T03:58:17.790191Z", - "start_time": "2024-10-28T03:58:17.785125Z" + "end_time": "2024-11-07T14:44:34.388119Z", + "start_time": "2024-11-07T14:44:34.382907Z" } }, "outputs": [], @@ -98,8 +98,8 @@ "metadata": { "id": "aBOi2mvKDIv8", "ExecuteTime": { - "end_time": "2024-10-28T03:58:19.501086Z", - "start_time": "2024-10-28T03:58:19.049909Z" + "end_time": "2024-11-07T14:44:37.001079Z", + "start_time": "2024-11-07T14:44:36.478485Z" } }, "outputs": [], @@ -122,11 +122,11 @@ "cell_type": "code", "execution_count": 3, "metadata": { + "id": "4rXlQ29MDIv8", "ExecuteTime": { - "end_time": "2024-10-28T02:52:31.594866Z", - "start_time": "2024-10-28T02:52:31.584663Z" - }, - "id": "4rXlQ29MDIv8" + "end_time": "2024-11-07T14:44:39.211149Z", + "start_time": "2024-11-07T14:44:39.204396Z" + } }, "outputs": [], "source": [ @@ -147,13 +147,17 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "VUXhaRtQDIv8", - "outputId": "ac2c222b-9af3-4b64-d8dd-cf5b3fe2f376" + "outputId": "ac2c222b-9af3-4b64-d8dd-cf5b3fe2f376", + "ExecuteTime": { + "end_time": "2024-11-07T14:44:47.071483Z", + "start_time": "2024-11-07T14:44:42.346352Z" + } }, "outputs": [], "source": [ @@ -179,11 +183,11 @@ "cell_type": "code", "execution_count": 5, "metadata": { + "id": "eaBFyWQPDIv8", "ExecuteTime": { - "end_time": "2024-10-28T02:52:32.123914Z", - "start_time": "2024-10-28T02:52:32.116018Z" - }, - "id": "eaBFyWQPDIv8" + "end_time": "2024-11-07T14:44:50.013484Z", + "start_time": "2024-11-07T14:44:50.008202Z" + } }, "outputs": [], "source": [ @@ -198,25 +202,27 @@ "id": "rmt5EIn8DIv8" }, "source": [ - "Define the fields for the collection, which include the id, title, type, release year, rating, and description." + "Define the fields for the collection, which include the id, title, type, release year, rating, description, and embedding." ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "xf5YMsDmDIv8", - "outputId": "b26cb009-8a82-4cfd-9d76-db6323d0df69" + "outputId": "b26cb009-8a82-4cfd-9d76-db6323d0df69", + "ExecuteTime": { + "end_time": "2024-11-07T14:44:58.337161Z", + "start_time": "2024-11-07T14:44:58.331295Z" + } }, "outputs": [], "source": [ "from pymilvus import DataType\n", "\n", - "# Create collection which includes the id, title, and embedding.\n", - "\n", "# 1. Create schema\n", "schema = MilvusClient.create_schema(\n", " auto_id=True,\n", @@ -247,34 +253,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "K9fwi332DIv8", - "outputId": "d9e1e36a-4830-491f-ce3b-be1974a363cf" + "outputId": "d9e1e36a-4830-491f-ce3b-be1974a363cf", + "ExecuteTime": { + "end_time": "2024-11-07T14:45:10.282754Z", + "start_time": "2024-11-07T14:45:09.768800Z" + } }, "outputs": [], "source": [ - "# Create the index on the collection and load it.\n", - "\n", "# 1. Prepare index parameters\n", "index_params = client.prepare_index_params()\n", "\n", - "\n", "# 2. Add an index on the embedding field\n", "index_params.add_index(\n", " field_name=\"embedding\", metric_type=\"IP\", index_type=\"AUTOINDEX\", params={}\n", ")\n", "\n", - "\n", "# 3. Create index\n", - "client.create_index(collection_name=COLLECTION_NAME, index_params=index_params)\n", - "\n", - "\n", - "# 4. Load collection\n", - "client.load_collection(collection_name=COLLECTION_NAME, replica_number=1)" + "client.create_index(collection_name=COLLECTION_NAME, index_params=index_params)" ] }, { @@ -289,7 +291,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -331,7 +333,11 @@ ] }, "id": "7pyst3ZBDIv8", - "outputId": "4f477b23-f190-4a36-905a-3884e40e70b9" + "outputId": "4f477b23-f190-4a36-905a-3884e40e70b9", + "ExecuteTime": { + "end_time": "2024-11-07T14:45:16.696358Z", + "start_time": "2024-11-07T14:45:13.628050Z" + } }, "outputs": [], "source": [ @@ -354,7 +360,11 @@ "cell_type": "code", "execution_count": 9, "metadata": { - "id": "YBi6ria2DIv8" + "id": "YBi6ria2DIv8", + "ExecuteTime": { + "end_time": "2024-11-07T14:45:20.867937Z", + "start_time": "2024-11-07T14:45:20.862589Z" + } }, "outputs": [], "source": [ @@ -406,10 +416,22 @@ "base_uri": "https://localhost:8080/" }, "id": "hMIpsCJUDrO3", - "outputId": "957f4502-dc50-49cc-c534-f447a7451445" + "outputId": "957f4502-dc50-49cc-c534-f447a7451445", + "ExecuteTime": { + "end_time": "2024-11-07T14:45:56.945419Z", + "start_time": "2024-11-07T14:45:23.849009Z" + } }, - "execution_count": null, - "outputs": [] + "execution_count": 10, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "100%|██████████| 8807/8807 [00:33<00:00, 266.16it/s]\n" + ] + } + ] }, { "cell_type": "markdown", @@ -429,36 +451,40 @@ "base_uri": "https://localhost:8080/" }, "id": "ohIMv8stDIv9", - "outputId": "67186ad6-3522-4f3f-c20d-c67693c05b5e" + "outputId": "67186ad6-3522-4f3f-c20d-c67693c05b5e", + "ExecuteTime": { + "end_time": "2024-11-07T14:51:05.805711Z", + "start_time": "2024-11-07T14:51:05.185586Z" + } }, "outputs": [ { - "output_type": "stream", "name": "stdout", + "output_type": "stream", "text": [ "Description: movie about a fluffly animal Expression: release_year < 2019 and rating like \"PG%\"\n", "Results:\n", - "\tRank: 1 Score: 0.42213767766952515 Title: The Adventures of Tintin\n", + "\tRank: 1 Score: 0.4221074879169464 Title: The Adventures of Tintin\n", "\t\tType: Movie Release Year: 2011 Rating: PG\n", "This 3-D motion capture adapts Georges Remi's classic comic strip about the adventures\n", "of fearless young journalist Tintin and his trusty dog, Snowy.\n", "\n", - "\tRank: 2 Score: 0.4041026830673218 Title: Hedgehogs\n", + "\tRank: 2 Score: 0.4041031002998352 Title: Hedgehogs\n", "\t\tType: Movie Release Year: 2016 Rating: PG\n", "When a hedgehog suffering from memory loss forgets his identity, he ends up on a big\n", "city journey with a pigeon to save his habitat from a human threat.\n", "\n", - "\tRank: 3 Score: 0.3980264663696289 Title: Osmosis Jones\n", + "\tRank: 3 Score: 0.3980264365673065 Title: Osmosis Jones\n", "\t\tType: Movie Release Year: 2001 Rating: PG\n", "Peter and Bobby Farrelly outdo themselves with this partially animated tale about an\n", "out-of-shape 40-year-old man who's the host to various organisms.\n", "\n", - "\tRank: 4 Score: 0.39479154348373413 Title: The Lamb\n", + "\tRank: 4 Score: 0.3947935104370117 Title: The Lamb\n", "\t\tType: Movie Release Year: 2017 Rating: PG\n", "A big-dreaming donkey escapes his menial existence and befriends some free-spirited\n", "animal pals in this imaginative retelling of the Nativity Story.\n", "\n", - "\tRank: 5 Score: 0.39370301365852356 Title: Open Season 2\n", + "\tRank: 5 Score: 0.39370331168174744 Title: Open Season 2\n", "\t\tType: Movie Release Year: 2008 Rating: PG\n", "Elliot the buck and his forest-dwelling cohorts must rescue their dachshund pal from\n", "some spoiled pets bent on returning him to domesticity.\n" From 11383223ffaa04dca54f95ed4bea9ab2f7aac971 Mon Sep 17 00:00:00 2001 From: Ryan Lin Date: Sat, 9 Nov 2024 23:45:37 -0500 Subject: [PATCH 2/3] added back load collection --- .../movie_recommendation_with_milvus.ipynb | 70 ++++++++++--------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb b/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb index 5693f53a5..bb37d101c 100644 --- a/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb +++ b/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb @@ -71,14 +71,13 @@ "metadata": { "id": "E8LsgeBzDIv8", "ExecuteTime": { - "end_time": "2024-11-07T14:44:34.388119Z", - "start_time": "2024-11-07T14:44:34.382907Z" + "end_time": "2024-11-10T04:43:29.331948Z", + "start_time": "2024-11-10T04:43:29.322790Z" } }, "outputs": [], "source": [ "import os\n", - "\n", "os.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"" ] }, @@ -98,8 +97,8 @@ "metadata": { "id": "aBOi2mvKDIv8", "ExecuteTime": { - "end_time": "2024-11-07T14:44:37.001079Z", - "start_time": "2024-11-07T14:44:36.478485Z" + "end_time": "2024-11-10T04:43:29.739181Z", + "start_time": "2024-11-10T04:43:29.333409Z" } }, "outputs": [], @@ -124,8 +123,8 @@ "metadata": { "id": "4rXlQ29MDIv8", "ExecuteTime": { - "end_time": "2024-11-07T14:44:39.211149Z", - "start_time": "2024-11-07T14:44:39.204396Z" + "end_time": "2024-11-10T04:43:29.746569Z", + "start_time": "2024-11-10T04:43:29.740806Z" } }, "outputs": [], @@ -147,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -155,8 +154,8 @@ "id": "VUXhaRtQDIv8", "outputId": "ac2c222b-9af3-4b64-d8dd-cf5b3fe2f376", "ExecuteTime": { - "end_time": "2024-11-07T14:44:47.071483Z", - "start_time": "2024-11-07T14:44:42.346352Z" + "end_time": "2024-11-10T04:44:04.205921Z", + "start_time": "2024-11-10T04:44:03.187020Z" } }, "outputs": [], @@ -181,12 +180,12 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": { "id": "eaBFyWQPDIv8", "ExecuteTime": { - "end_time": "2024-11-07T14:44:50.013484Z", - "start_time": "2024-11-07T14:44:50.008202Z" + "end_time": "2024-11-10T04:44:06.851427Z", + "start_time": "2024-11-10T04:44:06.768643Z" } }, "outputs": [], @@ -207,7 +206,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -215,8 +214,8 @@ "id": "xf5YMsDmDIv8", "outputId": "b26cb009-8a82-4cfd-9d76-db6323d0df69", "ExecuteTime": { - "end_time": "2024-11-07T14:44:58.337161Z", - "start_time": "2024-11-07T14:44:58.331295Z" + "end_time": "2024-11-10T04:44:08.634998Z", + "start_time": "2024-11-10T04:44:08.631894Z" } }, "outputs": [], @@ -253,7 +252,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -261,8 +260,8 @@ "id": "K9fwi332DIv8", "outputId": "d9e1e36a-4830-491f-ce3b-be1974a363cf", "ExecuteTime": { - "end_time": "2024-11-07T14:45:10.282754Z", - "start_time": "2024-11-07T14:45:09.768800Z" + "end_time": "2024-11-10T04:44:11.606543Z", + "start_time": "2024-11-10T04:44:11.097780Z" } }, "outputs": [], @@ -276,7 +275,10 @@ ")\n", "\n", "# 3. Create index\n", - "client.create_index(collection_name=COLLECTION_NAME, index_params=index_params)" + "client.create_index(collection_name=COLLECTION_NAME, index_params=index_params)\n", + "\n", + "# 4. Load Collection\n", + "client.load_collection(collection_name=COLLECTION_NAME)" ] }, { @@ -291,7 +293,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "colab": { "base_uri": "https://localhost:8080/", @@ -335,8 +337,8 @@ "id": "7pyst3ZBDIv8", "outputId": "4f477b23-f190-4a36-905a-3884e40e70b9", "ExecuteTime": { - "end_time": "2024-11-07T14:45:16.696358Z", - "start_time": "2024-11-07T14:45:13.628050Z" + "end_time": "2024-11-10T04:44:16.177399Z", + "start_time": "2024-11-10T04:44:13.214578Z" } }, "outputs": [], @@ -358,12 +360,12 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": { "id": "YBi6ria2DIv8", "ExecuteTime": { - "end_time": "2024-11-07T14:45:20.867937Z", - "start_time": "2024-11-07T14:45:20.862589Z" + "end_time": "2024-11-10T04:44:16.183133Z", + "start_time": "2024-11-10T04:44:16.179165Z" } }, "outputs": [], @@ -418,17 +420,17 @@ "id": "hMIpsCJUDrO3", "outputId": "957f4502-dc50-49cc-c534-f447a7451445", "ExecuteTime": { - "end_time": "2024-11-07T14:45:56.945419Z", - "start_time": "2024-11-07T14:45:23.849009Z" + "end_time": "2024-11-10T04:44:50.716217Z", + "start_time": "2024-11-10T04:44:17.361030Z" } }, - "execution_count": 10, + "execution_count": 11, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ - "100%|██████████| 8807/8807 [00:33<00:00, 266.16it/s]\n" + "100%|██████████| 8807/8807 [00:33<00:00, 264.06it/s]\n" ] } ] @@ -445,7 +447,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": { "colab": { "base_uri": "https://localhost:8080/" @@ -453,8 +455,8 @@ "id": "ohIMv8stDIv9", "outputId": "67186ad6-3522-4f3f-c20d-c67693c05b5e", "ExecuteTime": { - "end_time": "2024-11-07T14:51:05.805711Z", - "start_time": "2024-11-07T14:51:05.185586Z" + "end_time": "2024-11-10T04:44:51.025459Z", + "start_time": "2024-11-10T04:44:50.720202Z" } }, "outputs": [ @@ -464,7 +466,7 @@ "text": [ "Description: movie about a fluffly animal Expression: release_year < 2019 and rating like \"PG%\"\n", "Results:\n", - "\tRank: 1 Score: 0.4221074879169464 Title: The Adventures of Tintin\n", + "\tRank: 1 Score: 0.4221227169036865 Title: The Adventures of Tintin\n", "\t\tType: Movie Release Year: 2011 Rating: PG\n", "This 3-D motion capture adapts Georges Remi's classic comic strip about the adventures\n", "of fearless young journalist Tintin and his trusty dog, Snowy.\n", From 3a399ab0f9c6fc2244fb6468dfd7540073ea563d Mon Sep 17 00:00:00 2001 From: Ryan Lin Date: Sat, 9 Nov 2024 23:46:51 -0500 Subject: [PATCH 3/3] added back load collection --- .../tutorials/quickstart/movie_recommendation_with_milvus.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb b/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb index bb37d101c..d7eba3d36 100644 --- a/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb +++ b/bootcamp/tutorials/quickstart/movie_recommendation_with_milvus.ipynb @@ -78,6 +78,7 @@ "outputs": [], "source": [ "import os\n", + "\n", "os.environ[\"OPENAI_API_KEY\"] = \"sk-***********\"" ] },