Skip to navigation

nemo_automodel.components.models.nemotron_decision

View as MarkdownOpen in Claude

Typed-decision post-training support for Nemotron 3.5 Decision checkpoints.

Submodules

Package Contents

Classes

NameDescription
DecisionContractA checkpoint’s decision prompt contract (decision.json and decision_template.jinja).
NemotronForDecisionBidirectional Ministral 3 encoder plus a vocabulary head read at the decision mask token.
PreparedQuestionOne tokenized decision prompt (without the trailing mask) and its option readout.

Functions

NameDescription
encode_questionEncode one question of a record as its decision prompt, or None if this model cannot read it.
prepare_questionRender one question with the checkpoint’s decision template, optionally with shuffled, re-coded options.
require_decision_configReject checkpoints whose runtime contract this recipe does not implement.

API

class nemo_automodel.components.models.nemotron_decision.serving_prompt.DecisionContract(
template: str,
labels: dict[str, tuple[str, ...]],
max_input_tokens: int
)
Dataclass

A checkpoint’s decision prompt contract (decision.json and decision_template.jinja).

labels
dict[str, tuple[str, ...]]

Option codes per question type, in position order.

max_input_tokens
int

Longest read the checkpoint accepts, mask included.

sha256
str

Identity of the contract (template, codes and limit).

template
str

The Jinja decision template; it renders decision_content and ends with the mask token.

classmethod

Load and validate the contract of a local checkpoint directory or Hugging Face repository.

Raises:

  • ValueError: If a file is missing or the contract is malformed.
class nemo_automodel.components.models.nemotron_decision.model.NemotronForDecision(
config: transformers.models.ministral3.configuration_ministral3.Ministral3Config,
kwargs: typing.Any = {}
)

Bases: PreTrainedModel

Bidirectional Ministral 3 encoder plus a vocabulary head read at the decision mask token.

_no_split_modules
= ['Ministral3DecoderLayer']
base_model_prefix
= 'encoder'
diffusion_head
encoder
= Ministral3BidirectionalModel(config)
tie_word_embeddings_support
TieSupport = TieSupport.UNTIED_ONLY
nemo_automodel.components.models.nemotron_decision.model.NemotronForDecision.forward(
input_ids: torch.LongTensor | None = None,
attention_mask: torch.Tensor | None = None,
position_ids: torch.LongTensor | None = None,
inputs_embeds: torch.FloatTensor | None = None,
output_last_hidden_states_only: bool = False,
kwargs: typing.Any = {}
) -> transformers.modeling_outputs.BaseModelOutput | transformers.modeling_outputs.MaskedLMOutput

Read the sequence bidirectionally.

Parameters:

input_ids
torch.LongTensor | NoneDefaults to None

Token ids [batch, sequence].

attention_mask
torch.Tensor | NoneDefaults to None

Optional padding mask [batch, sequence].

position_ids
torch.LongTensor | NoneDefaults to None

Optional positions [batch, sequence]; defaults to 0..sequence-1.

inputs_embeds
torch.FloatTensor | NoneDefaults to None

Optional embeddings instead of input_ids.

output_last_hidden_states_only
boolDefaults to False

Return the encoder’s last hidden state without projecting the [batch, sequence, vocab] logits.

**kwargs
AnyDefaults to {}

Passed to the encoder (use_cache is ignored; decision reads keep no cache).

Returns: BaseModelOutput | MaskedLMOutput

BaseModelOutput(last_hidden_state) or MaskedLMOutput(logits).

nemo_automodel.components.models.nemotron_decision.model.NemotronForDecision.get_input_embeddings() -> torch.nn.Embedding

Token embeddings of the encoder.

nemo_automodel.components.models.nemotron_decision.model.NemotronForDecision.get_output_embeddings() -> torch.nn.Linear

The decision readout head.

nemo_automodel.components.models.nemotron_decision.model.NemotronForDecision.set_input_embeddings(
value: torch.nn.Embedding
) -> None

Replace the encoder’s token embeddings.

nemo_automodel.components.models.nemotron_decision.model.NemotronForDecision.set_output_embeddings(
value: torch.nn.Linear
) -> None

Replace the decision readout head.

nemo_automodel.components.models.nemotron_decision.model.NemotronForDecision.supports_config(
config: typing.Any
) -> bool
classmethod

True for text Ministral 3 decision checkpoints (no vision tower, no quantization).

class nemo_automodel.components.models.nemotron_decision.serving_prompt.PreparedQuestion(
question_id: str,
kind: str,
labels: tuple[str, ...],
code_token_ids: tuple[int, ...],
input_ids: tuple[int, ...]
)
Dataclass

One tokenized decision prompt (without the trailing mask) and its option readout.

code_token_ids
tuple[int, ...]
input_ids
tuple[int, ...]
kind
str
labels
tuple[str, ...]
question_id
str
nemo_automodel.components.models.nemotron_decision.records.encode_question(
tokenizer: typing.Any,
record: dict[str, typing.Any],
question_id: str,
mask_token_id: int,
max_tokens: int,
shuffle_seed: int | None = None

Encode one question of a record as its decision prompt, or None if this model cannot read it.

A question is not readable when the record carries media, the question does not fit the checkpoint’s contract (no instructions, unsupported fields, or more options than codes), or the prompt plus its mask is longer than max_tokens. The caller counts these questions.

Parameters:

tokenizer
Any

Tokenizer of the checkpoint.

contract
DecisionContract

The checkpoint’s decision contract.

record
dict[str, Any]

Validated SystemOne record that holds the question.

question_id
str

Key of the question in record["questions"].

mask_token_id
int

The checkpoint’s mask token.

max_tokens
int

Longest allowed prompt including the mask slot.

shuffle_seed
int | NoneDefaults to None

Option-shuffle seed (None keeps the checkpoint’s option order).

nemo_automodel.components.models.nemotron_decision.serving_prompt.prepare_question(
tokenizer: typing.Any,
state: typing.Any,
question_id: str,
question: dict[str, typing.Any],
mask_token_id: int,
shuffle_seed: int | None = None

Render one question with the checkpoint’s decision template, optionally with shuffled, re-coded options.

Parameters:

tokenizer
Any

Tokenizer of the checkpoint.

contract
DecisionContract

The checkpoint’s decision contract.

state
Any

JSON-serializable evidence shared by the question.

question_id
str

Key of the question (used in errors).

question
dict[str, Any]

{"type", "instructions", "criteria"} of a choice, noul or score question.

mask_token_id
int

The checkpoint’s mask token, which the template must write exactly once, at the end.

shuffle_seed
int | NoneDefaults to None

When set, permute the options with perm_seed(shuffle_seed) and re-code them by position; None keeps the checkpoint’s option order.

Returns: PreparedQuestion

The prepared prompt; token ids exclude the trailing mask.

Raises:

  • ValueError: If the question is malformed, has more options than codes, or the template does not end in exactly one mask token.
nemo_automodel.components.models.nemotron_decision.scorer.require_decision_config(
config: typing.Any
) -> None

Reject checkpoints whose runtime contract this recipe does not implement.

The recipe trains Nemotron 3.5 Decision checkpoints: a text Ministral 3 encoder read with fully bidirectional attention, one question per read, and the decision head at the mask token. Vision and quantized variants need their own input and storage paths and are not run silently as the text model.

Parameters:

config
Any

Hugging Face config (attribute access) of the checkpoint.

Raises:

  • ValueError: If the architecture, attention or storage format is unsupported.