nemo_automodel.components.models.ministral_bidirectional.model
nemo_automodel.components.models.ministral_bidirectional.model
Bidirectional Ministral3 model for embedding tasks.
This module provides a modified Ministral3Model that uses bidirectional (non-causal) attention, suitable for generating embeddings where each token should attend to all other tokens in the sequence.
Module Contents
Classes
Functions
Data
API
Bases: Ministral3Config
Configuration for Ministral3BidirectionalModel with pooling and temperature settings.
Bases: Ministral3Model
Ministral3Model modified to use bidirectional (non-causal) attention.
In standard Ministral3, each token can only attend to previous tokens (causal attention). This model removes that restriction, allowing each token to attend to all tokens in the sequence, which is useful for embedding tasks.
Loading a Mistral3 VLM checkpoint (e.g. mistralai/Ministral-3-3B-Base-2512
or mistralai/Ministral-3-3B-Instruct-2512) requires extracting the language
tower; this is driven by the recipe YAML via
extract_submodel: language_model and handled by
:func:nemo_automodel._transformers.retrieval.build_encoder_backbone.
Text-only checkpoints (e.g. mistralai/Ministral-3B-Instruct) load directly
via the standard from_pretrained path with no extraction needed.
Forward pass with bidirectional attention.
Identical to Ministral3Model.forward() except the causal mask is replaced with a bidirectional mask, allowing all tokens to attend to each other.
Register bidirectional Ministral3 with HuggingFace Auto classes.
Needed so AutoModel.from_config(Ministral3BidirectionalConfig) and checkpoint
reload paths that use Auto resolution work consistently.