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

Optimize Cosine Distance Calculation Using Float32Array for Improved Performance #4593

Open
cloudcreatr opened this issue Jan 29, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@cloudcreatr
Copy link

Feature Description

i want to create a pr to introduces an optimized implementation of the cosineDistance function to efficiently compute the cosine distance between two vectors. The key improvements include:

Performance Optimization: Uses Float32Array to enhance memory efficiency and speed, especially beneficial for large vector computations.
Single-Pass Calculation: Computes dot product and vector magnitudes in a single loop, reducing computational overhead (O(n) complexity).
Zero Vector Handling: Ensures robustness by returning a distance of 1 when either vector is zero (to avoid division by zero).

Use Cases

No response

Additional context

No response

@cloudcreatr cloudcreatr added the enhancement New feature or request label Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant