-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Shared service for elastic curated models (#167000)
## Summary Adds a shared service for elastic curated models. The first use case is to provide a default/recommended ELSER version based on the hardware of the current cluster. #### Why? In 8.11 we'll provide a platform-specific version of the ELSER v2 alongside the portable one. At the moment several solutions refer to ELSER for download/inference purposes with a `.elser_model_1` constant. Starting 8.11 the model ID will vary, so using the `ElastcModels` service allows retrieving the recommended version of ELSER for the current cluster without any changes by solution teams in future releases. It is still possible to request an older version of the model if necessary. #### Implementation - Adds a new Kibana API endpoint `/trained_models/model_downloads` that provides a list of model definitions, with the `default` and `recommended` flags. - Adds a new Kibana API endpoint `/trained_models/elser_config` that provides an ELSER configuration based on the cluster architecture. - `getELSER` method is exposed from the plugin `setup` server-side as part of our shared services and plugin `start` client-side. ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
Showing
17 changed files
with
438 additions
and
77 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
23 changes: 23 additions & 0 deletions
23
x-pack/plugins/ml/public/application/services/elastic_models_service.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { ModelDefinitionResponse, GetElserOptions } from '@kbn/ml-trained-models-utils'; | ||
import { type TrainedModelsApiService } from './ml_api_service/trained_models'; | ||
|
||
export class ElasticModels { | ||
constructor(private readonly trainedModels: TrainedModelsApiService) {} | ||
|
||
/** | ||
* Provides an ELSER model name and configuration for download based on the current cluster architecture. | ||
* The current default version is 2. If running on Cloud it returns the Linux x86_64 optimized version. | ||
* If any of the ML nodes run a different OS rather than Linux, or the CPU architecture isn't x86_64, | ||
* a portable version of the model is returned. | ||
*/ | ||
public async getELSER(options?: GetElserOptions): Promise<ModelDefinitionResponse> { | ||
return await this.trainedModels.getElserConfig(options); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/ml/public/application/services/get_shared_ml_services.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { type HttpStart } from '@kbn/core-http-browser'; | ||
import { ElasticModels } from './elastic_models_service'; | ||
import { HttpService } from './http_service'; | ||
import { mlApiServicesProvider } from './ml_api_service'; | ||
|
||
export type MlSharedServices = ReturnType<typeof getMlSharedServices>; | ||
|
||
/** | ||
* Provides ML services exposed from the plugin start. | ||
*/ | ||
export function getMlSharedServices(httpStart: HttpStart) { | ||
const httpService = new HttpService(httpStart); | ||
const mlApiServices = mlApiServicesProvider(httpService); | ||
|
||
return { | ||
elasticModels: new ElasticModels(mlApiServices.trainedModels), | ||
}; | ||
} |
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
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.