From c67f969194a3f07082072c9a7bb1a40dd0b06d8d Mon Sep 17 00:00:00 2001 From: Thanawan Atchariyachanvanit Date: Wed, 9 Aug 2023 16:06:38 -0700 Subject: [PATCH] Correct demo_ml_commons_integration.ipynb (#208) * Correct demo_ml_commons_integration.ipynb Signed-off-by: Thanawan Atchariyachanvanit * Update CHANGELOG.md Signed-off-by: Thanawan Atchariyachanvanit --------- Signed-off-by: Thanawan Atchariyachanvanit --- CHANGELOG.md | 1 + .../demo_ml_commons_integration.ipynb | 109 ++++++++---------- .../ml_commons/ml_commons_client.py | 1 + 3 files changed, 50 insertions(+), 61 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd5c14ed9..a12e045b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Fixed - Enable make_model_config_json to add model description to model config file by @thanawan-atc in ([#203](https://github.com/opensearch-project/opensearch-py-ml/pull/203)) +- Correct demo_ml_commons_integration.ipynb by @thanawan-atc in ([#208](https://github.com/opensearch-project/opensearch-py-ml/pull/208)) ## [1.1.0] diff --git a/docs/source/examples/demo_ml_commons_integration.ipynb b/docs/source/examples/demo_ml_commons_integration.ipynb index 4ed4a28a2..3d7ec373b 100644 --- a/docs/source/examples/demo_ml_commons_integration.ipynb +++ b/docs/source/examples/demo_ml_commons_integration.ipynb @@ -32,10 +32,9 @@ }, { "cell_type": "markdown", - "source": [], - "metadata": { - "collapsed": false - } + "id": "e9693720", + "metadata": {}, + "source": [] }, { "cell_type": "markdown", @@ -49,7 +48,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "17a3e085", "metadata": { "pycharm": { @@ -64,7 +63,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 2, "id": "f12096cd", "metadata": {}, "outputs": [ @@ -72,17 +71,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001B[33mDEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621\u001B[0m\u001B[33m\n", - "\u001B[0mCollecting deprecated\n", - " Downloading Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB)\n", - "Requirement already satisfied: wrapt<2,>=1.10 in /usr/local/lib/python3.9/site-packages (from deprecated) (1.13.3)\n", - "Installing collected packages: deprecated\n", - "\u001B[33m DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621\u001B[0m\u001B[33m\n", - "\u001B[0m\u001B[33mDEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621\u001B[0m\u001B[33m\n", - "\u001B[0mSuccessfully installed deprecated-1.2.14\n", - "\n", - "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip is available: \u001B[0m\u001B[31;49m23.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m23.1.2\u001B[0m\n", - "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpython3.9 -m pip install --upgrade pip\u001B[0m\n" + "\u001b[33mDEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621\u001b[0m\u001b[33m\n", + "\u001b[0mRequirement already satisfied: deprecated in /home/linuxbrew/.linuxbrew/lib/python3.9/site-packages (1.2.14)\n", + "Requirement already satisfied: wrapt<2,>=1.10 in /home/linuxbrew/.linuxbrew/lib/python3.9/site-packages (from deprecated) (1.15.0)\n", + "\u001b[33mDEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621\u001b[0m\u001b[33m\n", + "\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.1.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.2.1\u001b[0m\n", + "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython3.9 -m pip install --upgrade pip\u001b[0m\n" ] } ], @@ -92,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "39146873", "metadata": { "pycharm": { @@ -109,7 +104,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "5c85ae17", "metadata": {}, "outputs": [], @@ -119,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "id": "77442abf", "metadata": {}, "outputs": [], @@ -142,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "89e1cb2a", "metadata": {}, "outputs": [ @@ -150,7 +145,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "/usr/local/lib/python3.9/site-packages/opensearchpy/connection/http_urllib3.py:199: UserWarning: Connecting to https://localhost:9200 using SSL with verify_certs=False is insecure.\n", + "/home/linuxbrew/.linuxbrew/opt/python@3.8/lib/python3.8/site-packages/opensearchpy/connection/http_urllib3.py:199: UserWarning: Connecting to https://localhost:9200 using SSL with verify_certs=False is insecure.\n", " warnings.warn(\n" ] } @@ -175,6 +170,7 @@ "\n", "In our following example, we created a group and using the group id to register a model.\n", "\n", + "`model_id = ml_client.register_pretrained_model(model_name = \"huggingface/sentence-transformers/all-MiniLM-L12-v2\", model_version = \"1.0.1\", model_format = \"TORCH_SCRIPT\", model_group_id = \"d4hfsYgBFp6IJxCcqpwi\", deploy_model=False, wait_until_deployed=False)`\n", "\n", "###### From Opensearch 2.6, we introduced pre-trained models: https://opensearch.org/docs/latest/ml-commons-plugin/pretrained-models/\n", "\n", @@ -184,7 +180,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "id": "168a969e", "metadata": {}, "outputs": [], @@ -195,7 +191,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 8, "id": "3bfe1532", "metadata": {}, "outputs": [ @@ -203,13 +199,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "Model was registered successfully. Model Id: 7aF5sYgBZqn0fcHifav4\n" + "Model was registered successfully. Model Id: t0jp24kBHUgZTTdfDMmm\n", + "t0jp24kBHUgZTTdfDMmm\n" ] } ], "source": [ - "\n", - "model_id = ml_client.register_pretrained_model(model_name = \"huggingface/sentence-transformers/all-MiniLM-L12-v2\", model_version = \"1.0.1\", model_format = \"TORCH_SCRIPT\", model_group_id = \"d4hfsYgBFp6IJxCcqpwi\", deploy_model=False, wait_until_deployed=False)" + "model_id = ml_client.register_pretrained_model(model_name = \"huggingface/sentence-transformers/all-MiniLM-L12-v2\", model_version = \"1.0.1\", model_format = \"TORCH_SCRIPT\", deploy_model=False, wait_until_deployed=False)" ] }, { @@ -291,7 +287,8 @@ "\"\"\"\n", "\n", "\n", - "model_id_file_system = ml_client.register_model(model_path, model_config_path, model_group_id = \"d4hfsYgBFp6IJxCcqpwi\", isVerbose=True)" + "# model_id_file_system = ml_client.register_model(model_path, model_config_path, model_group_id = \"d4hfsYgBFp6IJxCcqpwi\", isVerbose=True\n", + "model_id_file_system = ml_client.register_model(model_path, model_config_path, isVerbose=True)" ] }, { @@ -301,12 +298,12 @@ "source": [ "## Step 2: Load Model\n", "\n", - "In the last step we upload a model and the model id is: `7KFfsYgBZqn0fcHi8Ku0`. Now we will load this model in opensearch memory." + "In the last step we upload a model and the model id is: `t0jp24kBHUgZTTdfDMmm`. Now we will load this model in opensearch memory." ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 9, "id": "28e9310c", "metadata": {}, "outputs": [ @@ -314,16 +311,16 @@ "name": "stdout", "output_type": "stream", "text": [ + "Task ID: uEjr24kBHUgZTTdfNskV\n", "Model deployed successfully\n", - "{'model_id': '7KFfsYgBZqn0fcHi8Ku0', 'task_type': 'DEPLOY_MODEL', 'function_name': 'TEXT_EMBEDDING', 'state': 'FAILED', 'worker_node': ['QkNLom65QCiU1AwA4fRQHA', 'BJ0OvIWHTJuEJu2muBVRIA'], 'create_time': 1686603192569, 'last_update_time': 1686603193467, 'error': '{\"QkNLom65QCiU1AwA4fRQHA\":\"Duplicate deploy model task\",\"BJ0OvIWHTJuEJu2muBVRIA\":\"Duplicate deploy model task\"}', 'is_async': True}\n" + "{'model_id': 't0jp24kBHUgZTTdfDMmm', 'task_type': 'DEPLOY_MODEL', 'function_name': 'TEXT_EMBEDDING', 'state': 'COMPLETED', 'worker_node': ['3w2aOHUBRmmwmVfoGgW8Jw'], 'create_time': 1691611772437, 'last_update_time': 1691611774664, 'is_async': True}\n" ] } ], "source": [ + "load_model_output = ml_client.deploy_model(\"t0jp24kBHUgZTTdfDMmm\")\n", "\n", - "load_model_output = ml_client.deploy_model(\"7KFfsYgBZqn0fcHi8Ku0\")\n", - "\n", - "print(load_model_output)\n" + "print(load_model_output)" ] }, { @@ -333,12 +330,12 @@ "source": [ "## Step 3: Get Task\n", "\n", - "When we invoke load model api of mlcommons plugin, a task get created. We can see the task id (`j9uRoIUBqB81FWKi_Xqu`) from previous output. Now, we can get the detailed information of the task using this task id" + "When we invoke load model api of mlcommons plugin, a task get created. We can see the task id (`uEjr24kBHUgZTTdfNskV`) from previous output. Now, we can get the detailed information of the task using this task id" ] }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 10, "id": "44d6b1d2", "metadata": {}, "outputs": [ @@ -346,13 +343,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'model_id': 'jtuRoIUBqB81FWKil3qA', 'task_type': 'LOAD_MODEL', 'function_name': 'TEXT_EMBEDDING', 'state': 'COMPLETED', 'worker_node': '56rNfEbPSG6p8ZZli59Zpg,Lncik04uQxe-cw3BC14wNA', 'create_time': 1673436764200, 'last_update_time': 1673436768619, 'is_async': True}\n" + "{'model_id': 't0jp24kBHUgZTTdfDMmm', 'task_type': 'DEPLOY_MODEL', 'function_name': 'TEXT_EMBEDDING', 'state': 'COMPLETED', 'worker_node': ['3w2aOHUBRmmwmVfoGgW8Jw'], 'create_time': 1691611772437, 'last_update_time': 1691611774664, 'is_async': True}\n" ] } ], "source": [ - "\n", - "task_info = ml_client.get_task_info(\"kNuaoIUBqB81FWKimHoo\")\n", + "task_info = ml_client.get_task_info(\"uEjr24kBHUgZTTdfNskV\")\n", "\n", "print(task_info)" ] @@ -369,7 +365,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 11, "id": "661c3f46", "metadata": {}, "outputs": [ @@ -377,13 +373,12 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'name': 'huggingface/sentence-transformers/all-MiniLM-L12-v2', 'model_group_id': 'd4hfsYgBFp6IJxCcqpwi', 'algorithm': 'TEXT_EMBEDDING', 'model_version': '1', 'model_format': 'TORCH_SCRIPT', 'model_state': 'DEPLOYED', 'model_content_size_in_bytes': 134568911, 'model_content_hash_value': 'f8012a4e6b5da1f556221a12160d080157039f077ab85a5f6b467a47247aad49', 'model_config': {'model_type': 'bert', 'embedding_dimension': 384, 'framework_type': 'SENTENCE_TRANSFORMERS', 'all_config': '{\"_name_or_path\":\"microsoft/MiniLM-L12-H384-uncased\",\"attention_probs_dropout_prob\":0.1,\"gradient_checkpointing\":false,\"hidden_act\":\"gelu\",\"hidden_dropout_prob\":0.1,\"hidden_size\":384,\"initializer_range\":0.02,\"intermediate_size\":1536,\"layer_norm_eps\":1e-12,\"max_position_embeddings\":512,\"model_type\":\"bert\",\"num_attention_heads\":12,\"num_hidden_layers\":12,\"pad_token_id\":0,\"position_embedding_type\":\"absolute\",\"transformers_version\":\"4.8.2\",\"type_vocab_size\":2,\"use_cache\":true,\"vocab_size\":30522}'}, 'created_time': 1686603034649, 'last_updated_time': 1686603197066, 'last_registered_time': 1686603047287, 'last_deployed_time': 1686603197066, 'total_chunks': 14, 'planning_worker_node_count': 2, 'current_worker_node_count': 2, 'planning_worker_nodes': ['QkNLom65QCiU1AwA4fRQHA', 'BJ0OvIWHTJuEJu2muBVRIA'], 'deploy_to_all_nodes': True}\n" + "{'name': 'huggingface/sentence-transformers/all-MiniLM-L12-v2', 'algorithm': 'TEXT_EMBEDDING', 'model_version': '1.0.1', 'model_format': 'TORCH_SCRIPT', 'model_state': 'DEPLOYED', 'model_content_size_in_bytes': 134568911, 'model_content_hash_value': 'f8012a4e6b5da1f556221a12160d080157039f077ab85a5f6b467a47247aad49', 'model_config': {'model_type': 'bert', 'embedding_dimension': 384, 'framework_type': 'SENTENCE_TRANSFORMERS', 'all_config': '{\"_name_or_path\":\"microsoft/MiniLM-L12-H384-uncased\",\"attention_probs_dropout_prob\":0.1,\"gradient_checkpointing\":false,\"hidden_act\":\"gelu\",\"hidden_dropout_prob\":0.1,\"hidden_size\":384,\"initializer_range\":0.02,\"intermediate_size\":1536,\"layer_norm_eps\":1e-12,\"max_position_embeddings\":512,\"model_type\":\"bert\",\"num_attention_heads\":12,\"num_hidden_layers\":12,\"pad_token_id\":0,\"position_embedding_type\":\"absolute\",\"transformers_version\":\"4.8.2\",\"type_vocab_size\":2,\"use_cache\":true,\"vocab_size\":30522}'}, 'created_time': 1691611630758, 'last_updated_time': 1691611774664, 'last_registered_time': 1691611634683, 'last_deployed_time': 1691611774664, 'total_chunks': 14, 'planning_worker_node_count': 1, 'current_worker_node_count': 1, 'planning_worker_nodes': ['3w2aOHUBRmmwmVfoGgW8Jw'], 'deploy_to_all_nodes': True}\n" ] } ], "source": [ - "\n", - "model_info = ml_client.get_model_info(\"7KFfsYgBZqn0fcHi8Ku0\")\n", + "model_info = ml_client.get_model_info(\"t0jp24kBHUgZTTdfDMmm\")\n", "\n", "print(model_info)" ] @@ -400,7 +395,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 12, "id": "8cc5a796", "metadata": {}, "outputs": [ @@ -408,7 +403,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'inference_results': [{'output': [{'name': 'sentence_embedding', 'data_type': 'FLOAT32', 'shape': [384], 'data': [0.070045985, 0.094030164, 0.029469099, 0.006335383, -0.037177853, 0.0034696271, 0.06973787, -0.041374803, -0.05277958, -0.019993568, 0.049499072, 0.0443014, 0.05095634, -0.09186084, -0.039252527, -0.028518854, 0.018059185, -0.097130835, -0.03480089, 0.044088792, 0.025124501, -0.06829837, 0.021070546, 0.073358126, -0.016342998, 0.016885245, 0.0073821708, -0.06980089, 0.019172797, -0.12756695, -0.0028336751, 0.076620854, 0.010953987, 0.04055977, 0.047134332, -0.029655162, -0.025424464, -0.023706172, 0.015665784, -0.00028456873, -0.022526933, -0.073676914, 0.055472963, 0.01868282, 0.039403405, -0.024852037, 0.04160002, -0.0012200676, -0.012104933, -0.051197134, -0.074466705, -0.055452745, 0.0074861553, -0.019089255, -0.030097326, -0.026060734, -0.052988756, 0.067124605, 0.025931405, -0.026440043, -0.006570677, 0.055886537, -0.053474635, 0.007984726, 0.08091788, -0.03664718, -0.03190376, -0.073973835, -0.00654548, 0.03476009, -0.009686864, 0.016051935, -0.047839254, 0.0035186426, -9.659327e-05, -0.03731518, 0.005097011, 0.0046331016, 0.04831959, -0.037194345, -0.018304912, -0.06406546, 0.007127483, 0.0036731786, -0.037867643, 0.0525798, 0.022754213, -0.009397554, -0.0788709, -0.04558914, 0.026581936, -0.07401967, 0.0022031788, 0.027502475, -0.04612981, 0.02867453, 0.02812278, -0.06055298, 0.046777442, 0.19889696, 0.026731564, -0.007961404, -0.064086854, 0.03999534, -0.065743305, -0.01038975, 0.031175181, 0.0015405513, -0.04053732, -0.0026587155, 0.0201725, 0.083728634, 0.005884634, 0.032710858, -0.0015733105, -0.09610316, 0.002357033, 0.05984074, -0.16500355, 0.036792327, 0.12291777, -0.001806536, 0.043636028, -0.04189108, 0.009408711, -0.08278277, 0.12746945, 0.016939184, 0.012635965, -0.146165, 0.051131286, 0.0033628952, -0.022748712, 0.022569735, -0.037459757, 0.018744115, -0.006217754, 0.084697165, -0.006795305, -0.054143608, -0.057388783, 0.047126126, 0.016142208, 0.04754377, -0.062171612, -0.012241133, -0.08141003, -0.01191984, 0.016868386, 0.013309095, 0.0659549, 0.02784064, 0.013731603, -0.05787209, -0.026792012, 0.018663717, -0.050591003, -0.02040348, 0.047714904, -0.016063442, -0.10401469, 0.13376768, -0.030586442, 0.0010340372, 0.070359856, -0.013292282, -0.015457728, 0.048926532, -0.011410942, -0.052058127, 0.18224765, 0.0035982048, 0.02246424, -0.0030590945, -0.019338036, 0.00026652194, 0.022335682, 0.07469184, 0.02382239, 0.01046695, 0.03009087, -0.006465016, -0.051522683, 0.019980922, -0.03548732, 0.010370418, -0.08818134, -0.028292583, 0.074272536, 0.08402995, 0.035817318, -0.018850267, 0.031453982, 0.06855093, 0.014118732, -0.07007131, 0.008944237, 0.01816519, -0.07784689, -0.07069612, -0.012862535, -0.015138116, -0.03347607, -0.0068311035, -0.002638591, 0.036386125, 0.03143706, -0.08959042, 0.053561244, -0.08690694, -0.014790011, 0.055373162, -0.11275848, -0.038676344, 0.01777759, -0.0624037, 0.08309957, -0.058959704, 0.02146699, -0.0052596424, -0.03967568, -0.07005087, 0.0535649, 1.1060871e-32, 0.0013608177, 0.106175095, -0.05951191, -0.0037961602, 0.013185205, -0.046274826, 0.10418064, -0.0012341454, -0.0131508345, 0.018092377, 0.0054246127, 0.014041023, 0.036791388, 0.016286977, -0.09607988, 0.015155129, 0.023281448, 0.0831054, 0.00065585395, 0.0002872294, 0.049073815, 0.050753243, -0.0048564766, 0.08584035, -0.049346138, 0.010288568, 0.08767223, -0.0668006, -0.02730152, -0.06031797, 0.08574493, 0.0017309934, 0.004164226, 0.13996643, -0.0064810724, -0.06346753, 0.106137946, -0.06602096, 0.007606502, 0.034102228, 0.015871577, 0.034030348, -0.06620869, 0.061993707, -0.016627932, -0.001730041, 0.025229787, -0.0031807858, 0.04901121, 0.00089508446, -0.039892998, 0.0016668648, -0.012777798, 0.015382705, 0.016362779, -0.02404705, -0.021434382, -0.09117077, -0.05373932, -0.018560624, 0.023284905, 0.0031982018, -0.0031510415, 0.10734427, 0.06998923, -0.0027732637, -0.0530556, 0.023547022, 0.025985928, -0.035036553, -0.058912452, -0.029204743, 0.008312955, -0.056485176, -0.014061077, 0.04225055, -0.08007323, -0.0091617135, -0.018469298, -0.04556874, -0.015968537, -0.014121485, 0.0036195326, 0.027108386, 0.03586916, -0.01750429, 0.10870282, -0.0083625065, 0.014823508, 0.04874035, 0.010967432, 0.018752282, -0.046599686, -0.05806444, -0.029174872, 4.6263226e-33, -0.03030781, -0.06679235, 0.0005264349, 0.045648444, 0.10910713, -0.016406672, -0.006509885, -0.16902378, 0.011055921, 0.036133043, 0.050960954, 0.028546343, -0.07644701, 0.08252433, -0.041281033, 0.0342127, -0.001389836, 0.0062635387, -0.04514362, -0.01706786, 0.07922916, -0.022634191, -0.06849333, -0.007873758, 0.030855168, 0.036613345, 0.01543812, 0.041089304, -0.05730519, 0.06317529, 0.08143371, 0.07131982, -0.037264705, -0.058889233, -0.049804617, -0.034103516, 0.06648858, -0.014449709, 0.022788258, 0.03571679, -0.03570635, 0.046074998, 0.0053664967, 0.024858603, 0.025428161, -0.010590862, -0.040552795, -0.06513859, -0.0003934997, -0.056372937, -0.05148246, 0.011264148, 0.06645999, 0.026652971, 0.07176414, 0.035537906, 0.03287273, -0.0017281885, -0.079337545, 0.049712148, 0.06649142, 0.06070372, -0.012733799, -0.0060011027]}]}, {'output': [{'name': 'sentence_embedding', 'data_type': 'FLOAT32', 'shape': [384], 'data': [0.07083514, 0.098972656, 0.023528868, 0.015548298, -0.03414622, 0.024773195, 0.060273148, -0.028832981, -0.09044978, -0.029630601, 0.044647824, 0.020695554, 0.0451399, -0.105178855, -0.03574795, -0.022011578, 0.02242477, -0.06875169, -0.041503854, 0.046235904, 0.025888842, -0.058203552, 0.0317196, 0.064302124, -0.030310726, 0.027002888, -0.0028196487, -0.044340227, 0.032432694, -0.11670581, 0.014379569, 0.06432164, -0.011770892, 0.032793347, 0.04387399, -0.038692925, -0.013582388, -0.026226582, 0.0076006465, -0.027217122, -0.034419663, -0.08012475, 0.05472637, 0.0074604633, 0.047486894, -0.025225092, 0.037482392, 0.0020973443, -0.0042126533, -0.057536595, -0.08447187, -0.043337554, 0.014264286, -0.023134142, -0.029479904, -0.03363044, -0.05907903, 0.06964192, 0.035337694, -0.022371998, -0.021929951, 0.062269177, -0.030993886, 0.0076106074, 0.07694969, -0.017912427, -0.044359725, -0.056732178, -0.015525767, 0.032636724, -0.009579165, 0.018426858, -0.054791622, 0.008909622, 0.0063452916, -0.0313364, 0.005820822, -0.008221157, 0.058385953, -0.047120888, -0.0052236924, -0.06515579, 0.0010107595, 0.020413563, -0.041749377, 0.044107597, 0.008662938, -0.011051114, -0.08871864, -0.04507809, 0.036184292, -0.07195325, 0.009203214, 0.023508972, -0.028275426, 0.028231027, 0.003911504, -0.070118375, 0.058573272, 0.20727791, 0.048356153, -0.0018830848, -0.066115424, 0.022906033, -0.061623204, -0.021237886, 0.018174624, -0.0050362684, -0.023906242, -0.002387967, 0.035721593, 0.10048729, -0.007958879, 0.044000257, 0.0103866365, -0.09361922, 0.011654698, 0.06738684, -0.1736049, 0.03254977, 0.13699506, -0.0092994645, 0.04818335, -0.050219133, 0.005542939, -0.10294832, 0.10766475, 0.015173319, 0.013554773, -0.13501169, 0.045765, 0.021902261, -0.033359535, 0.028230267, -0.04085567, 0.0077474224, -0.036401946, 0.092795655, -0.00096511975, -0.059694305, -0.035620503, 0.037294034, 0.0015283289, 0.034953, -0.04880616, -0.0059092464, -0.060103483, -0.008989362, 0.022295682, 0.022184573, 0.04979118, 0.049196165, 0.03790123, -0.053590335, -0.0077016405, 0.003188551, -0.056628674, -0.027927972, 0.060124118, -0.025649551, -0.09657911, 0.1299167, -0.032081775, -0.0060925665, 0.06273658, -0.025575282, -0.0069705267, 0.050369203, -0.025092889, -0.019692965, 0.17965682, 0.006651051, 0.024963867, -0.018071478, -0.016473701, -0.00877558, 0.04949933, 0.07836956, 0.03252581, -0.007377615, 0.03200573, -0.011032086, -0.028064458, 0.01763287, -0.026994107, 0.00808559, -0.070627235, -0.034461614, 0.05010755, 0.09331023, 0.049584378, -0.021610672, 0.027137306, 0.071931034, -0.013025755, -0.07407564, 0.020584432, 0.01143555, -0.10216391, -0.06688468, 0.019413434, -0.0076031247, -0.03699172, -0.03037342, 0.0014173934, 0.033982094, 0.028674062, -0.080678664, 0.037503026, -0.08438446, -0.00107288, 0.057899155, -0.113598086, -0.018308517, 0.011551393, -0.07234887, 0.09252413, -0.049695067, 0.014780652, -0.0075675673, -0.044519123, -0.061334103, 0.0589534, 8.414513e-33, 0.009771945, 0.12160786, -0.03935934, -0.010013683, 0.008984462, -0.048829008, 0.092219844, 0.0024215193, -0.008333239, 0.03851628, 0.012913554, 0.032042034, 0.04166485, 0.00095339265, -0.10857277, 0.024132853, 0.021791779, 0.10197005, 0.009454616, 0.02655147, 0.05246785, 0.06066869, -0.01103198, 0.08555522, -0.04832902, 0.015530094, 0.081544966, -0.07317735, -0.024714837, -0.054873053, 0.07664425, 0.00995868, -0.0126262475, 0.12942667, -0.020951333, -0.071839534, 0.112829536, -0.05635948, -0.00964097, 0.0416308, 0.037358228, 0.029693559, -0.06289643, 0.05327226, -0.012749386, 0.009228852, 0.019423483, 0.004775946, 0.036169004, -0.012142309, -0.019225916, -4.9336504e-05, -0.026529595, 0.012205288, 0.017824031, -0.015235648, -0.018118307, -0.08875225, -0.03372443, -0.020540647, -0.0050654826, -0.001371073, 0.0008696483, 0.11509085, 0.067525595, 0.0014781682, -0.05162725, 0.024478963, 0.02746541, -0.04733127, -0.071528465, -0.033279188, -0.007459125, -0.058763813, -0.04050985, 0.023988923, -0.0877261, -0.0031558173, -0.020018995, -0.041812886, -0.0050884373, -0.01390084, 0.02811135, 0.021810783, 0.013438191, -0.007385128, 0.100511186, -0.0144268125, -0.0046929154, 0.039197326, 0.002359752, 0.015907316, -0.035865612, -0.071099125, -0.01309764, 7.376516e-33, -0.022041496, -0.06963562, -0.022240836, 0.03717517, 0.09121255, -0.009112608, -0.014528304, -0.15407158, 0.005560728, 0.024977768, 0.052556068, 0.014630092, -0.08889645, 0.09537802, -0.03995325, 0.04229064, -0.024341475, 0.009678618, -0.048159223, -0.036069203, 0.059143994, -0.00944305, -0.062726334, 0.0018664591, 0.004131935, 0.03928479, 0.014626856, 0.025103925, -0.05313026, 0.054437604, 0.07312243, 0.059003882, -0.038209524, -0.085269175, -0.06061704, -0.042276274, 0.061298754, -0.016126659, 0.03648384, 0.0263596, -0.020908905, 0.048757087, -0.0046108705, 0.035508107, 0.028468246, -0.009864904, -0.034235284, -0.07204, -0.0005532754, -0.05454473, -0.04248278, 0.014105863, 0.081947, 0.040557176, 0.06266554, 0.040847275, 0.028606374, 0.025837993, -0.07722129, 0.039314467, 0.049470015, 0.05854979, -0.03244549, -0.02478489]}]}]}\n" + "{'inference_results': [{'output': [{'name': 'sentence_embedding', 'data_type': 'FLOAT32', 'shape': [384], 'data': [0.07004598, 0.094030194, 0.0294691, 0.0063353553, -0.037177887, 0.003469634, 0.06973778, -0.041374724, -0.052779537, -0.019993527, 0.049499035, 0.044301376, 0.050956327, -0.091860786, -0.039252494, -0.028518932, 0.018059155, -0.09713085, -0.034800865, 0.04408874, 0.025124485, -0.06829839, 0.02107054, 0.073358156, -0.016343018, 0.016885223, 0.0073822327, -0.069800906, 0.01917283, -0.127567, -0.002833644, 0.07662087, 0.010953967, 0.040559784, 0.047134362, -0.02965514, -0.025424507, -0.023706196, 0.015665805, -0.0002845036, -0.02252695, -0.073676944, 0.05547299, 0.018682828, 0.03940338, -0.024852037, 0.04160006, -0.0012200836, -0.012104877, -0.05119714, -0.07446669, -0.055452716, 0.007486106, -0.019089257, -0.030097323, -0.026060726, -0.052988816, 0.06712463, 0.025931384, -0.02644008, -0.0065706596, 0.05588654, -0.05347465, 0.007984704, 0.08091787, -0.036647186, -0.031903736, -0.07397383, -0.0065454575, 0.034760114, -0.009686786, 0.016051935, -0.04783923, 0.0035186426, -9.652851e-05, -0.037315175, 0.0050969664, 0.0046331156, 0.048319556, -0.037194334, -0.018304864, -0.06406543, 0.007127524, 0.0036731854, -0.037867695, 0.052579854, 0.02275424, -0.009397553, -0.078870915, -0.04558915, 0.02658195, -0.07401964, 0.0022031788, 0.027502479, -0.046129823, 0.028674513, 0.028122796, -0.06055296, 0.046777423, 0.198897, 0.02673153, -0.007961458, -0.06408687, 0.03999538, -0.06574333, -0.010389742, 0.031175155, 0.0015405632, -0.040537335, -0.0026587504, 0.020172479, 0.08372859, 0.0058846273, 0.032710858, -0.0015732804, -0.09610316, 0.0023569933, 0.05984071, -0.16500352, 0.03679231, 0.122917764, -0.0018065565, 0.043636024, -0.041891094, 0.009408743, -0.08278275, 0.12746939, 0.016939186, 0.012635989, -0.14616504, 0.051131263, 0.0033628803, -0.022748744, 0.022569718, -0.037459765, 0.018744126, -0.0062177675, 0.08469717, -0.006795277, -0.05414359, -0.0573888, 0.047126096, 0.01614229, 0.047543816, -0.062171623, -0.012241133, -0.08141003, -0.011919791, 0.016868353, 0.013309039, 0.065954946, 0.027840674, 0.013731638, -0.057872113, -0.026792012, 0.018663734, -0.05059098, -0.020403482, 0.047714923, -0.01606342, -0.10401474, 0.13376766, -0.03058641, 0.001033993, 0.070359856, -0.013292278, -0.015457728, 0.04892655, -0.011410854, -0.052058097, 0.18224768, 0.0035982134, 0.022464214, -0.0030590647, -0.019338032, 0.00026649763, 0.02233567, 0.07469185, 0.02382241, 0.010466962, 0.03009085, -0.006465027, -0.051522672, 0.0199809, -0.03548726, 0.0103704315, -0.08818128, -0.02829264, 0.074272595, 0.084029905, 0.035817306, -0.018850243, 0.031453986, 0.068550915, 0.014118737, -0.070071295, 0.008944256, 0.018165134, -0.07784688, -0.070696145, -0.012862558, -0.015138121, -0.0334761, -0.0068311137, -0.002638576, 0.03638613, 0.03143706, -0.08959043, 0.053561207, -0.08690697, -0.014789994, 0.055373095, -0.11275849, -0.038676355, 0.01777756, -0.062403727, 0.0830996, -0.058959745, 0.021466918, -0.005259635, -0.039675698, -0.07005095, 0.053564843, 1.1060878e-32, 0.0013608016, 0.106175035, -0.059511874, -0.0037960887, 0.013185141, -0.046274804, 0.10418073, -0.0012341124, -0.013150821, 0.018092388, 0.005424653, 0.014040968, 0.03679144, 0.016286962, -0.09607988, 0.015155191, 0.023281407, 0.08310539, 0.0006558546, 0.0002872544, 0.049073823, 0.050753288, -0.0048564966, 0.08584042, -0.049346182, 0.010288551, 0.087672256, -0.06680062, -0.027301554, -0.060317975, 0.08574496, 0.0017309932, 0.0041642035, 0.13996643, -0.0064810454, -0.06346753, 0.10613796, -0.06602093, 0.007606491, 0.034102246, 0.015871532, 0.034030363, -0.0662087, 0.061993726, -0.016627997, -0.001729985, 0.025229797, -0.003180745, 0.0490112, 0.00089509884, -0.039893012, 0.0016668896, -0.012777804, 0.015382689, 0.016362777, -0.02404702, -0.02143441, -0.0911707, -0.053739283, -0.018560594, 0.023284977, 0.0031981992, -0.0031510598, 0.10734427, 0.06998925, -0.0027732535, -0.053055596, 0.02354699, 0.025985928, -0.035036538, -0.058912467, -0.02920474, 0.008312963, -0.056485146, -0.014061096, 0.04225053, -0.08007323, -0.009161725, -0.018469293, -0.045568734, -0.015968522, -0.014121509, 0.0036195314, 0.027108373, 0.035869084, -0.017504305, 0.108702846, -0.008362452, 0.014823476, 0.04874034, 0.010967371, 0.018752342, -0.046599716, -0.058064498, -0.029174827, 4.6263152e-33, -0.030307822, -0.06679234, 0.0005264218, 0.045648467, 0.10910713, -0.016406672, -0.0065098666, -0.1690238, 0.011055945, 0.036133047, 0.050960947, 0.028546333, -0.07644701, 0.082524374, -0.041281033, 0.0342127, -0.0013897946, 0.0062635383, -0.045143634, -0.017067816, 0.079229176, -0.022634152, -0.068493344, -0.007873755, 0.030855201, 0.03661335, 0.0154381255, 0.041089326, -0.05730516, 0.063175276, 0.08143365, 0.07131981, -0.03726474, -0.058889214, -0.049804606, -0.03410345, 0.066488594, -0.014449714, 0.022788277, 0.035716787, -0.035706382, 0.046074968, 0.005366466, 0.0248586, 0.025428172, -0.010590827, -0.0405528, -0.065138645, -0.00039351193, -0.05637292, -0.0514825, 0.0112641435, 0.066459976, 0.026653022, 0.07176415, 0.0355379, 0.032872733, -0.0017282534, -0.07933759, 0.04971213, 0.066491455, 0.06070366, -0.012733777, -0.006001069]}]}, {'output': [{'name': 'sentence_embedding', 'data_type': 'FLOAT32', 'shape': [384], 'data': [0.07083512, 0.09897267, 0.02352888, 0.015548294, -0.034146227, 0.0247732, 0.06027314, -0.028832998, -0.09044973, -0.029630564, 0.044647824, 0.020695595, 0.045139927, -0.105178796, -0.035747953, -0.022011546, 0.022424795, -0.06875172, -0.04150383, 0.046235885, 0.02588881, -0.058203597, 0.03171956, 0.06430214, -0.030310709, 0.027002905, -0.0028196378, -0.044340268, 0.032432683, -0.11670582, 0.014379533, 0.0643216, -0.011770836, 0.032793343, 0.04387401, -0.038692914, -0.013582456, -0.026226604, 0.007600631, -0.027217109, -0.03441963, -0.08012474, 0.054726355, 0.0074604494, 0.04748688, -0.025225094, 0.03748238, 0.0020973468, -0.0042126784, -0.05753656, -0.08447185, -0.043337557, 0.014264312, -0.023134159, -0.02947989, -0.033630386, -0.05907903, 0.06964187, 0.03533768, -0.022372045, -0.021929925, 0.06226919, -0.030993978, 0.007610613, 0.07694968, -0.017912386, -0.044359725, -0.05673219, -0.01552571, 0.032636717, -0.009579155, 0.018426916, -0.05479158, 0.008909622, 0.006345299, -0.031336434, 0.0058207866, -0.008221157, 0.058385894, -0.047120895, -0.005223671, -0.06515576, 0.0010108105, 0.020413512, -0.041749343, 0.044107605, 0.008662969, -0.011051096, -0.08871866, -0.045078132, 0.036184326, -0.07195323, 0.009203147, 0.023508985, -0.028275412, 0.028231055, 0.0039115297, -0.07011834, 0.05857326, 0.20727783, 0.04835618, -0.0018830771, -0.06611541, 0.022906005, -0.061623234, -0.02123788, 0.018174635, -0.0050362577, -0.023906214, -0.0023879737, 0.035721574, 0.10048731, -0.007958884, 0.044000242, 0.010386637, -0.09361921, 0.011654652, 0.06738685, -0.17360488, 0.032549746, 0.13699506, -0.009299514, 0.048183367, -0.05021916, 0.005542932, -0.10294828, 0.10766478, 0.015173303, 0.01355476, -0.1350117, 0.045765016, 0.021902222, -0.033359498, 0.028230252, -0.04085572, 0.007747412, -0.036401898, 0.092795655, -0.00096510054, -0.059694264, -0.03562055, 0.037294004, 0.0015283314, 0.034953013, -0.048806172, -0.0059092273, -0.060103502, -0.00898931, 0.022295611, 0.022184547, 0.049791194, 0.049196154, 0.037901234, -0.053590365, -0.007701697, 0.0031885458, -0.056628704, -0.027927952, 0.060124114, -0.025649505, -0.09657915, 0.12991673, -0.03208177, -0.006092552, 0.06273655, -0.025575202, -0.0069704982, 0.0503692, -0.025092859, -0.019693008, 0.17965682, 0.0066510485, 0.024963824, -0.018071467, -0.016473666, -0.008775544, 0.049499284, 0.07836955, 0.032525778, -0.007377622, 0.03200582, -0.011032107, -0.028064458, 0.017632844, -0.026994104, 0.008085599, -0.07062725, -0.03446164, 0.050107572, 0.09331023, 0.049584396, -0.021610705, 0.027137293, 0.07193105, -0.013025723, -0.07407565, 0.02058441, 0.011435531, -0.10216389, -0.066884704, 0.019413384, -0.0076031317, -0.036991768, -0.0303734, 0.0014173611, 0.033982154, 0.028674075, -0.080678694, 0.0375031, -0.08438446, -0.0010728774, 0.05789914, -0.113598056, -0.018308552, 0.011551412, -0.07234886, 0.09252421, -0.04969506, 0.014780675, -0.007567542, -0.044519085, -0.06133406, 0.05895338, 8.414509e-33, 0.009771958, 0.12160779, -0.039359365, -0.010013683, 0.00898449, -0.04882902, 0.092219874, 0.0024215167, -0.008333214, 0.03851627, 0.012913563, 0.03204204, 0.041664835, 0.0009534093, -0.10857273, 0.024132818, 0.021791773, 0.101970024, 0.009454601, 0.026551446, 0.05246786, 0.06066872, -0.01103198, 0.08555519, -0.048329007, 0.015530085, 0.08154496, -0.0731774, -0.024714865, -0.05487307, 0.07664423, 0.009958633, -0.012626225, 0.12942669, -0.02095135, -0.071839556, 0.112829536, -0.05635947, -0.009640948, 0.04163078, 0.037358176, 0.029693598, -0.0628964, 0.053272255, -0.012749352, 0.009228823, 0.01942351, 0.004775929, 0.036169015, -0.012142286, -0.01922596, -4.9331225e-05, -0.026529552, 0.012205288, 0.017824046, -0.015235645, -0.0181183, -0.08875225, -0.03372447, -0.020540629, -0.005065464, -0.0013711171, 0.00086961745, 0.11509084, 0.06752553, 0.0014781557, -0.05162722, 0.024478994, 0.027465401, -0.04733123, -0.07152838, -0.033279166, -0.007459171, -0.05876381, -0.040509865, 0.023988906, -0.08772608, -0.003155819, -0.020018948, -0.041812915, -0.0050884616, -0.013900808, 0.02811133, 0.021810783, 0.013438155, -0.007385124, 0.10051118, -0.014426816, -0.004692878, 0.03919732, 0.0023597397, 0.015907336, -0.035865597, -0.071099125, -0.013097632, 7.3765136e-33, -0.022041548, -0.06963561, -0.022240805, 0.037175175, 0.09121253, -0.009112657, -0.014528283, -0.1540716, 0.005560708, 0.024977792, 0.052556057, 0.014630056, -0.088896446, 0.09537804, -0.039953273, 0.042290684, -0.024341425, 0.0096786395, -0.04815927, -0.03606919, 0.05914406, -0.009443069, -0.06272632, 0.0018664851, 0.004131947, 0.039284766, 0.014626883, 0.025103891, -0.053130243, 0.05443761, 0.07312244, 0.059003882, -0.03820951, -0.08526913, -0.06061701, -0.04227627, 0.06129878, -0.016126666, 0.0364838, 0.026359634, -0.020908944, 0.048757017, -0.004610902, 0.035508078, 0.02846824, -0.009864912, -0.034235265, -0.07203998, -0.0005532816, -0.054544747, -0.042482726, 0.014105883, 0.081946984, 0.040557213, 0.06266559, 0.04084731, 0.02860638, 0.025837963, -0.077221215, 0.039314423, 0.049470052, 0.05854972, -0.032445546, -0.024784891]}]}]}\n" ] } ], @@ -417,7 +412,7 @@ "\n", "input_sentences = [\"Test sentence1\", \"Test sentence2\"]\n", "\n", - "embedding_output = ml_client.generate_embedding(\"7KFfsYgBZqn0fcHi8Ku0\", input_sentences)\n", + "embedding_output = ml_client.generate_embedding(\"t0jp24kBHUgZTTdfDMmm\", input_sentences)\n", "\n", "print(embedding_output)\n" ] @@ -439,7 +434,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 13, "id": "9636c6bf", "metadata": {}, "outputs": [ @@ -447,13 +442,13 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'BJ0OvIWHTJuEJu2muBVRIA': {'stats': {'7KFfsYgBZqn0fcHi8Ku0': 'undeployed'}}, 'LnxY8AMlTpecPVBSiTOYWg': {'stats': {'7KFfsYgBZqn0fcHi8Ku0': 'not_found'}}, 'U6Y1_KIrRJuUbcu89tDIWg': {'stats': {'7KFfsYgBZqn0fcHi8Ku0': 'not_found'}}, 'QkNLom65QCiU1AwA4fRQHA': {'stats': {'7KFfsYgBZqn0fcHi8Ku0': 'undeployed'}}}\n" + "{'3w2aOHUBRmmwmVfoGgW8Jw': {'stats': {'t0jp24kBHUgZTTdfDMmm': 'undeployed'}}}\n" ] } ], "source": [ "\n", - "undeploy_model_response = ml_client.undeploy_model(\"7KFfsYgBZqn0fcHi8Ku0\")\n", + "undeploy_model_response = ml_client.undeploy_model(\"t0jp24kBHUgZTTdfDMmm\")\n", "\n", "print(undeploy_model_response)" ] @@ -470,7 +465,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 14, "id": "001165fb", "metadata": {}, "outputs": [ @@ -478,24 +473,16 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'_index': '.plugins-ml-model', '_id': '7KFfsYgBZqn0fcHi8Ku0', '_version': 11, 'result': 'deleted', '_shards': {'total': 2, 'successful': 2, 'failed': 0}, '_seq_no': 24, '_primary_term': 1}\n" + "{'_index': '.plugins-ml-model', '_id': 't0jp24kBHUgZTTdfDMmm', '_version': 6, 'result': 'deleted', '_shards': {'total': 2, 'successful': 1, 'failed': 0}, '_seq_no': 11203, '_primary_term': 33}\n" ] } ], "source": [ "\n", - "delete_model_response = ml_client.delete_model(\"7KFfsYgBZqn0fcHi8Ku0\")\n", + "delete_model_response = ml_client.delete_model(\"t0jp24kBHUgZTTdfDMmm\")\n", "\n", "print(delete_model_response)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "afb60353", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { @@ -514,7 +501,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.16" + "version": "3.8.17" } }, "nbformat": 4, diff --git a/opensearch_py_ml/ml_commons/ml_commons_client.py b/opensearch_py_ml/ml_commons/ml_commons_client.py index 41ef42757..722a70d1d 100644 --- a/opensearch_py_ml/ml_commons/ml_commons_client.py +++ b/opensearch_py_ml/ml_commons/ml_commons_client.py @@ -338,6 +338,7 @@ def deploy_model(self, model_id: str, wait_until_deployed: bool = True) -> objec "task_id" ] + print(f"Task ID: {task_id}") if wait_until_deployed: # Wait until deployed for i in range(TIMEOUT):