From 23c3e70b5b776059504da0024510b47c123c8d75 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 25 May 2023 16:46:19 +0000 Subject: [PATCH] [Doc] Fix cosinesimil OpenSearch Score and Distance Function formula (#4138) (#4139) Signed-off-by: Alireza Fatemi (cherry picked from commit 8d394f57264f2dd8f8fd9e999f7fa3f5a00f921b) Signed-off-by: github-actions[bot] --- _search-plugins/knn/approximate-knn.md | 2 +- _search-plugins/knn/knn-score-script.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_search-plugins/knn/approximate-knn.md b/_search-plugins/knn/approximate-knn.md index 5e0558f714..d57d164050 100644 --- a/_search-plugins/knn/approximate-knn.md +++ b/_search-plugins/knn/approximate-knn.md @@ -299,7 +299,7 @@ A space corresponds to the function used to measure the distance between two poi \[ d(\mathbf{x}, \mathbf{y}) = 1 - cos { \theta } = 1 - {\mathbf{x} · \mathbf{y} \over \|\mathbf{x}\| · \|\mathbf{y}\|}\]\[ = 1 - {\sum_{i=1}^n x_i y_i \over \sqrt{\sum_{i=1}^n x_i^2} · \sqrt{\sum_{i=1}^n y_i^2}}\] where \(\|\mathbf{x}\|\) and \(\|\mathbf{y}\|\) represent the norms of vectors x and y respectively. - nmslib and faiss:\[ score = {1 \over 1 + d } \]
Lucene:\[ score = {1 + d \over 2}\] + nmslib and faiss:\[ score = {1 \over 1 + d } \]
Lucene:\[ score = {2 - d \over 2}\] innerproduct (not supported for Lucene) diff --git a/_search-plugins/knn/knn-score-script.md b/_search-plugins/knn/knn-score-script.md index 268bc4cc3b..c8fa5ad595 100644 --- a/_search-plugins/knn/knn-score-script.md +++ b/_search-plugins/knn/knn-score-script.md @@ -306,10 +306,10 @@ A space corresponds to the function used to measure the distance between two poi cosinesimil - \[ d(\mathbf{x}, \mathbf{y}) = cos \theta = {\mathbf{x} · \mathbf{y} \over \|\mathbf{x}\| · \|\mathbf{y}\|}\]\[ = + \[ d(\mathbf{x}, \mathbf{y}) = 1 - cos { \theta } = 1 - {\mathbf{x} · \mathbf{y} \over \|\mathbf{x}\| · \|\mathbf{y}\|}\]\[ = 1 - {\sum_{i=1}^n x_i y_i \over \sqrt{\sum_{i=1}^n x_i^2} · \sqrt{\sum_{i=1}^n y_i^2}}\] - where \(\|\mathbf{x}\|\) and \(\|\mathbf{y}\|\) represent normalized vectors. - \[ score = 1 + d \] + where \(\|\mathbf{x}\|\) and \(\|\mathbf{y}\|\) represent the norms of vectors x and y respectively. + \[ score = 2 - d \] innerproduct (not supported for Lucene)