-
Notifications
You must be signed in to change notification settings - Fork 138
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
Tutorial for using Asymmetric models #3258
base: main
Are you sure you want to change the base?
Conversation
After replicating the local model embeddings. I am able to provide a high level solution of what the tutorial entails. Signed-off-by: Brian Flores <[email protected]>
Provides more context to each step Signed-off-by: Brian Flores <[email protected]>
Expands on the context of the previous commit and improvements in grammar and structure Signed-off-by: Brian Flores <[email protected]>
Signed-off-by: Brian Flores <[email protected]>
There is a flaky test in the CI, can I get a retry please? :
|
|
||
## Step 1: Spin Up a Docker OpenSearch Cluster | ||
|
||
To run OpenSearch in a local development environment, you can use Docker and a pre-configured `docker-compose` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a requirement? I think the step 2-6 can also be done if you run an OpenSearch cluster locally without a docker?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats true, I chose a docker setup since there aren't many tutorials using it. Also its better with creating the tutorial with not having to register and deploy it again when I go back to use docker.
can you please add the configuring the knn index using ml inference ingest processors, and also search using ml inference request processors? So we can give the full tutorials about how to use this model during ingest and search |
|
||
### b. Zip the Model Files | ||
|
||
In order to upload the model to OpenSearch, you must zip the necessary model files (`model.onnx`, `sentencepiece.bpe.model`, and `tokenizer.json`). The `model.onnx` file is located in the `onnx` directory of the cloned repository. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the onnx the only format that this model provided? Can we add pytorch format tutorial here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Zane! I can see why you ask Ill clarify that this is only for onnx, I havent used pytorch models so thats I wrote it like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, my suggestion is we can add both onnx and pytorch cases so that user can choose between them based on their cases.
Signed-off-by: Brian Flores <[email protected]>
In order for this tutorial for all users following it, the following PR has to be merged to avoid the MLInput being null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some suggestions to clarify the text. In general, use sentence case capitalization and refer to the user as "you". Thanks!
@@ -0,0 +1,539 @@ | |||
# Tutorial: Running Asymmetric Semnantic Search within OpenSearch | |||
|
|||
This tutorial demonstrates how to generate text embeddings using an asymmetric embedding model in OpenSearch which will be used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This tutorial demonstrates how to generate text embeddings using an asymmetric embedding model in OpenSearch which will be used | |
This tutorial demonstrates generating text embeddings using an asymmetric embedding model in OpenSearch. The embeddings will be used |
# Tutorial: Running Asymmetric Semnantic Search within OpenSearch | ||
|
||
This tutorial demonstrates how to generate text embeddings using an asymmetric embedding model in OpenSearch which will be used | ||
to run semantic search. This is implemented within a Docker container, the example model used in this tutorial is the multilingual |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you replace "this" with a noun? Is it the search that is implemented within a Docker container?
to run semantic search. This is implemented within a Docker container, the example model used in this tutorial is the multilingual | |
to run semantic search, implemented within a Docker container. The example model used in this tutorial is the multilingual |
This tutorial demonstrates how to generate text embeddings using an asymmetric embedding model in OpenSearch which will be used | ||
to run semantic search. This is implemented within a Docker container, the example model used in this tutorial is the multilingual | ||
`intfloat/multilingual-e5-small` model from Hugging Face. | ||
You will learn how to prepare the model, register it in OpenSearch, and run inference to generate embeddings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You will learn how to prepare the model, register it in OpenSearch, and run inference to generate embeddings. | |
In this tutorial, you'll learn how to prepare the model, register it in OpenSearch, and run inference to generate embeddings. |
|
||
- Docker Desktop installed and running on your local machine. | ||
- Basic familiarity with Docker and OpenSearch. | ||
- Access to the Hugging Face model `intfloat/multilingual-e5-small` (or another model of your choice). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Access to the Hugging Face model `intfloat/multilingual-e5-small` (or another model of your choice). | |
- Access to the Hugging Face `intfloat/multilingual-e5-small` model (or another model of your choice). |
- Access to the Hugging Face model `intfloat/multilingual-e5-small` (or another model of your choice). | ||
--- | ||
|
||
## Step 1: Spin Up a Docker OpenSearch Cluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Step 1: Spin Up a Docker OpenSearch Cluster | |
## Step 1: Spin up a Docker OpenSearch cluster |
``` | ||
|
||
### 2.4 Test ingest data | ||
Perform bulk ingestion, this will now trigger the ingest pipeline to have embeddings for each document. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perform bulk ingestion, this will now trigger the ingest pipeline to have embeddings for each document. | |
When you perform bulk ingestion, the ingest pipeline will generate embeddings for each document: |
|
||
## 3. Run Semantic Search | ||
|
||
### 3.1 Create the Search Pipeline |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
### 3.1 Create the Search Pipeline | |
### 3.1 Create a search pipeline |
## 3. Run Semantic Search | ||
|
||
### 3.1 Create the Search Pipeline | ||
Create the search pipeline which will convert your query into a embedding and run KNN on the index to return the best documents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create the search pipeline which will convert your query into a embedding and run KNN on the index to return the best documents. | |
Create a search pipeline that will convert your query into a embedding and run a k-NN search on the index to return the best-matching documents: |
``` | ||
|
||
### 3.1 Run Semantic Search | ||
In this scenario we are going to see the top 3 results, when asking about sporting activities in New York City. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this scenario we are going to see the top 3 results, when asking about sporting activities in New York City. | |
Run a query about sporting activities in New York City: |
} | ||
``` | ||
|
||
Which yields the following |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which yields the following | |
The response contains the top 3 matching documents: |
Description
This PR implements the tutorial required for local asymmetric model embeddings. In this specific tutorial it is done using a docker container, to help users take advantage of multi node clusters using ML Nodes.
Related Issues
Resolves #3255
Check List
--signoff
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.