langchain-ai / langchain-weaviate

MIT License
35 stars 15 forks source link

Is there a way to use langchain-weaviate without simsimd package? #187

Closed taeil00 closed 2 months ago

taeil00 commented 6 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 [...]

-> My server cannot install simsimd through pypi.org as --index-url This is an error message: Could not find a version that satisfies the requirement simsimd<5.0.0,>=3.6.1 (from langchain-weaviate) (from versions: 1.1.2, 1.2.0, 1.3.0, 1.4.0) ERROR: No matching distribution found for simsimd<5.0.0,>=3.6.1.

Describe the solution you'd like A clear and concise description of what you want to happen.

-> I saw the sentence like "Fastest SIMD-Accelerated Vector Similarity Functions for x86 and Arm" in https://pypi.org/project/simsimd/. I think my server isn't x86 or Arm.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. -> Is there a way to use langchain-weaviate without simsimd package?

hsm207 commented 6 months ago

No, simsimd is there for performance reason.

Could you find out what is your server's architecture is and make a request at the simsimd project to ask for that architecture to be supported?

In the meantime, we could consider making this dependency optional and in the code, drop to a numpy implementation when the lib is not installed.

oldpiao commented 2 months ago

I had the same problem. I'm centos7.8

oldpiao commented 2 months ago

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. 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:
    import numpy as simsimd
hsm207 commented 2 months ago

@oldpiao thanks for looking into this and identifying the dependencies.

I'm going to close this in favour of https://github.com/langchain-ai/langchain-weaviate/issues/208