-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Extend elastic_vector_search.py to allow for kNN indexing/searching #5346
Comments
Had this need today and did a crude version of it, let me know if this make sense - I can open a PR with it https://gist.github.com/ManZzup/1109d4c1f6b8bc48b60a67983dfbd0fd |
I'm almost done with adding a new I've been busy on a couple different projects but I'm hoping to have the pr sumbitted in the next day or two. Just debugging and cleaning up right now It you do take a look feel free to comment here if you have any suggestions |
@jeffvestal this looks much better and structured! Will wait for this to merge to use this instead. A couple of things,
|
# Create elastic_vector_search.ElasticKnnSearch class This extends `langchain/vectorstores/elastic_vector_search.py` by adding a new class `ElasticKnnSearch` Features: - Allow creating an index with the `dense_vector` mapping compataible with kNN search - Store embeddings in index for use with kNN search (correct mapping creates HNSW data structure) - Perform approximate kNN search - Perform hybrid BM25 (`query{}`) + kNN (`knn{}`) search - perform knn search by either providing a `query_vector` or passing a hosted `model_id` to use query_vector_builder to automatically generate a query_vector at search time Connection options - Using `cloud_id` from Elastic Cloud - Passing elasticsearch client object search options - query - k - query_vector - model_id - size - source - knn_boost (hybrid search) - query_boost (hybrid search) - fields This also adds examples to `docs/modules/indexes/vectorstores/examples/elasticsearch.ipynb` Fixes # [5346](#5346) cc: @dev2049 --> --------- Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
@ManZzup My PR was merged. I got most/all of the arg options you mentioned (I think) |
# Create elastic_vector_search.ElasticKnnSearch class This extends `langchain/vectorstores/elastic_vector_search.py` by adding a new class `ElasticKnnSearch` Features: - Allow creating an index with the `dense_vector` mapping compataible with kNN search - Store embeddings in index for use with kNN search (correct mapping creates HNSW data structure) - Perform approximate kNN search - Perform hybrid BM25 (`query{}`) + kNN (`knn{}`) search - perform knn search by either providing a `query_vector` or passing a hosted `model_id` to use query_vector_builder to automatically generate a query_vector at search time Connection options - Using `cloud_id` from Elastic Cloud - Passing elasticsearch client object search options - query - k - query_vector - model_id - size - source - knn_boost (hybrid search) - query_boost (hybrid search) - fields This also adds examples to `docs/modules/indexes/vectorstores/examples/elasticsearch.ipynb` Fixes # [5346](langchain-ai#5346) cc: @dev2049 --> --------- Co-authored-by: Dev 2049 <dev.dev2049@gmail.com>
Feature request
Extend
langchain/embeddings/elasticsearch.py
to support kNN indexing and searching.The high-level objectives will be:
Motivation
Elasticsearch support approximate k-nearest neighbor search with dense vectors. The current module only support script score / exact match vector search.
Your contribution
I will work on the code and create the pull request
The text was updated successfully, but these errors were encountered: