From 4536302666c922973da263e0031ec5f0cbc3bc12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Zolt=C3=A1n=20Szab=C3=B3?= Date: Mon, 25 Mar 2024 15:51:00 +0100 Subject: [PATCH 1/3] Changes model_id path parameter to inference_id in openAI and Cohere notebooks. --- notebooks/integrations/cohere/inference-cohere.ipynb | 8 ++++---- notebooks/search/07-inference.ipynb | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/notebooks/integrations/cohere/inference-cohere.ipynb b/notebooks/integrations/cohere/inference-cohere.ipynb index 3064452d..97404586 100644 --- a/notebooks/integrations/cohere/inference-cohere.ipynb +++ b/notebooks/integrations/cohere/inference-cohere.ipynb @@ -204,7 +204,7 @@ "\n", "client.inference.put_model(\n", " task_type=\"text_embedding\",\n", - " model_id=\"cohere_embeddings\",\n", + " inference_id=\"cohere_embeddings\",\n", " body={\n", " \"service\": \"cohere\",\n", " \"service_settings\": {\n", @@ -244,7 +244,7 @@ " processors=[\n", " {\n", " \"inference\": {\n", - " \"model_id\": \"cohere_embeddings\",\n", + " \"inference_id\": \"cohere_embeddings\",\n", " \"input_output\": {\n", " \"input_field\": \"plot\",\n", " \"output_field\": \"plot_embedding\",\n", @@ -265,7 +265,7 @@ "Let's note a few important parameters from that API call:\n", "\n", "- `inference`: A processor that performs inference using a machine learning model.\n", - "- `model_id`: Specifies the ID of the machine learning model to be used. In this example, the model ID is set to `cohere_embeddings`.\n", + "- `inference_id`: Specifies the ID of the inference entity to be used. In this example, the inference ID is set to `cohere_embeddings`.\n", "- `input_output`: Specifies input and output fields.\n", "- `input_field`: Field name from which the `dense_vector` representation is created.\n", "- `output_field`: Field name which contains inference results." @@ -406,7 +406,7 @@ " \"field\": \"plot_embedding\",\n", " \"query_vector_builder\": {\n", " \"text_embedding\": {\n", - " \"model_id\": \"cohere_embeddings\",\n", + " \"inference_id\": \"cohere_embeddings\",\n", " \"model_text\": \"Fighting movie\",\n", " }\n", " },\n", diff --git a/notebooks/search/07-inference.ipynb b/notebooks/search/07-inference.ipynb index e0a53a7b..dc2bc65b 100644 --- a/notebooks/search/07-inference.ipynb +++ b/notebooks/search/07-inference.ipynb @@ -25,7 +25,7 @@ "- An Elastic deployment:\n", " - We'll be using [Elastic Cloud](https://www.elastic.co/guide/en/cloud/current/ec-getting-started.html) for this example (available with a [free trial](https://cloud.elastic.co/registration?utm_source=github&utm_content=elasticsearch-labs-notebook))\n", "\n", - "- Elasticsearch 8.12 or above.\n", + "- Elasticsearch 8.13 or above.\n", " \n", "- A paid [OpenAI account](https://openai.com/) is required to use the Inference API with \n", "the OpenAI service as the OpenAI free trial API usage is limited. " @@ -172,7 +172,7 @@ "\n", "client.inference.put_model(\n", " task_type=\"text_embedding\",\n", - " model_id=\"my_openai_embedding_model\",\n", + " inference_id=\"my_openai_embedding_model\",\n", " body={\n", " \"service\": \"openai\",\n", " \"service_settings\": {\"api_key\": API_KEY},\n", @@ -204,7 +204,7 @@ " processors=[\n", " {\n", " \"inference\": {\n", - " \"model_id\": \"my_openai_embedding_model\",\n", + " \"inference_id\": \"my_openai_embedding_model\",\n", " \"input_output\": {\n", " \"input_field\": \"plot\",\n", " \"output_field\": \"plot_embedding\",\n", @@ -223,7 +223,7 @@ "Let's note a few important parameters from that API call:\n", "\n", "- `inference`: A processor that performs inference using a machine learning model.\n", - "- `model_id`: Specifies the ID of the machine learning model to be used. In this example, the model ID is set to `my_openai_embedding_model`. Use the model ID you defined when created the inference task.\n", + "- `inference_id`: Specifies the ID of the inference entity to be used. In this example, the inference ID is set to `my_openai_embedding_model`. Use the inference ID you defined when created the inference task.\n", "- `input_output`: Specifies input and output fields.\n", "- `input_field`: Field name from which the `dense_vector` representation is created.\n", "- `output_field`: Field name which contains inference results. " @@ -348,7 +348,7 @@ " \"field\": \"plot_embedding\",\n", " \"query_vector_builder\": {\n", " \"text_embedding\": {\n", - " \"model_id\": \"my_openai_embedding_model\",\n", + " \"inference_id\": \"my_openai_embedding_model\",\n", " \"model_text\": \"Fighting movie\",\n", " }\n", " },\n", From b1d37b9c79132b674cb93d64eab6100f5824e605 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Zolt=C3=A1n=20Szab=C3=B3?= Date: Mon, 25 Mar 2024 16:19:13 +0100 Subject: [PATCH 2/3] Updates examples. --- notebooks/integrations/cohere/inference-cohere.ipynb | 10 +++++----- notebooks/search/07-inference.ipynb | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/notebooks/integrations/cohere/inference-cohere.ipynb b/notebooks/integrations/cohere/inference-cohere.ipynb index 97404586..b8888c23 100644 --- a/notebooks/integrations/cohere/inference-cohere.ipynb +++ b/notebooks/integrations/cohere/inference-cohere.ipynb @@ -184,9 +184,9 @@ "id": "96788aa1" }, "source": [ - "## Create the inference task\n", + "## Create the inference endpoint\n", "\n", - "Let's create the inference task by using the [Create inference API](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html).\n", + "Let's create the inference endpoint by using the [Create inference API](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html).\n", "\n", "You'll need an Cohere API key for this that you can find in your Cohere account under the [API keys section](https://dashboard.cohere.com/api-keys). A paid membership is required to complete the steps in this notebook as the Cohere free trial API usage is limited." ] @@ -226,7 +226,7 @@ "source": [ "## Create an ingest pipeline with an inference processor\n", "\n", - "Create an ingest pipeline with an inference processor by using the [`put_pipeline`](https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html) method. Reference the Cohere model created above to infer against the data that is being ingested in the pipeline." + "Create an ingest pipeline with an inference processor by using the [`put_pipeline`](https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html) method. Reference the inference endpoint created above as the `model_id` to infer against the data that is being ingested in the pipeline." ] }, { @@ -244,7 +244,7 @@ " processors=[\n", " {\n", " \"inference\": {\n", - " \"inference_id\": \"cohere_embeddings\",\n", + " \"model_id\": \"cohere_embeddings\",\n", " \"input_output\": {\n", " \"input_field\": \"plot\",\n", " \"output_field\": \"plot_embedding\",\n", @@ -265,7 +265,7 @@ "Let's note a few important parameters from that API call:\n", "\n", "- `inference`: A processor that performs inference using a machine learning model.\n", - "- `inference_id`: Specifies the ID of the inference entity to be used. In this example, the inference ID is set to `cohere_embeddings`.\n", + "- `model_id`: Specifies the ID of the inference endpoint to be used. In this example, the model ID is set to `cohere_embeddings`.\n", "- `input_output`: Specifies input and output fields.\n", "- `input_field`: Field name from which the `dense_vector` representation is created.\n", "- `output_field`: Field name which contains inference results." diff --git a/notebooks/search/07-inference.ipynb b/notebooks/search/07-inference.ipynb index dc2bc65b..c6ea96fc 100644 --- a/notebooks/search/07-inference.ipynb +++ b/notebooks/search/07-inference.ipynb @@ -154,9 +154,9 @@ "id": "840d92f0", "metadata": {}, "source": [ - "## Create the inference task\n", + "## Create the inference endpoint\n", "\n", - "Let's create the inference task by using the [Create inference API](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html).\n", + "Let's create the inference endpoint by using the [Create inference API](https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html).\n", "\n", "You'll need an OpenAI API key for this that you can find in your OpenAI account under the [API keys section](https://platform.openai.com/api-keys). A paid membership is required to complete the steps in this notebook as the OpenAI free trial API usage is limited." ] @@ -188,7 +188,7 @@ "source": [ "## Create an ingest pipeline with an inference processor\n", "\n", - "Create an ingest pipeline with an inference processor by using the [`put_pipeline`](https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html) method. Reference the OpenAI model created above to infer against the data that is being ingested in the pipeline." + "Create an ingest pipeline with an inference processor by using the [`put_pipeline`](https://www.elastic.co/guide/en/elasticsearch/reference/master/put-pipeline-api.html) method. Reference the inference endpoint created above as `model_id` to infer against the data that is being ingested in the pipeline." ] }, { @@ -204,7 +204,7 @@ " processors=[\n", " {\n", " \"inference\": {\n", - " \"inference_id\": \"my_openai_embedding_model\",\n", + " \"model_id\": \"my_openai_embedding_model\",\n", " \"input_output\": {\n", " \"input_field\": \"plot\",\n", " \"output_field\": \"plot_embedding\",\n", @@ -223,7 +223,7 @@ "Let's note a few important parameters from that API call:\n", "\n", "- `inference`: A processor that performs inference using a machine learning model.\n", - "- `inference_id`: Specifies the ID of the inference entity to be used. In this example, the inference ID is set to `my_openai_embedding_model`. Use the inference ID you defined when created the inference task.\n", + "- `model_id`: Specifies the ID of the inference endpoint to be used. In this example, the inference ID is set to `my_openai_embedding_model`. Use the inference ID you defined when created the inference task.\n", "- `input_output`: Specifies input and output fields.\n", "- `input_field`: Field name from which the `dense_vector` representation is created.\n", "- `output_field`: Field name which contains inference results. " From 554f62c12a5a2fb39197fc652a38cb936405e073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Istv=C3=A1n=20Zolt=C3=A1n=20Szab=C3=B3?= Date: Tue, 26 Mar 2024 09:19:05 +0100 Subject: [PATCH 3/3] [DOCS] Adds note to inference notebook. --- notebooks/search/07-inference.ipynb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/notebooks/search/07-inference.ipynb b/notebooks/search/07-inference.ipynb index c6ea96fc..bc443d29 100644 --- a/notebooks/search/07-inference.ipynb +++ b/notebooks/search/07-inference.ipynb @@ -25,7 +25,7 @@ "- An Elastic deployment:\n", " - We'll be using [Elastic Cloud](https://www.elastic.co/guide/en/cloud/current/ec-getting-started.html) for this example (available with a [free trial](https://cloud.elastic.co/registration?utm_source=github&utm_content=elasticsearch-labs-notebook))\n", "\n", - "- Elasticsearch 8.13 or above.\n", + "- Elasticsearch 8.12 or above.\n", " \n", "- A paid [OpenAI account](https://openai.com/) is required to use the Inference API with \n", "the OpenAI service as the OpenAI free trial API usage is limited. " @@ -181,6 +181,14 @@ ")" ] }, + { + "cell_type": "markdown", + "id": "1f2e48b7", + "metadata": {}, + "source": [ + "**NOTE:** If you use Elasticsearch 8.12, you must change `inference_id` in the snippet above to `model_id`! " + ] + }, { "cell_type": "markdown", "id": "1024d070", @@ -364,6 +372,20 @@ " plot = hit[\"_source\"][\"plot\"]\n", " print(f\"Score: {score}\\nTitle: {title}\\nPlot: {plot}\\n\")" ] + }, + { + "cell_type": "markdown", + "id": "7e4055ba", + "metadata": {}, + "source": [ + "**NOTE:** If you use Elasticsearch 8.12, you must change `inference_id` in the snippet above to `model_id`." + ] + }, + { + "cell_type": "markdown", + "id": "59220b82", + "metadata": {}, + "source": [] } ], "metadata": {