fix(layers): clamp similarity to [0,1] to avoid negative values
This commit is contained in:
committed by
Igor Lins e Silva
parent
eef053d750
commit
f2bed9284f
+1
-1
@@ -287,7 +287,7 @@ class Layer3:
|
|||||||
for i, (doc, meta, dist) in enumerate(zip(docs, metas, dists), 1):
|
for i, (doc, meta, dist) in enumerate(zip(docs, metas, dists), 1):
|
||||||
meta = meta or {}
|
meta = meta or {}
|
||||||
doc = doc or ""
|
doc = doc or ""
|
||||||
similarity = round(1 - dist, 3)
|
similarity = round(max(0.0, 1 - dist), 3)
|
||||||
wing_name = meta.get("wing", "?")
|
wing_name = meta.get("wing", "?")
|
||||||
room_name = meta.get("room", "?")
|
room_name = meta.get("room", "?")
|
||||||
source = Path(meta.get("source_file", "")).name if meta.get("source_file") else ""
|
source = Path(meta.get("source_file", "")).name if meta.get("source_file") else ""
|
||||||
|
|||||||
Reference in New Issue
Block a user