[role="xpack"] [[infer-trained-model-deployment]] = Infer trained model deployment API [subs="attributes"] ++++ Infer trained model deployment ++++ Evaluates a trained model. [[infer-trained-model-deployment-request]] == {api-request-title} `POST _ml/trained_models//deployment/_infer` //// [[infer-trained-model-deployment-prereq]] == {api-prereq-title} //// //// [[infer-trained-model-deployment-desc]] == {api-description-title} //// [[infer-trained-model-deployment-path-params]] == {api-path-parms-title} ``:: (Required, string) include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id] [[infer-trained-model-deployment-query-params]] == {api-query-parms-title} `timeout`:: (Optional, time) Controls the amount of time to wait for {infer} results. Defaults to 10 seconds. [[infer-trained-model-request-body]] == {api-request-body-title} `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. //// [[infer-trained-model-deployment-results]] == {api-response-body-title} //// //// [[ml-get-trained-models-response-codes]] == {api-response-codes-title} //// [[infer-trained-model-deployment-example]] == {api-examples-title} The response depends on the task the model is trained for. If it is a text classification task, the response is the score. For example: [source,console] -------------------------------------------------- POST _ml/trained_models/model2/deployment/_infer { "docs": [{"text_field": "The movie was awesome!!"}] } -------------------------------------------------- // TEST[skip:TBD] The API returns the predicted label and the confidence. [source,console-result] ---- { "predicted_value" : "POSITIVE", "prediction_probability" : 0.9998667964092964 } ---- // NOTCONSOLE For named entity recognition (NER) tasks, the response contains the annotated text output and the recognized entities. [source,console] -------------------------------------------------- POST _ml/trained_models/model2/deployment/_infer { "input": "Hi my name is Josh and I live in Berlin" } -------------------------------------------------- // TEST[skip:TBD] The API returns in this case: [source,console-result] ---- { "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 } ] } ---- // NOTCONSOLE