From 5e493da85953db2f033b930408602fd8cf30cc49 Mon Sep 17 00:00:00 2001 From: Josh Hawkins <32435876+hawkeye217@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:04:33 -0500 Subject: [PATCH] Use sigmoid function for normalization for multi modal searches only --- web/src/views/search/SearchView.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/web/src/views/search/SearchView.tsx b/web/src/views/search/SearchView.tsx index 203942083..de1da0746 100644 --- a/web/src/views/search/SearchView.tsx +++ b/web/src/views/search/SearchView.tsx @@ -187,13 +187,23 @@ export default function SearchView({ } }, [searchResults, searchDetail]); - // confidence score - probably needs tweaking + // confidence score const zScoreToConfidence = (score: number) => { - // Sigmoid function: 1 / (1 + e^x) - const confidence = 1 / (1 + Math.exp(score)); + // Normalizing is needed for multi-modal searches only + // Sigmoid function for normalized: 1 / (1 + e^x) + // Cosine for non-normalized + if (searchFilter) { + const normalized = + !searchFilter.search_type || + (Array.isArray(searchFilter.search_type) && + searchFilter.search_type.length === 2 && + searchFilter.search_type.includes("thumbnail") && + searchFilter.search_type.includes("description")); + const confidence = normalized ? 1 / (1 + Math.exp(score)) : 1 - score; - return Math.round(confidence * 100); + return Math.round(confidence * 100); + } }; const hasExistingSearch = useMemo(