mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-05 02:41:34 +00:00
fix: exact matches score as the worst result on Weaviate (#31531)
With Weaviate as the vector database, a chunk identical to the query (distance 0) was treated as having no distance and got a relevance score of 0. Perfect matches could land at the bottom of the results or fall below the relevance threshold. They now score 1 as expected. Fixes #31527
This commit is contained in:
parent
52533c5675
commit
710b9f1e2c
1 changed files with 1 additions and 1 deletions
|
|
@ -212,7 +212,7 @@ class WeaviateClient(VectorDBBase):
|
|||
|
||||
# Weaviate has cosine distance, 2 (worst) -> 0 (best). Re-ordering to 0 -> 1
|
||||
raw_distances = [
|
||||
(obj.metadata.distance if obj.metadata and obj.metadata.distance else 2.0)
|
||||
(obj.metadata.distance if obj.metadata and obj.metadata.distance is not None else 2.0)
|
||||
for obj in response.objects
|
||||
]
|
||||
distances = [(2 - dist) / 2 for dist in raw_distances]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue