Create a trained model
- PUT /_ml/trained_models/{model_id}
Enable you to supply a trained model that is not created by data frame analytics.
Required authorization
- Cluster privileges manage_ml
Request body
-
compressed_definitionstring -
The compressed (GZipped and Base64 encoded) inference definition of the model. If compressed_definition is specified, then definition cannot be specified.
-
definitionobject -
The inference definition for the model. If definition is specified, then compressed_definition cannot be specified.
-
trained_modelobjectrequired -
The definition of the trained model.
-
inference_configobject -
The default configuration for inference. This can be either a regression or classification configuration. It must match the underlying definition.trained_model's target_type. For pre-packaged models such as ELSER the config is not required.
-
classificationobject -
Classification configuration for inference.
-
num_top_feature_importance_valuesnumber · default: 0 -
Specifies the maximum number of feature importance values per document.
-
prediction_field_typestring -
Specifies the type of the predicted field to write. Acceptable values are: string, number, boolean. When boolean is provided 1.0 is transformed to true and 0.0 to false.
-
text_classificationobject -
Text classification configuration for inference.
-
zero_shot_classificationobject -
Zeroshot classification configuration for inference.
-
hypothesis_templatestring · default: "This example is {}." -
Hypothesis template used when tokenizing labels for prediction
-
classification_labelsstringrequired -
The zero shot classification labels indicating entailment, neutral, and contradiction Must contain exactly and only entailment, neutral, and contradiction
-
fill_maskobject -
Fill mask configuration for inference.
-
mask_tokenstring -
The string/token which will be removed from incoming documents and replaced with the inference prediction(s). In a response, this field contains the mask token for the specified model/tokenizer. Each model and tokenizer has a predefined mask token which cannot be changed. Thus, it is recommended not to set this value in requests. However, if this field is present in a request, its value must match the predefined value for that model/tokenizer, otherwise the request will fail.
-
model_type· default: tree_ensemble -
The model type.
Supported values include:
tree_ensemble: The model definition is an ensemble model of decision trees.lang_ident: A special type reserved for language identification models.pytorch: The stored definition is a PyTorch (specifically a TorchScript) model. Currently only NLP models are supported.
-
Values:
tree_ensemblelang_identpytorch -
model_size_bytesnumber -
The estimated memory usage in bytes to keep the trained model in memory. This property is supported only if defer_definition_decompression is true or the model definition is not supplied.
-
platform_architecturestring -
The platform architecture (if applicable) of the trained mode. If the model only works on one platform, because it is heavily optimized for a particular processor architecture and OS combination, then this field specifies which. The format of the string must match the platform identifiers used by Elasticsearch, so one of,
linux-x86_64,linux-aarch64,darwin-aarch64, orwindows-x86_64. For portable models (those that work independent of processor architecture or OS features), leave this field unset. -
An array of tags to organize the model.
Response
-
model_type -
The model type
Supported values include:
tree_ensemble: The model definition is an ensemble model of decision trees.lang_ident: A special type reserved for language identification models.pytorch: The stored definition is a PyTorch (specifically a TorchScript) model. Currently only NLP models are supported.
-
Values:
tree_ensemblelang_identpytorch -
A comma delimited string of tags. A trained model can have many tags, or none.
-
default_field_mapmap string to string -
Any field map described in the inference configuration takes precedence.
-
estimated_heap_memory_usage_bytesnumber -
The estimated heap usage in bytes to keep the trained model in memory.
-
inference_configobject -
The default configuration for inference. This can be either a regression, classification, or one of the many NLP focused configurations. It must match the underlying definition.trained_model's target_type. For pre-packaged models such as ELSER the config is not required.
-
metadataobject -
An object containing metadata about the trained model. For example, models created by data frame analytics contain analysis_config and input objects.
-
feature_importance_baselinemap string to string -
An object that contains the baseline for feature importance values. For regression analysis, it is a single value. For classification analysis, there is a value for each class.
-
hyperparametersobject -
List of the available hyperparameters optimized during the fine_parameter_tuning phase as well as specified by the user.
-
absolute_importancenumber -
A positive number showing how much the parameter influences the variation of the loss function. For hyperparameters with values that are not specified by the user but tuned during hyperparameter optimization.
-
relative_importancenumber -
A number between 0 and 1 showing the proportion of influence on the variation of the loss function among all tuned hyperparameters. For hyperparameters with values that are not specified by the user but tuned during hyperparameter optimization.
-
total_feature_importanceobject -
An array of the total feature importance for each feature used from the training data set. This array of objects is returned if data frame analytics trained the model and the request includes total_feature_importance in the include request parameter.