Skip to content

fix(stores): Stores fixes and testing #4663

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 22, 2025
Merged

Conversation

richiejp
Copy link
Collaborator

@richiejp richiejp commented Jan 22, 2025

  • fix(stores): Actually check a vector is a unit vector/normalized
  • fix(stores): Add tests for known results and triangle inequality

Description

I'm trying to find fault with the builtin vector store implementation instead of finishing #2065.

I have added some tests and not found any issues yet with the vector distance comparison.
It behaves as expected in the mathematical tests I added. I did find one bug, but that
would have only effected performance.

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Copy link

netlify bot commented Jan 22, 2025

Deploy Preview for localai ready!

Name Link
🔨 Latest commit 882aa3c
🔍 Latest deploy log https://app.netlify.com/sites/localai/deploys/6790da74db98830008b4896c
😎 Deploy Preview https://deploy-preview-4663--localai.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Instead of just summing the components to see if they equal 1.0, take
the actual magnitude/p-norm of the vector and check that is
approximately 1.0.

Note that this shouldn't change the order of results except in edge
cases if I am too lax with the precision of the equality
comparison. However it should improve performance for normalized
vectors which were being misclassified.

Signed-off-by: Richard Palethorpe <[email protected]>
This adds some more tests to check the cosine similarity function has
some expected mathematical properties.

Signed-off-by: Richard Palethorpe <[email protected]>
@richiejp richiejp changed the title Stores fixes and testing fix(stores): Stores fixes and testing Jan 22, 2025
@richiejp richiejp mentioned this pull request Jan 22, 2025
1 task
Copy link
Owner

@mudler mudler 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 for having a look - I will give a run at this soon !

@mudler mudler merged commit e8eb0b2 into mudler:master Jan 22, 2025
27 of 28 checks passed
@mudler mudler added the bug Something isn't working label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants