Skip to navigation
ReferenceFull Library ReferenceNemo AutomodelNemo AutomodelComponentsModelsCommonnemo_automodel.components.models.common.decision_reader

nemo_automodel.components.models.common.decision_reader

View as MarkdownOpen in Claude

Model-owned reads for decision post-training.

The decision recipe reads every question of a SystemOne record on its own. A DecisionReader owns the two model-specific steps of a read: encoding one question as model input, and returning that question’s option logits. DecisionReaderConfig is the YAML reader: block; the recipe calls prepare before it loads the model and build after.

Module Contents

Classes

NameDescription
DecisionReadOne question encoded for a model.
DecisionReaderEncodes questions for one model and scores them (see the module docstring).
DecisionReaderConfigYAML reader: block of the decision recipe.

Data

ReadT

API

class nemo_automodel.components.models.common.decision_reader.DecisionRead(
question_id: str,
labels: tuple[str, ...]
)
Dataclass

One question encoded for a model.

labels
tuple[str, ...]

Option IDs in the order of the model’s logits.

question_id
str

Key of the question in its record.

class nemo_automodel.components.models.common.decision_reader.DecisionReader()
Abstract

Bases: Generic[ReadT]

Encodes questions for one model and scores them (see the module docstring).

max_input_tokens
int

Longest read the checkpoint accepts.

nemo_automodel.components.models.common.decision_reader.DecisionReader.encode(
record: dict[str, typing.Any],
question_id: str,
shuffle_seed: int | None = None
abstract

Encode one question of a validated SystemOne record.

Parameters:

record
dict[str, Any]

Validated SystemOne record that holds the question.

question_id
str

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

shuffle_seed
int | NoneDefaults to None

Option-shuffle seed, or None for the model’s own option order.

Returns: ReadT | None

The read, or None when this model cannot read the question; the recipe counts those as skipped.

nemo_automodel.components.models.common.decision_reader.DecisionReader.identity() -> dict[str, typing.Any]
abstract

Model-specific stage fields; the recipe refuses to load a stage whose identity differs.

nemo_automodel.components.models.common.decision_reader.DecisionReader.logits(
) -> torch.Tensor
abstract

Score one read.

Parameters:

read
ReadT

A read returned by encode.

Returns: torch.Tensor

fp32 tensor of shape [options] in read.labels order.

class nemo_automodel.components.models.common.decision_reader.DecisionReaderConfig()
DataclassAbstract

Bases: Generic[ReadT]

YAML reader: block of the decision recipe.

model: torch.nn.Module,
tokenizer: transformers.PreTrainedTokenizerBase,
model_path: str,
revision: str | None,
max_tokens: int,
peft: bool,
device: torch.device
abstract

Model-specific part of build (same arguments).

model: torch.nn.Module,
tokenizer: transformers.PreTrainedTokenizerBase,
model_path: str,
revision: str | None,
max_tokens: int,
peft: bool,
device: torch.device

Check the checkpoint contract, set the trainable parameters, and return the reader.

Parameters:

model
nn.Module

The model as the recipe runs it (DDP or FSDP2); reads run their forward through it.

tokenizer
PreTrainedTokenizerBase

Tokenizer of the checkpoint.

model_path
str

Checkpoint directory or Hub ID.

revision
str | None

Checkpoint revision, or None.

max_tokens
int

Longest read to accept (data.max_tokens).

peft
bool

Whether a PEFT adapter is configured.

device
torch.device

Device of the reads.

Returns: DecisionReader[ReadT]

The reader.

Raises:

  • ValueError: If max_tokens exceeds the checkpoint’s read limit, or the checkpoint or configuration is outside the reader’s contract.
nemo_automodel.components.models.common.decision_reader.DecisionReaderConfig.prepare(
model_path: str,
revision: str | None
) -> None
abstract

Run the checks and setup that must happen before the model is loaded.

Parameters:

model_path
str

Checkpoint directory or Hub ID.

revision
str | None

Checkpoint revision, or None.

nemo_automodel.components.models.common.decision_reader.ReadT = TypeVar('ReadT', bound=DecisionRead)