langchain icon indicating copy to clipboard operation
langchain copied to clipboard

Add SKLearnVectorStore

Open mrtj opened this issue 2 years ago • 1 comments

Add SKLearnVectorStore

This PR adds SKLearnVectorStore, a simply vector store based on NearestNeighbors implementations in the scikit-learn package. This provides a simple drop-in vector store implementation with minimal dependencies (scikit-learn is typically installed in a data scientist / ml engineer environment). The vector store can be persisted and loaded from json, bson and parquet format.

SKLearnVectorStore has soft (dynamic) dependency on the scikit-learn, numpy and pandas packages. Persisting to bson requires the bson package, persisting to parquet requires the pyarrow package.

Before submitting

Integration tests are provided under tests/integration_tests/vectorstores/test_sklearn.py

Sample usage notebook is provided under docs/modules/indexes/vectorstores/examples/sklear.ipynb

Who can review?

Community members can review the PR once tests pass. Tag maintainers/contributors who might be interested:

@hwchase17 - project lead

VectorStores / Retrievers / Memory @dev2049

mrtj avatar May 26 '23 16:05 mrtj

Thank you for the contribution @mrtj !

Code is looking great! One request is if you could move the test from integration to unit test.

Follow these guidelines -- https://github.com/hwchase17/langchain/blob/master/.github/CONTRIBUTING.md#working-with-optional-dependencies

This will allow the tests to be picked up on CI with an optional dependency

eyurtsev avatar May 26 '23 17:05 eyurtsev