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.
- Cluster privileges:
manage_ml
Path Parameters
-
model_idstring Idrequired -
The unique identifier of the trained model.
Query Parameters
-
defer_definition_decompressionboolean · default: false If set to
trueand acompressed_definitionis provided, the request defers definition decompression and skips relevant validations.-
wait_for_completionboolean · default: false Whether to wait for all child operations (e.g. model download) to complete.
Request
-
compressed_definitionstring -
The compressed (GZipped and Base64 encoded) inference definition of the model. If compressed_definition is specified, then definition cannot be specified.
-
definitionDefinition -
The inference definition for the model. If definition is specified, then compressed_definition cannot be specified.
-
preprocessorsPreprocessor -
Collection of preprocessors
-
frequency_encodingFrequencyEncodingPreprocessor -
fieldstringrequired -
feature_namestringrequired -
frequency_mapmap string to numberrequired -
one_hot_encodingOneHotEncodingPreprocessor -
target_mean_encodingTargetMeanEncodingPreprocessor -
fieldstringrequired -
feature_namestringrequired -
target_mapmap string to numberrequired -
default_valuenumberrequired -
trained_modelTrainedModelrequired -
The definition of the trained model.
-
treeTrainedModelTree -
The definition for a binary decision tree.
-
classification_labelsstring -
feature_namesstringrequired -
target_typestring -
tree_structureTrainedModelTreeNoderequired -
decision_typestring -
default_leftboolean -
leaf_valuenumber -
left_childnumber -
node_indexnumberrequired -
right_childnumber -
split_featurenumber -
split_gainnumber -
thresholdnumber -
tree_nodeTrainedModelTreeNode -
The definition of a node in a tree. There are two major types of nodes: leaf nodes and not-leaf nodes.
- Leaf nodes only need node_index and leaf_value defined.
- All other nodes need split_feature, left_child, right_child, threshold, decision_type, and default_left defined.
-
decision_typestring -
default_leftboolean -
leaf_valuenumber -
left_childnumber -
node_indexnumberrequired -
right_childnumber -
split_featurenumber -
split_gainnumber -
thresholdnumber -
ensembleEnsemble -
The definition for an ensemble model
-
aggregate_outputAggregateOutput -
logistic_regressionWeights -
weightsnumberrequired -
weighted_sumWeights -
weightsnumberrequired -
weighted_modeWeights -
weightsnumberrequired -
classification_labelsstring -
feature_namesstring -
target_typestring -
trained_modelsTrainedModelrequired -
descriptionstring -
A human-readable description of the inference trained model.
-
inference_configInferenceConfigCreateContainer -
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.
-
regressionRegressionInferenceOptions -
Regression configuration for inference.
-
results_fieldstring Field -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
num_top_feature_importance_valuesnumber · default: 0 -
Specifies the maximum number of feature importance values per document.
-
classificationClassificationInferenceOptions -
Classification configuration for inference.
-
num_top_classesnumber -
Specifies the number of top class predictions to return. Defaults to 0.
-
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.
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
top_classes_results_fieldstring -
Specifies the field to which the top classes are written. Defaults to top_classes.
-
text_classificationTextClassificationInferenceOptions -
Text classification configuration for inference.
-
num_top_classesnumber -
Specifies the number of top class predictions to return. Defaults to 0.
-
tokenizationTokenizationConfigContainer -
The tokenization options
-
bertNlpBertTokenizationConfig -
Indicates BERT tokenization and its options
-
do_lower_caseboolean · default: false -
Should the tokenizer lower case the text
-
max_sequence_lengthnumber · default: 512 -
Maximum input sequence length for the model
-
spannumber · default: -1 -
Tokenization spanning options. Special value of -1 indicates no spanning takes place
-
truncateTokenizationTruncate · default: first -
Should tokenization input be automatically truncated before sending to the model for inference
-
Values:
firstsecondnone -
with_special_tokensboolean · default: true -
Is tokenization completed with special tokens
-
bert_jaNlpBertTokenizationConfig -
Indicates BERT Japanese tokenization and its options
-
do_lower_caseboolean · default: false -
Should the tokenizer lower case the text
-
max_sequence_lengthnumber · default: 512 -
Maximum input sequence length for the model
-
spannumber · default: -1 -
Tokenization spanning options. Special value of -1 indicates no spanning takes place
-
truncateTokenizationTruncate · default: first -
Should tokenization input be automatically truncated before sending to the model for inference
-
Values:
firstsecondnone -
with_special_tokensboolean · default: true -
Is tokenization completed with special tokens
-
mpnetNlpBertTokenizationConfig -
Indicates MPNET tokenization and its options
-
do_lower_caseboolean · default: false -
Should the tokenizer lower case the text
-
max_sequence_lengthnumber · default: 512 -
Maximum input sequence length for the model
-
spannumber · default: -1 -
Tokenization spanning options. Special value of -1 indicates no spanning takes place
-
truncateTokenizationTruncate · default: first -
Should tokenization input be automatically truncated before sending to the model for inference
-
Values:
firstsecondnone -
with_special_tokensboolean · default: true -
Is tokenization completed with special tokens
-
robertaNlpRobertaTokenizationConfig -
Indicates RoBERTa tokenization and its options
-
do_lower_caseboolean · default: false -
Should the tokenizer lower case the text
-
max_sequence_lengthnumber · default: 512 -
Maximum input sequence length for the model
-
spannumber · default: -1 -
Tokenization spanning options. Special value of -1 indicates no spanning takes place
-
truncateTokenizationTruncate · default: first -
Should tokenization input be automatically truncated before sending to the model for inference
-
Values:
firstsecondnone -
with_special_tokensboolean · default: true -
Is tokenization completed with special tokens
-
add_prefix_spaceboolean · default: false -
Should the tokenizer prefix input with a space character
-
xlm_robertaXlmRobertaTokenizationConfig -
do_lower_caseboolean · default: false -
Should the tokenizer lower case the text
-
max_sequence_lengthnumber · default: 512 -
Maximum input sequence length for the model
-
spannumber · default: -1 -
Tokenization spanning options. Special value of -1 indicates no spanning takes place
-
truncateTokenizationTruncate · default: first -
Should tokenization input be automatically truncated before sending to the model for inference
-
Values:
firstsecondnone -
with_special_tokensboolean · default: true -
Is tokenization completed with special tokens
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
classification_labelsstring -
Classification labels to apply other than the stored labels. Must have the same deminsions as the default configured labels
-
vocabularyVocabulary -
indexstring IndexNamerequired -
zero_shot_classificationZeroShotClassificationInferenceOptions -
Zeroshot classification configuration for inference.
-
tokenizationTokenizationConfigContainer -
The tokenization options to update when inferring
-
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
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
multi_labelboolean · default: false -
Indicates if more than one true label exists.
-
labelsstring -
The labels to predict.
-
fill_maskFillMaskInferenceOptions -
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.
-
num_top_classesnumber -
Specifies the number of top class predictions to return. Defaults to 0.
-
tokenizationTokenizationConfigContainer -
The tokenization options to update when inferring
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
vocabularyVocabulary -
indexstring IndexNamerequired -
learning_to_rankLearningToRankConfig -
default_paramsmap string to object -
feature_extractorsstring to FeatureExtractor -
num_top_feature_importance_valuesnumberrequired -
nerNerInferenceOptions -
Named entity recognition configuration for inference.
-
tokenizationTokenizationConfigContainer -
The tokenization options
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
classification_labelsstring -
The token classification labels. Must be IOB formatted tags
-
vocabularyVocabulary -
indexstring IndexNamerequired -
pass_throughPassThroughInferenceOptions -
Pass through configuration for inference.
-
tokenizationTokenizationConfigContainer -
The tokenization options
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
vocabularyVocabulary -
indexstring IndexNamerequired -
text_embeddingTextEmbeddingInferenceOptions -
Text embedding configuration for inference.
-
embedding_sizenumber -
The number of dimensions in the embedding output
-
tokenizationTokenizationConfigContainer -
The tokenization options
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
vocabularyVocabulary -
indexstring IndexNamerequired -
text_expansionTextExpansionInferenceOptions -
Text expansion configuration for inference.
-
tokenizationTokenizationConfigContainer -
The tokenization options
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
vocabularyVocabulary -
indexstring IndexNamerequired -
question_answeringQuestionAnsweringInferenceOptions -
Question answering configuration for inference.
-
num_top_classesnumber -
Specifies the number of top class predictions to return. Defaults to 0.
-
tokenizationTokenizationConfigContainer -
The tokenization options to update when inferring
-
results_fieldstring -
The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.
-
max_answer_lengthnumber -
The maximum answer length to consider
-
metadataobject -
An object map that contains metadata about the model.
-
model_typeTrainedModelType · 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-x86_64,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.
-
prefix_stringsTrainedModelPrefixStrings -
Optional prefix strings applied at inference
Response
-
model_idstring Idrequired -
Identifier for the trained model.
-
model_typeTrainedModelType -
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.
-
versionstring -
The Elasticsearch version number in which the trained model was created.
-
compressed_definitionstring -
created_bystring -
Information on the creator of the trained model.
-
create_timeDateTime -
The time when the trained model was created.
-
default_field_mapmap string to string -
Any field map described in the inference configuration takes precedence.
-
descriptionstring -
The free-text description of the trained model.
-
estimated_heap_memory_usage_bytesnumber -
The estimated heap usage in bytes to keep the trained model in memory.
-
estimated_operationsnumber -
The estimated number of operations to use the trained model.
-
fully_definedboolean -
True if the full model definition is present.
-
inference_configInferenceConfigCreateContainer -
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.
-
inputTrainedModelConfigInputrequired -
The input field names for the model definition.
-
field_namesstring Fieldrequired -
An array of input field names for the model.
-
license_levelstring -
The license level of the trained model.
-
metadataTrainedModelConfigMetadata -
An object containing metadata about the trained model. For example, models created by data frame analytics contain analysis_config and input objects.
-
model_aliasesstring -
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.
-
hyperparametersHyperparameter -
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.
-
namestring Namerequired -
Name of the hyperparameter.
-
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.
-
suppliedbooleanrequired -
Indicates if the hyperparameter is specified by the user (true) or optimized (false).
-
valuenumberrequired -
The value of the hyperparameter, either optimized or specified by the user.
-
total_feature_importanceTotalFeatureImportance -
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.
-
feature_namestring Namerequired -
The feature for which this importance was calculated.
-
importanceTotalFeatureImportanceStatisticsrequired -
A collection of feature importance statistics related to the training data set for this particular feature.
-
mean_magnitudenumberrequired -
The average magnitude of this feature across all the training data. This value is the average of the absolute values of the importance for this feature.
-
maxnumberrequired -
The maximum importance value across all the training data for this feature.
-
minnumberrequired -
The minimum importance value across all the training data for this feature.
-
classesTotalFeatureImportanceClassrequired -
If the trained model is a classification model, feature importance statistics are gathered per target class value.
-
class_namestring Namerequired -
The target class value. Could be a string, boolean, or number.
-
importanceTotalFeatureImportanceStatisticsrequired -
A collection of feature importance statistics related to the training data set for this particular feature.
-
mean_magnitudenumberrequired -
The average magnitude of this feature across all the training data. This value is the average of the absolute values of the importance for this feature.
-
maxnumberrequired -
The maximum importance value across all the training data for this feature.
-
minnumberrequired -
The minimum importance value across all the training data for this feature.
-
model_size_bytesnumber | string ByteSize -
model_packageModelPackageConfig -
create_timeEpochTimeUnitMillis -
descriptionstring -
inference_configmap string to object -
metadataMetadata -
minimum_versionstring -
model_repositorystring -
model_typestring -
packaged_model_idstring Idrequired -
platform_architecturestring -
prefix_stringsTrainedModelPrefixStrings -
sizenumber | string ByteSize -
sha256string -
vocabulary_filestring -
locationTrainedModelLocation -
platform_architecturestring -
prefix_stringsTrainedModelPrefixStrings