From 710b9f1e2c7934baca5d83299538cf88a2cb6f3f Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 30 Sep 2026 17:29:59 +0200 Subject: [PATCH] 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 --- backend/open_webui/retrieval/vector/dbs/weaviate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/retrieval/vector/dbs/weaviate.py b/backend/open_webui/retrieval/vector/dbs/weaviate.py index 6d398d4ced..8ccb159721 100644 --- a/backend/open_webui/retrieval/vector/dbs/weaviate.py +++ b/backend/open_webui/retrieval/vector/dbs/weaviate.py @@ -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]