mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
Fix: Normalze all database distances to score in [0, 1]
This commit is contained in:
@@ -278,7 +278,9 @@ class PgvectorClient:
|
||||
for row in results:
|
||||
qid = int(row.qid)
|
||||
ids[qid].append(row.id)
|
||||
distances[qid].append(row.distance)
|
||||
# normalize and re-orders pgvec distance from [2, 0] to [0, 1] score range
|
||||
# https://github.com/pgvector/pgvector?tab=readme-ov-file#querying
|
||||
distances[qid].append((2.0 - row.distance)/2.0)
|
||||
documents[qid].append(row.text)
|
||||
metadatas[qid].append(row.vmetadata)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user