Infer trained model deployment APIedit

Evaluates 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.


POST _ml/trained_models/<model_id>/deployment/_infer

Path parametersedit

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

Query parametersedit

(Optional, time) Controls the amount of time to wait for inference results. Defaults to 10 seconds.

Request bodyedit

(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.


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:

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