Evaluate a trained model Added in 8.3.0

POST /_ml/trained_models/{model_id}/deployment/_infer

Path parameters

  • model_id string Required

    The unique identifier of the trained model.

Query parameters

  • timeout string

    Controls the amount of time to wait for inference results.

application/json

Body Required

  • docs array[object] Required

    An array of objects to pass to the model for inference. The objects should contain a fields matching your configured trained model input. Typically, for NLP models, the field name is text_field. Currently, for NLP models, only a single value is allowed.

    Hide docs attribute Show docs attribute object
    • * object Additional properties

      Additional properties are allowed.

  • Additional properties are allowed.

    Hide inference_config attributes Show inference_config attributes object
    • Additional properties are allowed.

      Hide regression attributes Show regression attributes object
    • Additional properties are allowed.

      Hide classification attributes Show classification attributes object
      • Specifies the number of top class predictions to return. Defaults to 0.

      • Specifies the maximum number of feature importance values per document.

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

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

      • Specifies the field to which the top classes are written. Defaults to top_classes.

    • Additional properties are allowed.

      Hide text_classification attributes Show text_classification attributes object
      • Specifies the number of top class predictions to return. Defaults to 0.

      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

      • Classification labels to apply other than the stored labels. Must have the same deminsions as the default configured labels

    • Additional properties are allowed.

      Hide zero_shot_classification attributes Show zero_shot_classification attributes object
      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

      • Update the configured multi label option. Indicates if more than one true label exists. Defaults to the configured value.

      • labels array[string] Required

        The labels to predict.

    • Additional properties are allowed.

      Hide fill_mask attributes Show fill_mask attributes object
      • Specifies the number of top class predictions to return. Defaults to 0.

      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

    • ner object

      Additional properties are allowed.

      Hide ner attributes Show ner attributes object
      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

    • Additional properties are allowed.

      Hide pass_through attributes Show pass_through attributes object
      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

    • Additional properties are allowed.

      Hide text_embedding attributes Show text_embedding attributes object
      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

    • Additional properties are allowed.

      Hide text_expansion attributes Show text_expansion attributes object
      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

    • Additional properties are allowed.

      Hide question_answering attributes Show question_answering attributes object
      • question string Required

        The question to answer given the inference context

      • Specifies the number of top class predictions to return. Defaults to 0.

      • Additional properties are allowed.

        Hide tokenization attributes Show tokenization attributes object
        • truncate string

          Values are first, second, or none.

        • span number

          Span options to apply

      • The field that is added to incoming documents to contain the inference prediction. Defaults to predicted_value.

      • The maximum answer length to consider for extraction

Responses

POST /_ml/trained_models/{model_id}/deployment/_infer
curl \
 -X POST http://api.example.com/_ml/trained_models/{model_id}/deployment/_infer \
 -H "Content-Type: application/json" \
 -d '{"docs":[{"additionalProperty1":{},"additionalProperty2":{}}],"inference_config":{"regression":{"results_field":"string","num_top_feature_importance_values":42.0},"classification":{"num_top_classes":42.0,"num_top_feature_importance_values":42.0,"prediction_field_type":"string","results_field":"string","top_classes_results_field":"string"},"text_classification":{"num_top_classes":42.0,"tokenization":{"truncate":"first","span":42.0},"results_field":"string","classification_labels":["string"]},"zero_shot_classification":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string","multi_label":true,"labels":["string"]},"fill_mask":{"num_top_classes":42.0,"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"ner":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"pass_through":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"text_embedding":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"text_expansion":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"question_answering":{"question":"string","num_top_classes":42.0,"tokenization":{"truncate":"first","span":42.0},"results_field":"string","max_answer_length":42.0}}}'
Request examples
{
  "docs": [
    {
      "additionalProperty1": {},
      "additionalProperty2": {}
    }
  ],
  "inference_config": {
    "regression": {
      "results_field": "string",
      "num_top_feature_importance_values": 42.0
    },
    "classification": {
      "num_top_classes": 42.0,
      "num_top_feature_importance_values": 42.0,
      "prediction_field_type": "string",
      "results_field": "string",
      "top_classes_results_field": "string"
    },
    "text_classification": {
      "num_top_classes": 42.0,
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string",
      "classification_labels": [
        "string"
      ]
    },
    "zero_shot_classification": {
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string",
      "multi_label": true,
      "labels": [
        "string"
      ]
    },
    "fill_mask": {
      "num_top_classes": 42.0,
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string"
    },
    "ner": {
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string"
    },
    "pass_through": {
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string"
    },
    "text_embedding": {
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string"
    },
    "text_expansion": {
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string"
    },
    "question_answering": {
      "question": "string",
      "num_top_classes": 42.0,
      "tokenization": {
        "truncate": "first",
        "span": 42.0
      },
      "results_field": "string",
      "max_answer_length": 42.0
    }
  }
}
Response examples (200)
{
  "inference_results": [
    {
      "entities": [
        {
          "class_name": "string",
          "class_probability": 42.0,
          "entity": "string",
          "start_pos": 42.0,
          "end_pos": 42.0
        }
      ],
      "is_truncated": true,
      "": 42.0,
      "predicted_value_sequence": "string",
      "prediction_probability": 42.0,
      "prediction_score": 42.0,
      "top_classes": [
        {
          "class_name": "string",
          "class_probability": 42.0,
          "class_score": 42.0
        }
      ],
      "warning": "string",
      "feature_importance": [
        {
          "feature_name": "string",
          "importance": 42.0,
          "classes": [
            {}
          ]
        }
      ]
    }
  ]
}