Create trained model definition part API

Create trained model definition part API

New API reference

For the most up-to-date API details, refer to Machine learning trained model APIs.

Creates part of a trained model definition.

Request

PUT _ml/trained_models/<model_id>/definition/<part_num>

Prerequisites

Requires the manage_ml cluster privilege. This privilege is included in the machine_learning_admin built-in role.

Path parameters

<model_id>

(Required, string) The unique identifier of the trained model.

<part>

(Required, number) The definition part number. When the definition is loaded for inference the definition parts will be streamed in order of their part_num. The first part must be 0 and the final part must be total_parts - 1.

Request body

definition

(Required, string) The definition part for the model. Must be a base64 encoded string.

total_definition_length

(Required, number) The total uncompressed definition length in bytes. Not base64 encoded.

total_parts

(Required, number) The total number of parts that will be uploaded. Must be greater than 0.

Examples

The following example creates a model definition part for a previously stored model configuration. The definition part is stored in the index that is configured by the location.index.name.

The value of the definition object is elided from the example as it is a very large base64 encoded string.

  1. resp = client.ml.put_trained_model_definition_part(
  2. model_id="elastic__distilbert-base-uncased-finetuned-conll03-english",
  3. part="0",
  4. definition="...",
  5. total_definition_length=265632637,
  6. total_parts=64,
  7. )
  8. print(resp)
  1. const response = await client.ml.putTrainedModelDefinitionPart({
  2. model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english",
  3. part: 0,
  4. definition: "...",
  5. total_definition_length: 265632637,
  6. total_parts: 64,
  7. });
  8. console.log(response);
  1. PUT _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/definition/0
  2. {
  3. "definition": "...",
  4. "total_definition_length": 265632637,
  5. "total_parts": 64
  6. }

The API returns the following results:

  1. {
  2. "acknowledged": true
  3. }