Skip to content
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

feat: cosine_similarity function #2680

Merged
merged 12 commits into from
Feb 22, 2024
Merged

Conversation

universalmind303
Copy link
Contributor

adds new function cosine_similarity for comparing similarity across floating point vectors. cosine_similarity is commonly used in vector search workloads.

Copy link
Contributor

@greyscaled greyscaled left a comment

Choose a reason for hiding this comment

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

I tried it out, and it worked nicely.

I don't fully understand why two equivalent vectors gives me 5.9604645e-8 instead of 0.0 (as shown in the tests), but I understand that this is upstream behaviour and I lack some prior art/experience.

@universalmind303
Copy link
Contributor Author

I tried it out, and it worked nicely.

I don't fully understand why two equivalent vectors gives me 5.9604645e-8 instead of 0.0 (as shown in the tests), but I understand that this is upstream behaviour and I lack some prior art/experience.

yeah i think this is just a math/precision thing when performing similarity. 0.000000059604645 is practically 0.0

@universalmind303
Copy link
Contributor Author

@tychoish the CI seems to keep getting stuck on build cache. I don't think this is related to this PR at all.

https://github.com/GlareDB/glaredb/actions/runs/8008291239/job/21874514119?pr=2680

@universalmind303 universalmind303 enabled auto-merge (squash) February 22, 2024 17:45
@universalmind303 universalmind303 merged commit 1ab8eb0 into main Feb 22, 2024
25 checks passed
@universalmind303 universalmind303 deleted the universalmind303/cosine branch February 22, 2024 17:57
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.

None yet

3 participants