nemo_automodel.components.models.ministral_bidirectional
nemo_automodel.components.models.ministral_bidirectional
Bidirectional Ministral3 model for embedding and retrieval tasks.
Submodules
nemo_automodel.components.models.ministral_bidirectional.modelnemo_automodel.components.models.ministral_bidirectional.processornemo_automodel.components.models.ministral_bidirectional.reranker_exportnemo_automodel.components.models.ministral_bidirectional.reranker_model
Package Contents
Classes
API
Bases: Ministral3Config
Configuration for Ministral3BidirectionalModel with pooling and temperature settings.
Bases: Ministral3Model
Ministral3 retrieval model with a configurable attention mode.
The historical class identity is retained for legacy checkpoint compatibility.
Forward pass with the attention mode stored in the model config.
Causal mode delegates to the Hugging Face parent implementation. Non-causal mode uses the retrieval-specific bidirectional mask.
Parameters:
Integer token IDs [batch, sequence], exclusive with inputs_embeds.
Optional padding mask [batch, sequence], with zero for padding.
Integer positions [batch, sequence] or [1, sequence].
Optional Transformers cache in its native layout.
Floating-point embeddings [batch, sequence, hidden].
Whether to populate the returned cache.
Integer cache positions [sequence].
Additional Hugging Face forward options.
Returns: BaseModelOutputWithPast
Output with floating-point last_hidden_state [batch, sequence, hidden],
Bases: Mistral3Config
Configuration for Mistral3BidirectionalModel with pooling and temperature settings.
Serialize pooling under its public configuration key.
Bases: Mistral3Model
Mistral3 retrieval model with a configurable Ministral3 text tower.
The historical class identity is retained while the text tower honors either policy.
Run the smallest valid Pixtral image through the sharded vision tower.
Apply compatible Liger kernels to the Ministral text tower only.
Run text or multimodal inputs through one FSDP root forward.
Parameters:
Tensor of shape [batch, sequence] containing text and image placeholder token IDs.
Tensor of shape [images, channels, height, width].
Tensor of shape [images, 2] containing image height and width.
Tensor of shape [batch, sequence].
Tensor of shape [batch, sequence].
Optional cache with per-layer key and value tensors of shape [batch, kv_heads, cached_sequence, head_dim], where kv_heads is the number of key/value heads and cached_sequence is the stored token count. The cache is updated in place when used.
Tensor of shape [batch, sequence, hidden].
Whether to return updated key/value cache state.
Whether to return attention tensors.
Whether to return intermediate hidden states.
Whether to return a structured model output.
Whether to execute a zero-weighted vision path for text-only inputs. Defaults to enabled in training. Sharded vision layers always participate during evaluation, even when false, to preserve collective ordering across ranks with different modalities.
Additional arguments forwarded to the stock Mistral3 model.
Returns: tuple[torch.Tensor, ...] | Mistral3ModelOutputWithPast
A Mistral3ModelOutputWithPast with these fields:
Load stock Mistral3 weights into the bidirectional VL layout.
Caller-provided key mappings take precedence over this model’s default stock-checkpoint conversion.
Return the stock Transformers config used for portable inference export.
Subclasses must explicitly re-assert _export_as_stock_model = True.
This prevents inherited export from silently discarding custom forward
behavior that a stock Mistral3Model cannot reproduce.
Select this implementation only for Ministral3 text towers.
Parameters:
Checkpoint configuration before any retrieval conversion.
Returns: bool
Whether the checkpoint has a supported text architecture.
Bases: Mistral3PreTrainedModel
Bidirectional Mistral3 VLM with a sequence-scoring head.
Return the temperature applied to score logits by this model.
Select the portable reranker export for direct and distributed checkpoint saves.
Initialize the scoring head in its configured dtype.
Parameters:
Module whose parameters are initialized in place.
Apply compatible Liger kernels to the nested Mistral text tower.
Score each multimodal question-document sequence.
Parameters:
Tensor of shape [batch, sequence] containing text and image placeholder token IDs.
Tensor of shape [images, channels, height, width].
Tensor of shape [images, 2] containing image height and width before padding.
Tensor of shape [batch, sequence].
Tensor of shape [batch, sequence].
Optional cache with per-layer key and value tensors of shape [batch, kv_heads, cached_sequence, head_dim], where kv_heads is the number of key/value heads and cached_sequence is the stored token count. The cache is updated in place when used.
Tensor of shape [batch, sequence, hidden].
Tensor of shape [query_batch] containing the relevant candidate index for each query. Accepted for compatibility but intentionally unused because the recipe computes the grouped cross-entropy loss.
Whether to return updated key/value cache state.
Whether to return attention tensors.
Whether to return intermediate hidden states.
Whether to return a structured model output.
Whether text-only inputs should run dummy vision. Sharded vision always participates during evaluation to keep collectives aligned across ranks with different modalities.
Additional arguments forwarded to Mistral3BidirectionalModel.
Returns: SequenceClassifierOutputWithPast | tuple[torch.Tensor, ...]
A SequenceClassifierOutputWithPast with these fields:
Load stock Mistral3 VLM weights into the reranker layout.
Stock conditional-generation checkpoints nest the text backbone under
model.language_model.model. This reranker owns that backbone directly
under model.language_model, so checkpoint loading must remove the
extra model segment.
Save trained weights using the shared Transformers/vLLM reranker head name.
Return whether the checkpoint uses the supported Ministral3 text tower.
Parameters:
Checkpoint configuration before retrieval conversion.
Returns: bool
Whether the checkpoint can use this scoring backbone.