Skip to content

Conversation

@sigfawn
Copy link

@sigfawn sigfawn commented Jan 2, 2026

This PR fixes a similarity calculation bug in RuVectorBackend.ts.

1. IP Metric Normalization

  • Problem: The ip (Inner Product) metric was returning raw negative distances as "similarity". This resulted in unbounded values, violating the VectorBackend interface contract (which requires 0-1 normalized similarity) and causing thresholding logic to fail.
  • Fix: Updated distanceToSimilarity() to use a Sigmoid function (1 / (1 + exp(-distance))) for the ip metric.

Result: All vector backends (RuVector and HNSWLib) now return consistent, normalized similarity scores across all distance metrics.

@sigfawn sigfawn closed this by deleting the head repository Jan 11, 2026
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.

1 participant