mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-27 15:49:23 -05: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:
1 parent
52533c5675
commit
710b9f1e2c
1 file changed
+1
-1
@@ -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]
|
||||
|
||||
Reference in new issue
Block a user