Skip to content
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

[ML] Automatically download the ELSER model when PUT in _inference #104334

Merged
merged 7 commits into from Jan 15, 2024

Conversation

maxhniebergall
Copy link
Member

Closes https://github.com/elastic/ml-team/issues/1098

Previously, to be able to use the ELSER model, there were two steps: 1. Put (download) ELSER using the trained models API; 2. Put the ELSER model using the _inference API.

With this change, these two steps are combined, so now to install ELSER in _inference, all one has to do is PUT the ELSER model using the _inference API.

For example,

curl -X PUT "localhost:9200/_inference/sparse_embedding/<model_id>" \
-H 'Content-Type: application/json' -u <user>:<password> \
-d'  
{
  "service": "elser",
  "service_settings": {
    "num_allocations": 1,
    "num_threads": 1
  },
  "task_settings": {}
}
'

@elasticsearchmachine elasticsearchmachine added the Team:ML Meta label for the ML team label Jan 12, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/ml-core (Team:ML)

@elasticsearchmachine
Copy link
Collaborator

Hi @maxhniebergall, I've created a changelog YAML for you.

* @param modelVariant The configuration of the model variant to be downloaded
* @param listener The listener
*/
default void putModel(Model modelVariant, ActionListener<Boolean> listener) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leverage the start method that's in this interface for downloading the model instead of adding a new one?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could use start, although I am unsure about the benefit. I suppose it would decrease the complexity of the interface, and it is a bit weird that startModel in TransportPutInferenceModelAction calls two methods in the InferenceService. However, I think that this also represents the underlying business logic (that start is both starting an inference model and putting a trained model definition). I think that creating a second method in the interface has the benefit of splitting up these two objectives into separate methods in the ElserMlNodeService (and other InferenceServices), which represent the two API calls we are making to support the business logic.

So, I can't really imagine why it would be better to avoid creating another method in this interface, but please let me know if I missed it!

var input = new TrainedModelInput(fieldNames);
var config = TrainedModelConfig.builder().setInput(input).setModelId(modelVariant).build();
PutTrainedModelAction.Request putRequest = new PutTrainedModelAction.Request(config, false, true);
executeAsyncWithOrigin(client, ML_ORIGIN, PutTrainedModelAction.INSTANCE, putRequest, listener.delegateFailure((l, r) -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I wonder if we should be using a new origin for inference instead of ML_ORIGIN 🤔 @davidkyle ? Or do we need this as ML_ORIGIN so it gets the permissions correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really consider using a different origin. I'll have to look into what the impact of the origin is. Thanks for pointing this out!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there is already an inference origin, so I switched to using that. Thanks @jonathan-buttner !

Copy link
Member

@davidkyle davidkyle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maxhniebergall maxhniebergall merged commit 6a4a22f into main Jan 15, 2024
16 checks passed
@maxhniebergall maxhniebergall deleted the _infDownloadElserOnPut branch January 15, 2024 15:06
jedrazb pushed a commit to jedrazb/elasticsearch that referenced this pull request Jan 17, 2024
…lastic#104334)

* Automatically download ELSER when PUT in _inference

* Revert "Disable elser download test case in inf IT (elastic#104271)"

* add IT

* disable IT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :ml Machine learning Team:ML Meta label for the ML team v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants