mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
Merge pull request #17049 from rgaricano/dev-FIX_lex-sem
FIX: Hybrid Search
This commit is contained in:
commit
719d115d49
2 changed files with 4 additions and 9 deletions
|
|
@ -128,8 +128,6 @@ def query_doc_with_hybrid_search(
|
||||||
log.warning(f"query_doc_with_hybrid_search:no_docs {collection_name}")
|
log.warning(f"query_doc_with_hybrid_search:no_docs {collection_name}")
|
||||||
return {"documents": [], "metadatas": [], "distances": []}
|
return {"documents": [], "metadatas": [], "distances": []}
|
||||||
|
|
||||||
# BM_25 required only if weight is greater than 0
|
|
||||||
if hybrid_bm25_weight > 0:
|
|
||||||
log.debug(f"query_doc_with_hybrid_search:doc {collection_name}")
|
log.debug(f"query_doc_with_hybrid_search:doc {collection_name}")
|
||||||
bm25_retriever = BM25Retriever.from_texts(
|
bm25_retriever = BM25Retriever.from_texts(
|
||||||
texts=collection_result.documents[0],
|
texts=collection_result.documents[0],
|
||||||
|
|
@ -343,8 +341,7 @@ def query_collection_with_hybrid_search(
|
||||||
# Fetch collection data once per collection sequentially
|
# Fetch collection data once per collection sequentially
|
||||||
# Avoid fetching the same data multiple times later
|
# Avoid fetching the same data multiple times later
|
||||||
collection_results = {}
|
collection_results = {}
|
||||||
# Only retrieve entire collection if bm_25 calculation is required
|
|
||||||
if hybrid_bm25_weight > 0:
|
|
||||||
for collection_name in collection_names:
|
for collection_name in collection_names:
|
||||||
try:
|
try:
|
||||||
log.debug(
|
log.debug(
|
||||||
|
|
@ -356,9 +353,7 @@ def query_collection_with_hybrid_search(
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception(f"Failed to fetch collection {collection_name}: {e}")
|
log.exception(f"Failed to fetch collection {collection_name}: {e}")
|
||||||
collection_results[collection_name] = None
|
collection_results[collection_name] = None
|
||||||
else:
|
|
||||||
for collection_name in collection_names:
|
|
||||||
collection_results[collection_name] = []
|
|
||||||
log.info(
|
log.info(
|
||||||
f"Starting hybrid search for {len(queries)} queries in {len(collection_names)} collections..."
|
f"Starting hybrid search for {len(queries)} queries in {len(collection_names)} collections..."
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1104,10 +1104,10 @@
|
||||||
<div class="py-0.5">
|
<div class="py-0.5">
|
||||||
<div class="flex w-full justify-between">
|
<div class="flex w-full justify-between">
|
||||||
<div class=" text-left text-xs font-small">
|
<div class=" text-left text-xs font-small">
|
||||||
{$i18n.t('lexical')}
|
{$i18n.t('semantic')}
|
||||||
</div>
|
</div>
|
||||||
<div class=" text-right text-xs font-small">
|
<div class=" text-right text-xs font-small">
|
||||||
{$i18n.t('semantic')}
|
{$i18n.t('lexical')}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue