Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tutorials for cross encoder models on Amazon Bedrock #3278

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

tkykenmt
Copy link
Contributor

Description

Add tutorials for Amazon Bedrock cross-encoder model (Amazon Rerank 1.0 and Cohere Rerank 3.5)

Related Issues

Resolves #3245

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

"content-type": "application/json"
},
"pre_process_function": """
def query_text = params.query_text;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about raising a PR for pre & post processor functions for Bedrock rerank model like these.

In that way, customer can just mention the name of the pre/post process function rather than writing painless script in the connector payload.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think built-in pre & post processor is good solution to reduce overhead and ease implementation. I've submitted issues for the topic.

#3254

I'm not familiar with code development, but I'm happy to contribute in this area.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to implement built-in function in #3254 but please let me leave custom pre and post function as it is in this PR.

@tkykenmt tkykenmt temporarily deployed to ml-commons-cicd-env-require-approval December 16, 2024 17:40 — with GitHub Actions Inactive
Copy link
Contributor

@brianf-aws brianf-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with what was authored just minor feedback. Thank you for the contribution!

{
"action_type": "predict",
"method": "POST",
"url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/amazon.rerank-v1:0/invoke",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar feedback like before :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

{
"action_type": "predict",
"method": "POST",
"url": "https://bedrock-runtime.${parameters.region}.amazonaws.com/model/cohere.rerank-v3-5:0/invoke",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar feedback like before

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

Copy link
Contributor

@kolchfa-aws kolchfa-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some text suggestions for one of the tutorials. Since the text is the same, please apply to both tutorials. Thanks!

# 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
It can rerank search results, providing a relevance score for each document in the search results with respect to the search query.
It can rerank search results, providing a relevance score with respect to the search query for each matching document.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm going to merge your recommendation on next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm going to merge your recommendation on next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

# Steps

## 0. Test the model on Amazon Bedrock
You can perform a reranking test with the following code.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can perform a reranking test with the following code.
You can perform a reranking test using the following code:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm going to merge your recommendation on next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

}
```

If using the Amazon Opensearch Service, you can provide an IAM role arn that allows access to the bedrock service. Refer to this [AWS doc](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ml-amazon-connector.html)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If using the Amazon Opensearch Service, you can provide an IAM role arn that allows access to the bedrock service. Refer to this [AWS doc](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ml-amazon-connector.html)
If using the Amazon Opensearch Service, you can provide an IAM role ARN that allows access to the Amazon Bedrock service. For more information, see [AWS documentation](https://docs.aws.amazon.com/opensearch-service/latest/developerguide/ml-amazon-connector.html):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the sentence based on your recommendation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

}
```

Each item in the array comprises a query_text and a text_docs string, separated by a .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is incomplete. Separated by what?

Suggested change
Each item in the array comprises a query_text and a text_docs string, separated by a .
Each item in the array comprises a `query_text` and a `text_docs` string, separated by a .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" separated by a , ." is correct sentence. I'm going to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47


The connector `pre_process_function` transforms the input into the format required by parameters shown previously.

By default, Amazon Bedrock Rerank API output has the following format:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default, Amazon Bedrock Rerank API output has the following format:
By default, the Amazon Bedrock Rerank API output has the following format:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to apply your recommendation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

]
```

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
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 the results by index. This adapted format is as follows:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to apply your recommendation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47


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.
2. The `similarity` outputs are provided in the order of the input documents; the first result of similarity pertains to the first document.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
2. The `similarity` outputs are provided in the order of the input documents; the first result of similarity pertains to the first document.
2. The `similarity` outputs are provided in the order of the input documents; the first similarity result pertains to the first document.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to apply your recommendation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

}
```

Note: if you provide multiple filed names in `document_fields`, the values of all fields are first concatenated and then reranking is performed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note: if you provide multiple filed names in `document_fields`, the values of all fields are first concatenated and then reranking is performed.
Note: if you provide multiple file names in `document_fields`, the values of all fields are first concatenated and then reranking is performed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed is typo. field is correct. I'm going to fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

}
```

Note: You can avoid writing the query twice by using query_text_path instead of query_text, as follows:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note: You can avoid writing the query twice by using query_text_path instead of query_text, as follows:
Note: You can avoid writing the query twice by using the `query_text_path` instead of `query_text` as follows:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to apply your recoomendation.

body=body
)
results = json.loads(response.get('body').read())["results"]
print(json.dumps(sorted(results, key=lambda x: x['index']),indent=2))
Copy link
Collaborator

@ylwu-amzn ylwu-amzn Dec 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about just print the model response directly? Adding sorted may confuse user as this is some processed response.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print(json.dumps(results, indent=2))

Response

[
  {
    "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
  }
]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'm going to updated based on your recommendation on next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47


Test the model by using the Predict API:
```json
POST _plugins/_ml/models/your_model_id/_predict
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure every step in the tutorial works. I tested and this step failed

{
  "error": {
    "root_cause": [
      {
        "type": "script_exception",
        "reason": "compile error",
        "script_stack": [
          "...     resultBuilder.append(' {\\\"name\\\": \\\"similarity ...",
          "                             ^---- HERE"
        ],
        "script": "\n        if (params.result == null || params.result.length > 0) {\n          throw new IllegalArgumentException(\"Post process function input is empty.\");\n        }\n        def outputs = params.results;\n        def relevance_scores = new Double[outputs.length];\n        for (int i=0; i<outputs.length; i++) {\n          def index = new BigDecimal(outputs[i].index.toString()).intValue();\n          relevance_scores[index] = outputs[i].relevance_score;\n        }\n        def resultBuilder = new StringBuilder('[');\n        for (int i=0; i<relevance_scores.length; i++) {\n          resultBuilder.append(' {\\\"name\\\": \\\"similarity\\\", \\\"data_type\\\": \\\"FLOAT32\\\", \\\"shape\\\": [1],');\n          resultBuilder.append('\\\"data\\\": [');\n          resultBuilder.append(relevance_scores[i]);\n          resultBuilder.append(']}');\n          if (i<outputs.length - 1) {\n            resultBuilder.append(',');\n          }\n        }\n        resultBuilder.append(']');\n        return resultBuilder.toString();\n      ",
        "lang": "painless",
        "position": {
          "offset": 598,
          "start": 573,
          "end": 623
        }
      }
    ],
    "type": "m_l_exception",
    "reason": "m_l_exception: Fail to execute PREDICT in aws connector",
    "caused_by": {
      "type": "script_exception",
      "reason": "compile error",
      "script_stack": [
        "...     resultBuilder.append(' {\\\"name\\\": \\\"similarity ...",
        "                             ^---- HERE"
      ],
      "script": "\n        if (params.result == null || params.result.length > 0) {\n          throw new IllegalArgumentException(\"Post process function input is empty.\");\n        }\n        def outputs = params.results;\n        def relevance_scores = new Double[outputs.length];\n        for (int i=0; i<outputs.length; i++) {\n          def index = new BigDecimal(outputs[i].index.toString()).intValue();\n          relevance_scores[index] = outputs[i].relevance_score;\n        }\n        def resultBuilder = new StringBuilder('[');\n        for (int i=0; i<relevance_scores.length; i++) {\n          resultBuilder.append(' {\\\"name\\\": \\\"similarity\\\", \\\"data_type\\\": \\\"FLOAT32\\\", \\\"shape\\\": [1],');\n          resultBuilder.append('\\\"data\\\": [');\n          resultBuilder.append(relevance_scores[i]);\n          resultBuilder.append(']}');\n          if (i<outputs.length - 1) {\n            resultBuilder.append(',');\n          }\n        }\n        resultBuilder.append(']');\n        return resultBuilder.toString();\n      ",
      "lang": "painless",
      "position": {
        "offset": 598,
        "start": 573,
        "end": 623
      },
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "unexpected character [' {\\\"]. The only valid escape sequences in strings starting with ['] are [\\\\] and [\\'].",
        "caused_by": {
          "type": "lexer_no_viable_alt_exception",
          "reason": "lexer_no_viable_alt_exception: null"
        }
      }
    }
  },
  "status": 500
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove unnecessary escape character and test again on my side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

def text_docs = params.text_docs;
def textDocsBuilder = new StringBuilder('[');
for (int i=0; i<text_docs.length; i++) {
textDocsBuilder.append('\"');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
textDocsBuilder.append('\"');
textDocsBuilder.append('"');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove unnecessary escape character and test again on my side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

for (int i=0; i<text_docs.length; i++) {
textDocsBuilder.append('\"');
textDocsBuilder.append(text_docs[i]);
textDocsBuilder.append('\"');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
textDocsBuilder.append('\"');
textDocsBuilder.append('"');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove unnecessary escape character and test again on my side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

}
}
textDocsBuilder.append(']');
def parameters = '{ \"query\": \"' + query_text + '\", \"documents\": ' + textDocsBuilder.toString() + ' }';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def parameters = '{ \"query\": \"' + query_text + '\", \"documents\": ' + textDocsBuilder.toString() + ' }';
def parameters = '{ "query": "' + query_text + '", "documents": ' + textDocsBuilder.toString() + ' }';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove unnecessary escape character and test again on my side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

}
textDocsBuilder.append(']');
def parameters = '{ \"query\": \"' + query_text + '\", \"documents\": ' + textDocsBuilder.toString() + ' }';
return '{\"parameters\": ' + parameters + '}';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return '{\"parameters\": ' + parameters + '}';
return '{"parameters": ' + parameters + '}';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove unnecessary escape character and test again on my side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

""",
"request_body": "{ \"query\": \"${parameters.query}\", \"documents\": ${parameters.documents} }",
"post_process_function": """
if (params.result == null || params.result.length > 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (params.result == null || params.result.length > 0) {
if (params.results == null || params.results.length == 0) {

Copy link
Contributor Author

@tkykenmt tkykenmt Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to update condition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

Comment on lines 125 to 133
for (int i=0; i<relevance_scores.length; i++) {
resultBuilder.append(' {\"name\": \"similarity\", \"data_type\": \"FLOAT32\", \"shape\": [1],');
resultBuilder.append('\"data\": [');
resultBuilder.append(relevance_scores[i]);
resultBuilder.append(']}');
if (i<outputs.length - 1) {
resultBuilder.append(',');
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (int i=0; i<relevance_scores.length; i++) {
resultBuilder.append(' {\"name\": \"similarity\", \"data_type\": \"FLOAT32\", \"shape\": [1],');
resultBuilder.append('\"data\": [');
resultBuilder.append(relevance_scores[i]);
resultBuilder.append(']}');
if (i<outputs.length - 1) {
resultBuilder.append(',');
}
}
for (int i=0; i<relevance_scores.length; i++) {
resultBuilder.append(' {"name": "similarity", "data_type": "FLOAT32", "shape": [1],');
resultBuilder.append('"data": [');
resultBuilder.append(relevance_scores[i]);
resultBuilder.append(']}');
if (i<outputs.length - 1) {
resultBuilder.append(',');
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove unnecessary escape character and test again on my side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 9482b47

@ylwu-amzn
Copy link
Collaborator

Please make sure the tutorial can work. I fixed docs/tutorials/rerank/rerank_pipeline_with_Amazon_Rerank_model_on_Amazon_Bedrock.md , please fix the Cohere one following the same way

@tkykenmt tkykenmt requested a deployment to ml-commons-cicd-env-require-approval December 25, 2024 04:09 — with GitHub Actions Waiting
@tkykenmt tkykenmt requested a deployment to ml-commons-cicd-env-require-approval December 25, 2024 04:09 — with GitHub Actions Waiting
@tkykenmt tkykenmt temporarily deployed to ml-commons-cicd-env-require-approval December 25, 2024 14:38 — with GitHub Actions Inactive
@tkykenmt tkykenmt temporarily deployed to ml-commons-cicd-env-require-approval December 25, 2024 14:38 — with GitHub Actions Inactive
@tkykenmt tkykenmt temporarily deployed to ml-commons-cicd-env-require-approval December 26, 2024 18:09 — with GitHub Actions Inactive
Copy link
Contributor

@brianf-aws brianf-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think everything looks good just that one part where you keep mentioning SageMaker since you are using bedrock models

```
### 2.2 Create a reranking pipeline
```json
PUT /_search/pipeline/rerank_pipeline_sagemaker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is written for Sagemaker here but the models are hosted on bedrock. Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed at a219218

```
### 2.2 Create a reranking pipeline
```json
PUT /_search/pipeline/rerank_pipeline_sagemaker
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here for the name and description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed at a219218


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to change it where you write SageMaker too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed at a219218

@tkykenmt tkykenmt had a problem deploying to ml-commons-cicd-env-require-approval December 27, 2024 02:45 — with GitHub Actions Failure
@tkykenmt tkykenmt temporarily deployed to ml-commons-cicd-env-require-approval December 27, 2024 02:45 — with GitHub Actions Inactive
@tkykenmt tkykenmt temporarily deployed to ml-commons-cicd-env-require-approval December 27, 2024 16:54 — with GitHub Actions Inactive
}
```

Each item in the array comprises a `query_text` and a `text_docs` string, separated by a ` , `.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this to line 295, query_text and a text_docs string exist in the example of

POST _plugins/_ml/_predict/text_similarity/your_model_id

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. Please let me delete this note because it's bit inaccurate. Deleted comment on commit 0a549fb

```

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.
Copy link
Collaborator

@ylwu-amzn ylwu-amzn Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. Modified at commit 0a549fb

@tkykenmt tkykenmt requested a deployment to ml-commons-cicd-env-require-approval December 29, 2024 14:28 — with GitHub Actions Waiting
@tkykenmt tkykenmt requested a deployment to ml-commons-cicd-env-require-approval December 29, 2024 14:28 — with GitHub Actions Waiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Tutorial for cross-encoder models on Amazon Bedrock
6 participants