nemo_automodel.components.models.ministral_bidirectional.model
nemo_automodel.components.models.ministral_bidirectional.model
Custom bidirectional Ministral3 model for explicit and legacy use.
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. Standard ministral3 embedding checkpoints
use the stock HuggingFace model with is_causal=False; this custom architecture
remains available for ministral3_bidirec checkpoints.
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.
This class is not selected automatically for standard ministral3 embedding
checkpoints. It remains registered for explicit and legacy use.
In causal 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.