From 557a1df24773ba131680dffd334af4f982936b69 Mon Sep 17 00:00:00 2001 From: tkykenmt Date: Wed, 25 Dec 2024 17:20:15 +0900 Subject: [PATCH 1/2] fix post_process_function bug on sort results for rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md (#3247) Signed-off-by: tkykenmt --- ...erank-m3-v2_model_deployed_on_Sagemaker.md | 140 ++++++++++++++++-- 1 file changed, 126 insertions(+), 14 deletions(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md b/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md index 238f62300e..b215095c7b 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md @@ -59,10 +59,38 @@ result = predictor.predict(data={ ] }) -print(json.dumps(sorted(result, key=lambda x: x['index']), indent=2)) +print(json.dumps(result, indent=2)) ``` -The reranking results are as follows: +The reranking result is ordering by the highest score first: +``` +[ + { + "index": 2, + "score": 0.92879725 + }, + { + "index": 0, + "score": 0.013636836 + }, + { + "index": 1, + "score": 0.000593021 + }, + { + "index": 3, + "score": 0.00012148176 + } +] +``` + +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: ``` [ @@ -121,9 +149,51 @@ POST /_plugins/_ml/connectors/_create "headers": { "content-type": "application/json" }, - "request_body": "{ \"query\": \"${parameters.query}\", \"texts\": ${parameters.texts} }", - "pre_process_function": "\n def query_text = params.query_text;\n def text_docs = params.text_docs;\n def textDocsBuilder = new StringBuilder('[');\n for (int i=0; i Date: Fri, 3 Jan 2025 14:13:50 -0800 Subject: [PATCH 2/2] fix typo Signed-off-by: Yaliang Wu --- ...peline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md b/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md index b215095c7b..10b317da4a 100644 --- a/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md +++ b/docs/tutorials/rerank/rerank_pipeline_with_bge-rerank-m3-v2_model_deployed_on_Sagemaker.md @@ -87,7 +87,8 @@ The reranking result is ordering by the highest score first: You can sort the result by index number. ```python -print(json.dumps(sorted(results, key=lambda x: x['index']),indent=2)) +print(json.dumps(sorted(result, key=lambda x: x['index']),indent=2)) + ``` The results are as follows: