langchain-ai / langchain-weaviate

MIT License
34 stars 14 forks source link

Whether the simsimd library can be changed to optional configuration #208

Open oldpiao opened 2 months ago

oldpiao commented 2 months ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] simsimd cannot be installed properly on some older systems, and simsimd is not a necessary dependency in my opinion.

Describe the solution you'd like A clear and concise description of what you want to happen. After testing, I found that simsimd requires libc version 2.28+, and the centos version I use is only 2.17, and upgrading libc is too risky.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. After looking at the langchain-weaviate code, I see that the vector computation is only accelerated in _math.py, which appears on line 29. Z = 1 - np.array(simsimd.cdist(X, Y, metric="cosine"))

In fact, this can be changed to an optional configuration, rather than a necessary configuration, so that the package is not available because simsimd is not installed. For example:

try:
    import simsimd  # type: ignore
except ImportError:
    from scipy.spatial import distance as simsimd

Additional context Add any other context or screenshots about the feature request here.

hsm207 commented 2 months ago

I like this idea, just also add a logging message to inform user that simsimd lib is not found and will drop to numpy.

leaving this open for community contribution.