Create a trained model vocabulary Generally available

PUT /_ml/trained_models/{model_id}/vocabulary

This API is supported only for natural language processing (NLP) models. The vocabulary is stored in the index as described in inference_config.*.vocabulary of the trained model definition.

Required authorization

  • Cluster privileges: manage_ml

Path parameters

  • model_id string Required

    The unique identifier of the trained model.

application/json

Body Required

  • vocabulary array[string] Required

    The model vocabulary, which must not be empty.

  • merges array[string] Generally available

    The optional model merges if required by the tokenizer.

  • scores array[number] Generally available

    The optional vocabulary value scores if required by the tokenizer.

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • acknowledged boolean Required

      For a successful response, this value is always true. On failure, an exception is returned instead.

PUT /_ml/trained_models/{model_id}/vocabulary
PUT _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/vocabulary
{
  "vocabulary": [
    "[PAD]",
    "[unused0]",
  ]
}
resp = client.ml.put_trained_model_vocabulary(
    model_id="elastic__distilbert-base-uncased-finetuned-conll03-english",
    vocabulary=[
        "[PAD]",
        "[unused0]"
    ],
)
const response = await client.ml.putTrainedModelVocabulary({
  model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english",
  vocabulary: ["[PAD]", "[unused0]"],
});
response = client.ml.put_trained_model_vocabulary(
  model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english",
  body: {
    "vocabulary": [
      "[PAD]",
      "[unused0]"
    ]
  }
)
$resp = $client->ml()->putTrainedModelVocabulary([
    "model_id" => "elastic__distilbert-base-uncased-finetuned-conll03-english",
    "body" => [
        "vocabulary" => array(
            "[PAD]",
            "[unused0]",
        ),
    ],
]);
curl -X PUT -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"vocabulary":["[PAD]","[unused0]"]}' "$ELASTICSEARCH_URL/_ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/vocabulary"
Request example
An example body for a `PUT _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/vocabulary` request.
{
  "vocabulary": [
    "[PAD]",
    "[unused0]",
  ]
}