forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Procedure to run: 1. use external scipy/scikit-learn kmeans algorithm on your data 2. compute centroids and save them into a file "centroids.txt" as a numpy array in a binary form (use numpy array "tofile" function) 3. also compute labels for all points (what centroids them belong to) and save into a file 4. put centroids.txt file inside elasticsearch/x-pack/plugin/vectors/src/main/resources and build elasticsearch from it and use this build for test 5. from any client create index: { "mappings": { "dynamic": "false", "properties": { "vector": { "type": "dense_vector", "dims": 128 } } } } 6. index your vectors from any client using labels file computed in step 3 { "vector": { "centroid" : 39, "value": [0.12, 22.01, ...] } } 7. find closes points based on ann query { "query": { "script_score": { "query": { "ann": { "field": "vector", "number_of_probes": 3, "query_vector": [3.4, 10.12, ...] } }, "script": { "source": "1 / (1 + l2norm(params.query_vector, doc['vector']))", "params": { "query_vector": [3.4, 10.12, ...] } } } } } Relates to elastic#42326
- Loading branch information
1 parent
e8dac62
commit 2da0a93
Showing
5 changed files
with
311 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.