Skip to content

Commit 6e1dc7b

Browse files
committed
fix: add integration tests for both retrievers and change py.typed placement
1 parent fed38b0 commit 6e1dc7b

3 files changed

Lines changed: 571 additions & 5 deletions

File tree

integrations/falkordb/src/haystack_integrations/components/retrievers/falkordb/py.typed renamed to integrations/falkordb/src/haystack_integrations/components/retrievers/py.typed

File renamed without changes.

integrations/falkordb/src/haystack_integrations/document_stores/falkordb/document_store.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,9 @@ def _embedding_retrieval(
432432
Uses `CALL db.idx.vector.queryNodes` — FalkorDB's OpenCypher extension for
433433
ANN search. **No APOC is required.**
434434
435-
Cosine scores are returned in `[-1, 1]`; when `scale_score=True` they are
435+
Cosine scores are returned as distance in `[0, 2]`; when `scale_score=True` they are
436436
scaled to `[0, 1]` using the formula:
437-
`(score + 1) / 2`. Euclidean scores are transformed with a sigmoid.
437+
`1 - (score / 2)`. Euclidean scores are transformed with `1 / (1 + score)`.
438438
439439
:param query_embedding: Query vector as a plain Python list of floats.
440440
:param top_k: Maximum number of results to return.
@@ -452,7 +452,7 @@ def _embedding_retrieval(
452452
YIELD node AS d, score
453453
WHERE {where_clause}
454454
RETURN d, score
455-
ORDER BY score ASC
455+
ORDER BY score ASC, d.id ASC
456456
"""
457457
params: dict[str, Any] = {
458458
"top_k": top_k,
@@ -507,7 +507,7 @@ def _cypher_retrieval(
507507

508508
def _scale_to_unit_interval(self, score: float) -> float:
509509
"""
510-
Scale a raw similarity score to the unit interval `[0, 2]`.
510+
Scale a raw similarity score to the unit interval `[0, 1]`.
511511
512512
Uses the following formulas:
513513
- Cosine: `1 - (score / 2)`

0 commit comments

Comments
 (0)