From af61b9df5f05c43ff37b34fd8129f38e6d7a22c4 Mon Sep 17 00:00:00 2001 From: tkykenmt Date: Tue, 3 Dec 2024 14:34:25 +0900 Subject: [PATCH 1/8] add tutorials for cross encoder models on Amazon Bedrock Signed-off-by: tkykenmt --- ...h_Amazon_Rerank_model_on_Amazon_Bedrock.md | 622 +++++++++++++++++ ...h_Cohere_Rerank_model_on_Amazon_Bedrock.md | 625 ++++++++++++++++++ 2 files changed, 1247 insertions(+) create mode 100644 docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md create mode 100644 docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md new file mode 100644 index 0000000000..8036ea23d1 --- /dev/null +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -0,0 +1,622 @@ +# Topic + +[Reranking pipeline](https://opensearch.org/docs/latest/search-plugins/search-relevance/reranking-search-results/) is a feature released in OpenSearch 2.12. +It can rerank search results, providing a relevance score for each document in the search results with respect to the search query. +The relevance score is calculated by a cross-encoder model. + +This tutorial explains how to use the [Amazon Rerank 1.0 model in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-supported.html) in a reranking pipeline. + +Note: Replace the placeholders that start with `your_` with your own values. + +# Steps + +## 0. Test the model on Amazon Bedrock +You can perform a reranking test with the following code. + +```python +import json +import boto3 +bedrock_region = "your_bedrock_model_region_like_us-west-2" +bedrock_runtime_client = boto3.client("bedrock-runtime", region_name=bedrock_region) + +modelId = "amazon.rerank-v1:0" +contentType = "application/json" +accept = "*/*" + +body = json.dumps({ + "query": "What is the capital city of America?", + "documents": [ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + ] +}) + +response = bedrock_runtime_client.invoke_model( + modelId=modelId, + contentType=contentType, + accept=accept, + body=body +) +results = json.loads(response.get('body').read())["results"] +print(json.dumps(sorted(results, key=lambda x: x['index']),indent=2)) +``` + +The reranking results are as follows: + +``` +[ + { + "index": 0, + "relevance_score": 0.0025114635138098534 + }, + { + "index": 1, + "relevance_score": 2.4876490010363496e-05 + }, + { + "index": 2, + "relevance_score": 0.7711548724998493 + }, + { + "index": 3, + "relevance_score": 6.339210403977635e-06 + } +] +``` + +## 1. Create a connector and register the model + +To create a connector for the model, send the following request. If you are using self-managed OpenSearch, supply your AWS credentials: +```json +POST /_plugins/_ml/connectors/_create +{ + "name": "Amazon Bedrock cross-encoder model", + "description": "Test connector for Amazon Bedrock cross-encoder model", + "version": 1, + "protocol": "aws_sigv4", + "credential": { + "access_key": "your_access_key", + "secret_key": "your_secret_key", + "session_token": "your_session_token" + }, + "parameters": { + "region": "your_bedrock_model_region_like_us-west-2", + "service_name": "bedrock" + }, + "actions": [ + { + "action_type": "predict", + "method": "POST", + "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/amazon.rerank-v1:0/invoke", + "headers": { + "x-amz-content-sha256": "required", + "content-type": "application/json" + }, + "pre_process_function": """ + def query_text = params.query_text; + def text_docs = params.text_docs; + def textDocsBuilder = new StringBuilder('['); + for (int i=0; i"], + "post_tags": [""], + "fields": {"passage_text": {}} + }, + "_source": false, + "fields": ["passage_text"] +} +``` + +The first document in the response is `Carson City is the capital city of the American state of Nevada`, which is incorrect: +```json +{ + "took": 2, + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 4, + "relation": "eq" + }, + "max_score": 2.5045562, + "hits": [ + { + "_index": "my-test-data", + "_id": "1", + "_score": 2.5045562, + "fields": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + }, + "highlight": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + } + }, + { + "_index": "my-test-data", + "_id": "2", + "_score": 0.5807494, + "fields": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan." + ] + }, + "highlight": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean.", + "Its capital is Saipan." + ] + } + }, + { + "_index": "my-test-data", + "_id": "3", + "_score": 0.5261191, + "fields": { + "passage_text": [ + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + ] + }, + "highlight": { + "passage_text": [ + "(also known as simply Washington or D.C., and officially as the District of Columbia) is the capital", + "of the United States.", + "It is a federal district." + ] + } + }, + { + "_index": "my-test-data", + "_id": "4", + "_score": 0.5083029, + "fields": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + ] + }, + "highlight": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States", + "As of 2017, capital punishment is legal in 30 of the 50 states." + ] + } + } + ] + } +} +``` + +Next, test the query using the reranking pipeline: +```json +POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +{ + "query": { + "match": { + "passage_text": "What is the capital city of America?" + } + }, + "ext": { + "rerank": { + "query_context": { + "query_text": "What is the capital city of America?" + } + } + }, + "highlight": { + "pre_tags": [""], + "post_tags": [""], + "fields": {"passage_text": {}} + }, + "_source": false, + "fields": ["passage_text"] +} +``` + +The first document in the response is `"Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."`, which is correct: + +```json +{ + "took": 2, + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 4, + "relation": "eq" + }, + "max_score": 0.7711549, + "hits": [ + { + "_index": "my-test-data", + "_id": "3", + "_score": 0.7711549, + "fields": { + "passage_text": [ + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + ] + }, + "highlight": { + "passage_text": [ + "(also known as simply Washington or D.C., and officially as the District of Columbia) is the capital", + "of the United States.", + "It is a federal district." + ] + } + }, + { + "_index": "my-test-data", + "_id": "1", + "_score": 0.0025114636, + "fields": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + }, + "highlight": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + } + }, + { + "_index": "my-test-data", + "_id": "2", + "_score": 02.487649e-05, + "fields": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan." + ] + }, + "highlight": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean.", + "Its capital is Saipan." + ] + } + }, + { + "_index": "my-test-data", + "_id": "4", + "_score": 6.3392104e-06, + "fields": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + ] + }, + "highlight": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States", + "As of 2017, capital punishment is legal in 30 of the 50 states." + ] + } + } + ] + }, + "profile": { + "shards": [] + } +} +``` + +Note: You can avoid writing the query twice by using query_text_path instead of query_text, as follows: +```json +POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +{ + "query": { + "match": { + "passage_text": "What is the capital city of America?" + } + }, + "ext": { + "rerank": { + "query_context": { + "query_text_path": "query.match.passage_text.query" + } + } + }, + "highlight": { + "pre_tags": [""], + "post_tags": [""], + "fields": {"passage_text": {}} + }, + "_source": false, + "fields": ["passage_text"] +} +``` diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md new file mode 100644 index 0000000000..2cc62d74eb --- /dev/null +++ b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md @@ -0,0 +1,625 @@ +# Topic + +[Reranking pipeline](https://opensearch.org/docs/latest/search-plugins/search-relevance/reranking-search-results/) is a feature released in OpenSearch 2.12. +It can rerank search results, providing a relevance score for each document in the search results with respect to the search query. +The relevance score is calculated by a cross-encoder model. + +This tutorial explains how to use the [Cohere Rerank 3.5 model in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-supported.html) in a reranking pipeline. + +Note: Replace the placeholders that start with `your_` with your own values. + +# Steps + +## 0. Test the model on Amazon Bedrock +You can perform a reranking test with the following code. + +```python +import json +import boto3 +bedrock_region = "your_bedrock_model_region_like_us-west-2" +bedrock_runtime_client = boto3.client("bedrock-runtime", region_name=bedrock_region) + +modelId = "cohere.rerank-v3-5:0" +contentType = "application/json" +accept = "*/*" + +body = json.dumps({ + "query": "What is the capital city of America?", + "documents": [ + "Carson City is the capital city of the American state of Nevada.", + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + ], + "api_version": 2 +}) + +response = bedrock_runtime_client.invoke_model( + modelId=modelId, + contentType=contentType, + accept=accept, + body=body +) +results = json.loads(response.get('body').read())["results"] +print(json.dumps(sorted(results, key=lambda x: x['index']),indent=2)) +``` + +The reranking results are as follows: + +``` +[ + { + "index": 0, + "relevance_score": 0.32418242 + }, + { + "index": 1, + "relevance_score": 0.07456104 + }, + { + "index": 2, + "relevance_score": 0.7190094 + }, + { + "index": 3, + "relevance_score": 0.06124987 + } +] +``` + +## 1. Create a connector and register the model + +To create a connector for the model, send the following request. If you are using self-managed OpenSearch, supply your AWS credentials: +```json +POST /_plugins/_ml/connectors/_create +{ + "name": "Amazon Bedrock cross-encoder model", + "description": "Test connector for Amazon Bedrock cross-encoder model", + "version": 1, + "protocol": "aws_sigv4", + "credential": { + "access_key": "your_access_key", + "secret_key": "your_secret_key", + "session_token": "your_session_token" + }, + "parameters": { + "region": "your_bedrock_model_region_like_us-west-2", + "service_name": "bedrock", + "api_version": 2 + }, + "actions": [ + { + "action_type": "predict", + "method": "POST", + "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/cohere.rerank-v3-5:0/invoke", + "headers": { + "x-amz-content-sha256": "required", + "content-type": "application/json" + }, + "pre_process_function": """ + def query_text = params.query_text; + def text_docs = params.text_docs; + def textDocsBuilder = new StringBuilder('['); + for (int i=0; i"], + "post_tags": [""], + "fields": {"passage_text": {}} + }, + "_source": false, + "fields": ["passage_text"] +} +``` + +The first document in the response is `Carson City is the capital city of the American state of Nevada`, which is incorrect: +```json +{ + "took": 2, + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 4, + "relation": "eq" + }, + "max_score": 2.5045562, + "hits": [ + { + "_index": "my-test-data", + "_id": "1", + "_score": 2.5045562, + "fields": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + }, + "highlight": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + } + }, + { + "_index": "my-test-data", + "_id": "2", + "_score": 0.5807494, + "fields": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan." + ] + }, + "highlight": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean.", + "Its capital is Saipan." + ] + } + }, + { + "_index": "my-test-data", + "_id": "3", + "_score": 0.5261191, + "fields": { + "passage_text": [ + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + ] + }, + "highlight": { + "passage_text": [ + "(also known as simply Washington or D.C., and officially as the District of Columbia) is the capital", + "of the United States.", + "It is a federal district." + ] + } + }, + { + "_index": "my-test-data", + "_id": "4", + "_score": 0.5083029, + "fields": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + ] + }, + "highlight": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States", + "As of 2017, capital punishment is legal in 30 of the 50 states." + ] + } + } + ] + } +} +``` + +Next, test the query using the reranking pipeline: +```json +POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +{ + "query": { + "match": { + "passage_text": "What is the capital city of America?" + } + }, + "ext": { + "rerank": { + "query_context": { + "query_text": "What is the capital city of America?" + } + } + }, + "highlight": { + "pre_tags": [""], + "post_tags": [""], + "fields": {"passage_text": {}} + }, + "_source": false, + "fields": ["passage_text"] +} +``` + +The first document in the response is `"Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."`, which is correct: + +```json +{ + "took": 2, + "timed_out": false, + "_shards": { + "total": 1, + "successful": 1, + "skipped": 0, + "failed": 0 + }, + "hits": { + "total": { + "value": 4, + "relation": "eq" + }, + "max_score": 0.7190094, + "hits": [ + { + "_index": "my-test-data", + "_id": "3", + "_score": 0.7190094, + "fields": { + "passage_text": [ + "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district." + ] + }, + "highlight": { + "passage_text": [ + "(also known as simply Washington or D.C., and officially as the District of Columbia) is the capital", + "of the United States.", + "It is a federal district." + ] + } + }, + { + "_index": "my-test-data", + "_id": "1", + "_score": 0.32418242, + "fields": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + }, + "highlight": { + "passage_text": [ + "Carson City is the capital city of the American state of Nevada." + ] + } + }, + { + "_index": "my-test-data", + "_id": "2", + "_score": 0.07456104, + "fields": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan." + ] + }, + "highlight": { + "passage_text": [ + "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean.", + "Its capital is Saipan." + ] + } + }, + { + "_index": "my-test-data", + "_id": "4", + "_score": 0.06124987, + "fields": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states." + ] + }, + "highlight": { + "passage_text": [ + "Capital punishment (the death penalty) has existed in the United States since beforethe United States", + "As of 2017, capital punishment is legal in 30 of the 50 states." + ] + } + } + ] + }, + "profile": { + "shards": [] + } +} +``` + +Note: You can avoid writing the query twice by using query_text_path instead of query_text, as follows: +```json +POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +{ + "query": { + "match": { + "passage_text": "What is the capital city of America?" + } + }, + "ext": { + "rerank": { + "query_context": { + "query_text_path": "query.match.passage_text.query" + } + } + }, + "highlight": { + "pre_tags": [""], + "post_tags": [""], + "fields": {"passage_text": {}} + }, + "_source": false, + "fields": ["passage_text"] +} +``` From ecef600b235af7ce31fef17f9d57b5e814f88e60 Mon Sep 17 00:00:00 2001 From: tkykenmt Date: Tue, 3 Dec 2024 14:52:39 +0900 Subject: [PATCH 2/8] fix bedrock url to reflect region parameter Signed-off-by: tkykenmt --- ...ank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md | 4 ++-- ...ank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md index 8036ea23d1..d1434fe011 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -89,7 +89,7 @@ POST /_plugins/_ml/connectors/_create { "action_type": "predict", "method": "POST", - "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/amazon.rerank-v1:0/invoke", + "url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/amazon.rerank-v1:0/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" @@ -159,7 +159,7 @@ POST /_plugins/_ml/connectors/_create { "action_type": "predict", "method": "POST", - "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/amazon.rerank-v1:0/invoke", + "url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/amazon.rerank-v1:0/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md index 2cc62d74eb..abe34f2b9e 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md @@ -91,7 +91,7 @@ POST /_plugins/_ml/connectors/_create { "action_type": "predict", "method": "POST", - "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/cohere.rerank-v3-5:0/invoke", + "url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/cohere.rerank-v3-5:0/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" @@ -162,7 +162,7 @@ POST /_plugins/_ml/connectors/_create { "action_type": "predict", "method": "POST", - "url": "https://bedrock-runtime.us-west-2.amazonaws.com/model/cohere.rerank-v3-5:0/invoke", + "url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/cohere.rerank-v3-5:0/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" From 8183b4206302da4bf224e67aabf93b19b6bb8d86 Mon Sep 17 00:00:00 2001 From: tkykenmt Date: Sun, 15 Dec 2024 23:25:29 +0900 Subject: [PATCH 3/8] update error handling to throw exception when post processing function recieve empty result from a model. Signed-off-by: tkykenmt --- ...eline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md | 10 +++++----- ...eline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md index d1434fe011..50c4b8751c 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -112,8 +112,8 @@ POST /_plugins/_ml/connectors/_create """, "request_body": "{ \"query\": \"${parameters.query}\", \"documents\": ${parameters.documents} }", "post_process_function": """ - if (params.results == null) { - return "no result generated"; + if (params.result == null || params.result.length > 0) { + throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; def relevance_scores = new Double[outputs.length]; @@ -182,8 +182,8 @@ POST /_plugins/_ml/connectors/_create """, "request_body": "{ \"query\": \"${parameters.query}\", \"documents\": ${parameters.documents} }", "post_process_function": """ - if (params.results == null) { - return "no result generated"; + if (params.result == null || params.result.length > 0) { + throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; def relevance_scores = new Double[outputs.length]; @@ -277,7 +277,7 @@ By default, Amazon Bedrock Rerank API output has the following format: ] ``` -The connector `post_process_function` transforms the model's output into a format that the [Reranker processor](https://opensearch.org/docs/latest/search-plugins/search-pipelines/rerank-processor/) can interpret. This adapted format is as follows: +The connector `post_process_function` transforms the model's output into a format that the [Reranker processor](https://opensearch.org/docs/latest/search-plugins/search-pipelines/rerank-processor/) can interpret, and orders result by index. This adapted format is as follows: ```json { "inference_results": [ diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md index abe34f2b9e..3c7fc53033 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md @@ -114,8 +114,8 @@ POST /_plugins/_ml/connectors/_create """, "request_body": "{ \"documents\": ${parameters.texts}, \"query\": \"${parameters.query}\", \"api_version\": ${parameters.api_version}}", "post_process_function": """ - if (params.results == null) { - return "no result generated"; + if (params.result == null || params.result.length > 0) { + throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; def relevance_scores = new Double[outputs.length]; @@ -185,8 +185,8 @@ POST /_plugins/_ml/connectors/_create """, "request_body": "{ \"documents\": ${parameters.texts}, \"query\": \"${parameters.query}\", \"api_version\": ${parameters.api_version}}", "post_process_function": """ - if (params.results == null) { - return "no result generated"; + if (params.result == null || params.result.length > 0) { + throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; def relevance_scores = new Double[outputs.length]; @@ -280,7 +280,7 @@ By default, Amazon Bedrock Rerank API output has the following format: ] ``` -The connector `post_process_function` transforms the model's output into a format that the [Reranker processor](https://opensearch.org/docs/latest/search-plugins/search-pipelines/rerank-processor/) can interpret. This adapted format is as follows: +The connector `post_process_function` transforms the model's output into a format that the [Reranker processor](https://opensearch.org/docs/latest/search-plugins/search-pipelines/rerank-processor/) can interpret, and orders result by index. This adapted format is as follows: ```json { "inference_results": [ From 9482b472b2bc68bba61267c87f484967362e2c5b Mon Sep 17 00:00:00 2001 From: tkykenmt Date: Wed, 25 Dec 2024 23:37:28 +0900 Subject: [PATCH 4/8] fix tutorials for cross encoder models on Amazon Bedrock based on review comments on #3278 Signed-off-by: tkykenmt --- ...h_Amazon_Rerank_model_on_Amazon_Bedrock.md | 130 +++++++++++------ ...h_Cohere_Rerank_model_on_Amazon_Bedrock.md | 132 ++++++++++++------ 2 files changed, 171 insertions(+), 91 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md index 50c4b8751c..32b8aa876a 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -1,17 +1,15 @@ # Topic -[Reranking pipeline](https://opensearch.org/docs/latest/search-plugins/search-relevance/reranking-search-results/) is a feature released in OpenSearch 2.12. -It can rerank search results, providing a relevance score for each document in the search results with respect to the search query. -The relevance score is calculated by a cross-encoder model. +[Reranking pipeline](https://opensearch.org/docs/latest/search-plugins/search-relevance/reranking-search-results/) is a feature released in OpenSearch 2.12. It can rerank search results, providing a relevance score with respect to the search query for each matching document. The relevance score is calculated by a cross-encoder model. -This tutorial explains how to use the [Amazon Rerank 1.0 model in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-supported.html) in a reranking pipeline. +This tutorial illustrates using the [Amazon Rerank 1.0 model in Amazon Bedrock](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-supported.html) in a reranking pipeline. Note: Replace the placeholders that start with `your_` with your own values. # Steps ## 0. Test the model on Amazon Bedrock -You can perform a reranking test with the following code. +You can perform a reranking test using the following code. ```python import json @@ -40,11 +38,39 @@ response = bedrock_runtime_client.invoke_model( body=body ) results = json.loads(response.get('body').read())["results"] -print(json.dumps(sorted(results, key=lambda x: x['index']),indent=2)) +print(json.dumps(results, indent=2)) +``` + +The reranking result is ordering by the highest score first: +``` +[ + { + "index": 2, + "relevance_score": 0.7711548724998493 + }, + { + "index": 0, + "relevance_score": 0.0025114635138098534 + }, + { + "index": 1, + "relevance_score": 2.4876490010363496e-05 + }, + { + "index": 3, + "relevance_score": 6.339210403977635e-06 + } +] ``` -The reranking results are as follows: +You can sort the result by index number. + +```python +print(json.dumps(sorted(results, key=lambda x: x['index']),indent=2)) +``` + +The results are as follows: ``` [ { @@ -82,14 +108,16 @@ POST /_plugins/_ml/connectors/_create "session_token": "your_session_token" }, "parameters": { - "region": "your_bedrock_model_region_like_us-west-2", - "service_name": "bedrock" + "service_name": "bedrock", + "service_code": "bedrock-runtime", + "region": "your_bedrock_model_region_like_us", + "model_name": "amazon.rerank-v1:0" }, "actions": [ { - "action_type": "predict", + "action_type": "PREDICT", "method": "POST", - "url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/amazon.rerank-v1:0/invoke", + "url": "https://${parameters.service_code}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" @@ -99,20 +127,25 @@ POST /_plugins/_ml/connectors/_create def text_docs = params.text_docs; def textDocsBuilder = new StringBuilder('['); for (int i=0; i 0) { + if (params.results == null || params.results.length == 0) { throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; @@ -123,8 +156,8 @@ POST /_plugins/_ml/connectors/_create } def resultBuilder = new StringBuilder('['); for (int i=0; i 0) { + if (params.results == null || params.results.length == 0) { throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; @@ -193,8 +233,8 @@ POST /_plugins/_ml/connectors/_create } def resultBuilder = new StringBuilder('['); for (int i=0; i 0) { + if (params.results == null || params.results.length == 0) { throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; @@ -125,8 +158,8 @@ POST /_plugins/_ml/connectors/_create } def resultBuilder = new StringBuilder('['); for (int i=0; i 0) { + if (params.results == null || params.results.length == 0) { throw new IllegalArgumentException("Post process function input is empty."); } def outputs = params.results; @@ -196,8 +236,8 @@ POST /_plugins/_ml/connectors/_create } def resultBuilder = new StringBuilder('['); for (int i=0; i Date: Fri, 27 Dec 2024 11:40:51 +0900 Subject: [PATCH 5/8] fix wrong service name on tutorials for cross encoder models on Amazon Bedrock #3278 Signed-off-by: tkykenmt --- ...eline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md | 10 +++++----- ...eline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md index 32b8aa876a..4684882d9e 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -253,7 +253,7 @@ Use the connector ID from the response to register and deploy the model: ```json POST /_plugins/_ml/models/_register?deploy=true { - "name": "Bedrock Cross-Encoder model", + "name": "Amazon Bedrock Cross-Encoder model", "function_name": "remote", "description": "test rerank model", "connector_id": "your_connector_id" @@ -390,9 +390,9 @@ POST _bulk ``` ### 2.2 Create a reranking pipeline ```json -PUT /_search/pipeline/rerank_pipeline_sagemaker +PUT /_search/pipeline/rerank_pipeline_bedrock { - "description": "Pipeline for reranking with Sagemaker cross-encoder model", + "description": "Pipeline for reranking with Bedrock cross-encoder model", "response_processors": [ { "rerank": { @@ -520,7 +520,7 @@ The first document in the response is `Carson City is the capital city of the Am Next, test the query using the reranking pipeline: ```json -POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +POST my-test-data/_search?search_pipeline=rerank_pipeline_bedrock { "query": { "match": { @@ -637,7 +637,7 @@ The first document in the response is `"Washington, D.C. (also known as simply W Note: You can avoid writing the query twice by using the `query_text_path` instead of `query_text` as follows: ```json -POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +POST my-test-data/_search?search_pipeline=rerank_pipeline_bedrock { "query": { "match": { diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md index f1f420d516..654bf9637b 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md @@ -393,9 +393,9 @@ POST _bulk ``` ### 2.2 Create a reranking pipeline ```json -PUT /_search/pipeline/rerank_pipeline_sagemaker +PUT /_search/pipeline/rerank_pipeline_bedrock { - "description": "Pipeline for reranking with Sagemaker cross-encoder model", + "description": "Pipeline for reranking with Bedrock cross-encoder model", "response_processors": [ { "rerank": { @@ -523,7 +523,7 @@ The first document in the response is `Carson City is the capital city of the Am Next, test the query using the reranking pipeline: ```json -POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +POST my-test-data/_search?search_pipeline=rerank_pipeline_bedrock { "query": { "match": { @@ -640,7 +640,7 @@ The first document in the response is `"Washington, D.C. (also known as simply W Note: You can avoid writing the query twice by using the `query_text_path` instead of `query_text` as follows: ```json -POST my-test-data/_search?search_pipeline=rerank_pipeline_sagemaker +POST my-test-data/_search?search_pipeline=rerank_pipeline_bedrock { "query": { "match": { From 0a549fb925eff6b1a9e95c955a31e12d149fcfb6 Mon Sep 17 00:00:00 2001 From: tkykenmt Date: Sun, 29 Dec 2024 23:26:36 +0900 Subject: [PATCH 6/8] fix some notes on tutorials for cross encoder models on Amazon Bedrock #3278 Signed-off-by: tkykenmt --- ...ank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md | 4 +--- ...ank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md index 4684882d9e..be53234f5b 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -277,8 +277,6 @@ POST _plugins/_ml/models/your_model_id/_predict } ``` -Each item in the array comprises a `query_text` and a `text_docs` string, separated by a ` , `. - Alternatively, you can test the model as follows: ```json POST _plugins/_ml/_predict/text_similarity/your_model_id @@ -371,7 +369,7 @@ The connector `post_process_function` transforms the model's output into a forma ``` Explanation of the response: -1. The response contains two `similarity` outputs. For each `similarity` output, the `data` array contains a relevance score of each document against the query. +1. The response contains four `similarity` outputs. For each `similarity` output, the `data` array contains a relevance score of each document against the query. 2. The `similarity` outputs are provided in the order of the input documents; the first similarity result pertains to the first document. ## 2. Reranking pipeline diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md index 654bf9637b..9082f80ed5 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md @@ -280,8 +280,6 @@ POST _plugins/_ml/models/your_model_id/_predict } ``` -Each item in the array comprises a `query_text` and a `text_docs` string, separated by a ` , `. - Alternatively, you can test the model as follows: ```json POST _plugins/_ml/_predict/text_similarity/your_model_id @@ -374,7 +372,7 @@ The connector `post_process_function` transforms the model's output into a forma ``` Explanation of the response: -1. The response contains two `similarity` outputs. For each `similarity` output, the `data` array contains a relevance score of each document against the query. +1. The response contains four `similarity` outputs. For each `similarity` output, the `data` array contains a relevance score of each document against the query. 2. The `similarity` outputs are provided in the order of the input documents; the first similarity result pertains to the first document. ## 2. Reranking pipeline From e4c55ce366393bee27553d9227231c735d86226a Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Fri, 3 Jan 2025 15:30:59 -0800 Subject: [PATCH 7/8] some minor fix Signed-off-by: Yaliang Wu --- ...h_Amazon_Rerank_model_on_Amazon_Bedrock.md | 14 +++++------ ...h_Cohere_Rerank_model_on_Amazon_Bedrock.md | 24 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md index be53234f5b..37f763ffca 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -109,15 +109,15 @@ POST /_plugins/_ml/connectors/_create }, "parameters": { "service_name": "bedrock", - "service_code": "bedrock-runtime", - "region": "your_bedrock_model_region_like_us", + "endpoint": "bedrock-runtime", + "region": "your_bedrock_model_region_like_us-west-2", "model_name": "amazon.rerank-v1:0" }, "actions": [ { "action_type": "PREDICT", "method": "POST", - "url": "https://${parameters.service_code}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", + "url": "https://${parameters. endpoint}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" @@ -186,15 +186,15 @@ POST /_plugins/_ml/connectors/_create }, "parameters": { "service_name": "bedrock", - "service_code": "bedrock-runtime", - "region": "your_bedrock_model_region_like_us", + "endpoint": "bedrock-runtime", + "region": "your_bedrock_model_region_like_us-west-2", "model_name": "amazon.rerank-v1:0" }, "actions": [ { "action_type": "PREDICT", "method": "POST", - "url": "https://${parameters.service_code}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", + "url": "https://${parameters.endpoint}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" @@ -267,7 +267,7 @@ POST _plugins/_ml/models/your_model_id/_predict { "parameters": { "query": "What is the capital city of America?", - "texts": [ + "documents": [ "Carson City is the capital city of the American state of Nevada.", "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md index 9082f80ed5..9bfb5679ab 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md @@ -98,8 +98,8 @@ To create a connector for the model, send the following request. If you are usin ```json POST /_plugins/_ml/connectors/_create { - "name": "Amazon Bedrock cross-encoder model", - "description": "Test connector for Amazon Bedrock cross-encoder model", + "name": "Amazon Bedrock Cohere rerank model", + "description": "Test connector for Amazon Bedrock Cohere rerank model", "version": 1, "protocol": "aws_sigv4", "credential": { @@ -109,8 +109,8 @@ POST /_plugins/_ml/connectors/_create }, "parameters": { "service_name": "bedrock", - "service_code": "bedrock-runtime", - "region": "your_bedrock_model_region_like_us", + "endpoint": "bedrock-runtime", + "region": "your_bedrock_model_region_like_us-west-2", "model_name": "cohere.rerank-v3-5:0", "api_version": 2 }, @@ -118,7 +118,7 @@ POST /_plugins/_ml/connectors/_create { "action_type": "PREDICT", "method": "POST", - "url": "https://${parameters.service_code}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", + "url": "https://${parameters. endpoint}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" @@ -178,8 +178,8 @@ If using the Amazon Opensearch Service, you can provide an IAM role ARN that all ```json POST /_plugins/_ml/connectors/_create { - "name": "Amazon Bedrock cross-encoder model", - "description": "Test connector for Amazon Bedrock cross-encoder model", + "name": "Amazon Bedrock Cohere rerank model", + "description": "Test connector for Amazon Bedrock Cohere rerank model", "version": 1, "protocol": "aws_sigv4", "credential": { @@ -187,8 +187,8 @@ POST /_plugins/_ml/connectors/_create }, "parameters": { "service_name": "bedrock", - "service_code": "bedrock-runtime", - "region": "your_bedrock_model_region_like_us", + "endpoint": "bedrock-runtime", + "region": "your_bedrock_model_region_like_us-west-2", "model_name": "cohere.rerank-v3-5:0", "api_version": 2 }, @@ -196,7 +196,7 @@ POST /_plugins/_ml/connectors/_create { "action_type": "PREDICT", "method": "POST", - "url": "https://${parameters.service_code}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", + "url": "https://${parameters. endpoint}.${parameters.region}.amazonaws.com/model/${parameters.model_name}/invoke", "headers": { "x-amz-content-sha256": "required", "content-type": "application/json" @@ -256,7 +256,7 @@ Use the connector ID from the response to register and deploy the model: ```json POST /_plugins/_ml/models/_register?deploy=true { - "name": "Amazon Bedrock Cross-Encoder model", + "name": "Amazon Bedrock Cohere rerank model", "function_name": "remote", "description": "test rerank model", "connector_id": "your_connector_id" @@ -270,7 +270,7 @@ POST _plugins/_ml/models/your_model_id/_predict { "parameters": { "query": "What is the capital city of America?", - "texts": [ + "documents": [ "Carson City is the capital city of the American state of Nevada.", "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan.", "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district.", From 72643dafac98c1f5c9d43364b7f67b6b35bd3a2a Mon Sep 17 00:00:00 2001 From: Yaliang Wu Date: Fri, 3 Jan 2025 15:37:07 -0800 Subject: [PATCH 8/8] change cross-encoder to rerank Signed-off-by: Yaliang Wu --- ...ine_with_Amazon_Rerank_model_on_Amazon_Bedrock.md | 12 ++++++------ ...ine_with_Cohere_Rerank_model_on_Amazon_Bedrock.md | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md index 37f763ffca..f8c20b7353 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md @@ -98,8 +98,8 @@ To create a connector for the model, send the following request. If you are usin ```json POST /_plugins/_ml/connectors/_create { - "name": "Amazon Bedrock cross-encoder model", - "description": "Test connector for Amazon Bedrock cross-encoder model", + "name": "Amazon Bedrock rerank model", + "description": "Test connector for Amazon Bedrock rerank model", "version": 1, "protocol": "aws_sigv4", "credential": { @@ -177,8 +177,8 @@ If using the Amazon Opensearch Service, you can provide an IAM role ARN that all ```json POST /_plugins/_ml/connectors/_create { - "name": "Amazon Bedrock cross-encoder model", - "description": "Test connector for Amazon Bedrock cross-encoder model", + "name": "Amazon Bedrock rerank model", + "description": "Test connector for Amazon Bedrock rerank model", "version": 1, "protocol": "aws_sigv4", "credential": { @@ -253,7 +253,7 @@ Use the connector ID from the response to register and deploy the model: ```json POST /_plugins/_ml/models/_register?deploy=true { - "name": "Amazon Bedrock Cross-Encoder model", + "name": "Amazon Bedrock rerank model", "function_name": "remote", "description": "test rerank model", "connector_id": "your_connector_id" @@ -390,7 +390,7 @@ POST _bulk ```json PUT /_search/pipeline/rerank_pipeline_bedrock { - "description": "Pipeline for reranking with Bedrock cross-encoder model", + "description": "Pipeline for reranking with Bedrock rerank model", "response_processors": [ { "rerank": { diff --git a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md index 9bfb5679ab..f29b1543c7 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_Cohere_Rerank_model_on_Amazon_Bedrock.md @@ -393,7 +393,7 @@ POST _bulk ```json PUT /_search/pipeline/rerank_pipeline_bedrock { - "description": "Pipeline for reranking with Bedrock cross-encoder model", + "description": "Pipeline for reranking with Bedrock Cohere rerank model", "response_processors": [ { "rerank": {