IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Create trained model vocabulary API
editCreate trained model vocabulary APIedit
Creates a trained model vocabulary. This is supported only for natural language processing (NLP) models.
Requestedit
PUT _ml/trained_models/<model_id>/vocabulary/
Prerequisitesedit
Requires the manage_ml
cluster privilege. This privilege is included in the
machine_learning_admin
built-in role.
Descriptionedit
The vocabulary is stored in the index as described in
inference_config.*.vocabulary
of the trained model definition.
Path parametersedit
-
<model_id>
- (Required, string) The unique identifier of the trained model.
Request bodyedit
-
vocabulary
- (array) The model vocabulary. Must not be empty.
-
merges
- (Optional, array) The model merges used in byte-pair encoding. The merges must be sub-token pairs, space delimited, and in order of preference. Example: ["f o", "fo o"]. Must be provided for RoBERTa and BART style models.
-
scores
-
(Optional, array)
Vocabulary value scores used by sentence-piece tokenization. Must have the same length as
vocabulary
. Required for unigram sentence-piece tokenized models like XLMRoberta and T5.
Examplesedit
The following example shows how to create a model vocabulary for a previously stored trained model configuration.
resp = client.ml.put_trained_model_vocabulary( model_id="elastic__distilbert-base-uncased-finetuned-conll03-english", body={"vocabulary": ["[PAD]", "[unused0]", ...]}, ) print(resp)
PUT _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/vocabulary { "vocabulary": [ "[PAD]", "[unused0]", ... ] }
The API returns the following results:
{ "acknowledged": true }