lplalbert commented on code in PR #412:
URL: https://github.com/apache/hugegraph-ai/pull/412#discussion_r4525956104
##########
hugegraph-llm/src/hugegraph_llm/indices/vector_index/qdrant_vector_store.py:
##########
@@ -127,15 +127,15 @@ def search(self, query_vector: List[float], top_k: int =
5, dis_threshold: float
for hit in search_result:
distance = 1.0 - hit.score
- if distance < dis_threshold:
+ if distance <= dis_threshold:
Review Comment:
Good catch - adopted in cc6d391: the Qdrant filter now compares `distance <=
dis_threshold + _DISTANCE_TOLERANCE` (`_DISTANCE_TOLERANCE = 1e-6`, named so
the reason is visible at the use site: cosine scores are float32, so an exact
match can round to 0.99999994 and compute a tiny positive distance instead of
0.0).
Scoped to Qdrant only - Faiss and Milvus return exact 0.0 for identical
inputs, so they keep the strict inclusive comparison.
Regression test `test_qdrant_threshold_tolerates_float32_score_noise` pins
both ends: a hit at score 0.99999994 survives `dis_threshold=0`, while hits at
distance 1e-5 (outside the tolerance) and 0.5 are still dropped.
Validation: `SKIP_EXTERNAL_SERVICES=true uv run pytest
hugegraph-llm/src/tests/indices/` -> 24 passed, 1 skipped (test fails without
the tolerance); ruff clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]