Mistral3Tokenizer classkeras_hub.tokenizers.Mistral3Tokenizer(
vocabulary=None, merges=None, split_pattern=None, control_tokens=None, **kwargs
)
Mistral3 Tekken tokenizer layer based on byte-level BPE.
Handles Mistral3's Tekken (tiktoken-style byte-level BPE) vocabulary. It
is based on keras_hub.tokenizers.BytePairTokenizer, uses the Tekken
pre-tokenization regex instead of the GPT-2/Llama3 pattern hardcoded in
the base class, and registers the special image tokens ("[IMG]",
"[IMG_BREAK]", "[IMG_END]") used by multimodal Mistral3/Pixtral
models to mark image placeholder positions in a prompt.
Not a subclass of keras_hub.models.MistralTekkenTokenizer: that class
builds its unsplittable_tokens list inline in __init__ before calling
the BytePairTokenizer constructor, which doesn't leave a clean
extension point for adding the vision tokens via inheritance.
The vocabulary and merges are usually produced from a tekken.json
file by the Hugging Face conversion path; see
keras_hub.src.utils.transformers.convert_mistral3.
If input is a batch of strings (rank > 0), the layer will output a
tf.RaggedTensor where the last dimension of the output is ragged.
If input is a scalar string (rank == 0), the layer will output a dense
tf.Tensor with static shape [None].
Arguments
"[INST]") to register as unsplittable, in addition to the
start/end/vision tokens. Defaults to None.Examples
tokenizer = keras_hub.models.Mistral3Tokenizer.from_preset(
"hf://mistralai/Mistral-Small-3.2-24B-Instruct-2506",
)
tokenizer("The quick brown fox jumped.")
tokenizer.detokenize(tokenizer("The quick brown fox jumped."))
from_preset methodMistral3Tokenizer.from_preset(preset, config_file="tokenizer.json", **kwargs)
Instantiate a keras_hub.models.Tokenizer from a model preset.
A preset is a directory of configs, weights and other file assets used
to save and load a pre-trained model. The preset can be passed as
one of:
'bert_base_en''kaggle://user/bert/keras/bert_base_en''hf://user/bert_base_en''./bert_base_en'For any Tokenizer subclass, you can run cls.presets.keys() to list
all built-in presets available on the class.
This constructor can be called in one of two ways. Either from the base
class like keras_hub.models.Tokenizer.from_preset(), or from
a model class like keras_hub.models.GemmaTokenizer.from_preset().
If calling from the base class, the subclass of the returning object
will be inferred from the config in the preset directory.
Arguments
True, the weights will be loaded into the
model architecture. If False, the weights will be randomly
initialized.Examples
# Load a preset tokenizer.
tokenizer = keras_hub.tokenizer.Tokenizer.from_preset("bert_base_en")
# Tokenize some input.
tokenizer("The quick brown fox tripped.")
# Detokenize some input.
tokenizer.detokenize([5, 6, 7, 8, 9])
| Preset | Parameters | Description |
|---|---|---|
| ministral_3_3b_base_2512_en | 3.85B | 3 billion parameter, 26-layer, pretrained Ministral 3 model with a Pixtral vision encoder for image input. |
| ministral_3_3b_instruct_2512_en | 3.85B | 3 billion parameter, 26-layer, instruction-tuned Ministral 3 model with a Pixtral vision encoder for image input. |
| ministral_3_3b_reasoning_2512_en | 3.85B | 3 billion parameter, 26-layer, reasoning-tuned Ministral 3 model with a Pixtral vision encoder for image input. |
| shieldstral_1.0_3b_en | 3.85B | 3 billion parameter, 26-layer Shieldstral model with a Pixtral vision encoder. The model checks text and image content against a safety policy written in natural language. The model returns one safety score for each input. |
| ministral_3_8b_base_2512_en | 8.92B | 8 billion parameter, 34-layer, pretrained Ministral 3 model with a Pixtral vision encoder for image input. |
| ministral_3_8b_instruct_2512_en | 8.92B | 8 billion parameter, 34-layer, instruction-tuned Ministral 3 model with a Pixtral vision encoder for image input. |
| ministral_3_8b_reasoning_2512_en | 8.92B | 8 billion parameter, 34-layer, reasoning-tuned Ministral 3 model with a Pixtral vision encoder for image input. |
| ministral_3_14b_base_2512_en | 13.95B | 14 billion parameter, 40-layer, pretrained Ministral 3 model with a Pixtral vision encoder for image input. |
| ministral_3_14b_instruct_2512_en | 13.95B | 14 billion parameter, 40-layer, instruction-tuned Ministral 3 model with a Pixtral vision encoder for image input. |
| ministral_3_14b_reasoning_2512_en | 13.95B | 14 billion parameter, 40-layer, reasoning-tuned Ministral 3 model with a Pixtral vision encoder for image input. |
| mistral_small_3.1_24b_base_2503_en | 24.01B | 24 billion parameter, 40-layer, pretrained Mistral3 model with a Pixtral vision encoder for image input. |
| mistral_small_3.1_24b_instruct_2503_en | 24.01B | 24 billion parameter, 40-layer, instruction-tuned Mistral3 model with a Pixtral vision encoder for image input. |
| mistral_small_3.2_24b_instruct_2506_en | 24.01B | 24 billion parameter, 40-layer, instruction-tuned Mistral3 model with a Pixtral vision encoder for image input. An updated version of mistral_small_3.1_24b_instruct_2503_en with improved instruction-following and reduced repetition. |
| devstral_small_2_24b_instruct_2512_en | 24.01B | 24 billion parameter, 40-layer, instruction-tuned Devstral Small 2 model for agentic software engineering, with a Pixtral vision encoder for image input. |
| magistral_small_2509_en | 24.01B | 24 billion parameter, 40-layer, reasoning-tuned Magistral Small model with a Pixtral vision encoder for image input. |