IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Infer trained model deployment API
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Infer trained model deployment API
editEvaluates a trained model.
This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
Request
editPOST _ml/trained_models/<model_id>/deployment/_infer
Path parameters
edit-
<model_id>
- (Required, string) The unique identifier of the trained model.
Query parameters
edit-
timeout
- (Optional, time) Controls the amount of time to wait for inference results. Defaults to 10 seconds.
Request body
edit-
docs
-
(Required, array)
An array of objects to pass to the model for inference. The objects should
contain a field matching your configured trained model input. Typically, the field
name is
text_field
. Currently, only a single value is allowed.
Examples
editThe response depends on the task the model is trained for. If it is a text classification task, the response is the score. For example:
POST _ml/trained_models/model2/deployment/_infer { "docs": [{"text_field": "The movie was awesome!!"}] }
The API returns the predicted label and the confidence.
{ "predicted_value" : "POSITIVE", "prediction_probability" : 0.9998667964092964 }
For named entity recognition (NER) tasks, the response contains the annotated text output and the recognized entities.
POST _ml/trained_models/model2/deployment/_infer { "input": "Hi my name is Josh and I live in Berlin" }
The API returns in this case:
{ "predicted_value" : "Hi my name is [Josh](PER&Josh) and I live in [Berlin](LOC&Berlin)", "entities" : [ { "entity" : "Josh", "class_name" : "PER", "class_probability" : 0.9977303419824, "start_pos" : 14, "end_pos" : 18 }, { "entity" : "Berlin", "class_name" : "LOC", "class_probability" : 0.9992474323902818, "start_pos" : 33, "end_pos" : 39 } ] }