Skip to content

Conversation

ejrtks1020
Copy link
Contributor

@ejrtks1020 ejrtks1020 commented Jul 16, 2025

🐛 Fix: Normalize Milvus similarity scores for SimilarityThresholdRetriever

Summary

Added score normalization logic to Milvus vector store to ensure SimilarityThresholdRetriever works correctly across different metric types.

Changes

  • Added normalization logic for L2, IP, and COSINE metric types
  • L2 distances converted to similarity scores using 1/(1+distance)
  • IP and COSINE scores normalized from [-1,1] to [0,1] range

Problem Solved

  • SimilarityThresholdRetriever was not working properly with Milvus due to unnormalized scores
  • Different metric types returned scores in different ranges, causing inconsistent threshold filtering
  • Raw distance/similarity values were passed directly without proper normalization

Testing

  • Tested with L2, IP, and COSINE metric types
  • Verified SimilarityThresholdRetriever now works consistently across all metric types
  • Confirmed scores are properly normalized to 0-1 range

Files Modified

  • packages/components/nodes/vectorstores/Milvus/Milvus.ts

related issue #4879

Copy link
Contributor

@HenryHengZJ HenryHengZJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@HenryHengZJ HenryHengZJ merged commit 2605a1f into FlowiseAI:main Jul 18, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants