Skip to navigation

nemo_automodel.recipes.decision.train_nemotron_decision

View as MarkdownOpen in Claude

Post-train Nemotron 3.5 Decision checkpoints on SystemOne records (LoRA or backbone fine-tuning).

Every question of a record is its own read, rendered with the checkpoint’s own decision contract (decision_template.jinja and decision.json: the question’s option order and the checkpoint’s codes), which ends in the mask token. The bidirectional Ministral 3 encoder reads it, and the frozen decision head’s logits at the mask, restricted to the option codes, give the answer distribution. Supervision, the objective and the metrics are the shared decision components: question_targets aligns answers, rewards and soft labels with each prompt’s option order, assemble_decision_batch and DecisionLoss (loss.mode: sft) compute the loss, and DecisionEvaluator scores validation and test. Training reads keep the checkpoint’s option order unless train.canonical_fraction is below 1, in which case the remaining share is shuffled and re-coded by position.

  • peft set: LoRA on the attention/MLP projections; embeddings and the decision head stay frozen.
  • peft: null: backbone fine-tuning of the encoder blocks and final norm; embeddings and the decision head stay frozen.
  • mode: eval scores the configured checkpoint (or init_from stage) on validation and test.

Validation selects the published stage (LOWEST_VAL): most correct validation decisions, then lowest NLL; for LoRA the starting checkpoint (step 0) is a saved, selectable stage; backbone fine-tuning selects among trained stages. Report the test split separately; the validation split is not an untouched test. Export a selected stage as a complete servable checkpoint with examples/decision/export_nemotron_decision.py.

Run with::

automodel examples/decision/nemotron_decision_support_routing_lora.yaml —nproc-per-node 1

Module Contents

Classes

NameDescription
TrainNemotronDecisionRecipeLoRA or full post-training of Nemotron 3.5 Decision checkpoints (see module docstring).
_DecisionOne supervised question of a record, encoded in the checkpoint’s option order.

Functions

NameDescription
mainCLI entry point: python -m nemo_automodel.recipes.decision.train_nemotron_decision --config <yaml>.
selection_valueLower-is-better scalar that orders stages by correct validation decisions, then by lower cross-entropy.

Data

MODES

STAGE_FORMAT

logger

API

class nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe(
)

Bases: BaseRecipe

LoRA or full post-training of Nemotron 3.5 Decision checkpoints (see module docstring).

cfg
nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._encode_split(
records: list[dict[str, typing.Any]],
train: bool

Encode every supervised question of records in the checkpoint’s option order.

Training keeps the questions the objective weights (a gold answer, or soft labels when they replace the gold target); evaluation keeps the questions the evaluator scores (a gold answer or rewards).

Parameters:

records
list[dict[str, Any]]

Validated SystemOne records of one split.

train
bool

Whether the split trains the model.

Returns: list[_Decision]

The decisions, and the number of questions this model cannot read (media, a question that does not fit

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._load_stage(
path: pathlib.Path
) -> None

Initialize weights from a published stage of the same base, method and readout contract.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._log(
name: str,
record: dict[str, typing.Any]
) -> None
nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._logits(
) -> torch.Tensor

Option logits of prompt, fp32 tensor of shape [options] in prompt order.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._report(
split: str
) -> None

Write metrics_{split}.json (evaluator summary) and predictions_{split}.jsonl on the main rank.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._save_stage(
path: pathlib.Path,
validation: dict[str, typing.Any] | None
) -> None

Publish the trainable weights (LoRA adapter or consolidated full weights) as an immutable stage.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._target(
record: dict[str, typing.Any],
staticmethod

Supervision of prompt’s question, aligned with the prompt’s option order.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._targets(
record: dict[str, typing.Any],
device: torch.device | None = None

One-question loss targets with the configured question weights, on device (CPU by default).

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._train() -> pathlib.Path

Train; returns the validation-selected stage (the last stage when there is no validation split).

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe._validate(
step: int
) -> dict[str, typing.Any] | None

Selection record of the current weights on the validation split, or None without one.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe.evaluate(
split: str
) -> tuple[dict[str, typing.Any], list[dict[str, typing.Any]]]

Score every decision of split with the shared DecisionEvaluator.

Every rank runs the same number of forwards; padded duplicates are scored once.

Returns: tuple[dict[str, Any], list[dict[str, Any]]]

The evaluator summary and its per-decision predictions, identical on every rank.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe.run_train_validation_loop() -> None

Evaluate (mode: eval) or train, then report validation and test metrics of the selected weights.

nemo_automodel.recipes.decision.train_nemotron_decision.TrainNemotronDecisionRecipe.setup() -> None

Check the checkpoint contract, build the model, encode the splits and the optimizer.

class nemo_automodel.recipes.decision.train_nemotron_decision._Decision(
record: dict[str, typing.Any],
)
Dataclass

One supervised question of a record, encoded in the checkpoint’s option order.

prompt
PreparedQuestion

Serving prompt of the question (option labels and codes in prompt order).

record
dict[str, Any]

The validated SystemOne record that holds the question.

target
QuestionTarget

Supervision aligned with prompt.labels.

nemo_automodel.recipes.decision.train_nemotron_decision.main(
config_path: str | None = None
) -> None

CLI entry point: python -m nemo_automodel.recipes.decision.train_nemotron_decision --config <yaml>.

nemo_automodel.recipes.decision.train_nemotron_decision.selection_value(
correct: int,
cross_entropy: float
) -> float

Lower-is-better scalar that orders stages by correct validation decisions, then by lower cross-entropy.

The cross-entropy term lies in [0, 0.99], below the gap of one correct decision, so the order is exactly lexicographic for any validation size (every stage is scored on the same validation decisions).

Parameters:

correct
int

Number of correctly decided labelled validation questions.

cross_entropy
float

Mean validation cross-entropy, the evaluator’s nll (clipped to 99).

nemo_automodel.recipes.decision.train_nemotron_decision.MODES = ('eval', 'train')
nemo_automodel.recipes.decision.train_nemotron_decision.STAGE_FORMAT = 'nemotron-decision-stage-v1'
nemo_automodel.recipes.decision.train_nemotron_decision.logger = logging.getLogger(__name__)