Mistral3CausalLMPreprocessor classkeras_hub.models.Mistral3CausalLMPreprocessor(
tokenizer,
image_converter=None,
sequence_length=1024,
add_start_token=True,
add_end_token=True,
spatial_merge_size=2,
**kwargs
)
Mistral3 Causal LM preprocessor.
This preprocessing layer is meant for use with
keras_hub.models.Mistral3CausalLM. It takes in batches of prompts and
(optionally, per-prompt) images and returns outputs in a
(x, y, sample_weight) format, where the y label is the next token id
in the x sequence.
x for call()/generate_preprocess() should be a dict with
"prompts" (and optionally "responses") and, for multimodal inputs, an
"images" key. Images are matched to prompts by their "[IMG]"
placeholder occurrences, consumed in order — "images" can be any
reasonable nesting (a single image, a batched array, flat or
per-prompt-grouped lists), as long as the total image count matches the
total placeholder count. Omitting "images" (or passing x as a plain
string/list of strings) preprocesses as plain text, matching HF's
Mistral3ForConditionalGeneration, which also supports text-only calls.
For use with generation, the layer also exposes two methods
generate_preprocess() and generate_postprocess(). When this preprocessor
is attached to a keras_hub.models.Mistral3CausalLM instance, these methods
will be called implicitly in generate(). They can also be called
standalone (e.g. to precompute preprocessing inputs for generation in a
separate process).
Arguments
keras_hub.models.Mistral3Tokenizer instance.keras_hub.layers.Mistral3ImageConverter
instance or None.True, the preprocessor will prepend the tokenizer
start token to each input sequence. Default is True.True, the preprocessor will append the tokenizer
end token to each input sequence. Default is True.2.Call arguments
"prompts" and, optionally, "images" keys.None as the layer generates labels.None as the layer
generates label weights.sequence_length of
the layer.from_preset methodMistral3CausalLMPreprocessor.from_preset(
preset, config_file="preprocessor.json", **kwargs
)
Instantiate a keras_hub.models.Preprocessor 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 Preprocessor subclass, you can run cls.presets.keys() to
list all built-in presets available on the class.
As there are usually multiple preprocessing classes for a given model,
this method should be called on a specific subclass like
keras_hub.models.BertTextClassifierPreprocessor.from_preset().
Arguments
Examples
# Load a preprocessor for Gemma generation.
preprocessor = keras_hub.models.CausalLMPreprocessor.from_preset(
"gemma_2b_en",
)
# Load a preprocessor for Bert classification.
preprocessor = keras_hub.models.TextClassifierPreprocessor.from_preset(
"bert_base_en",
)
| 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. |
tokenizer propertykeras_hub.models.Mistral3CausalLMPreprocessor.tokenizer
The tokenizer used to tokenize strings.
image_converter propertykeras_hub.models.Mistral3CausalLMPreprocessor.image_converter
The image converter used to preprocess image data.