Skip to navigation

nemo_automodel.components.models.d1.text_readout

View as Markdown

Model-owned frozen text features and released D1 option-scoring semantics.

Module Contents

Classes

NameDescription
D1CausalTextReadoutFinal-token features and max-over-answer-alias logits for D1-3B.
D1OmniTextReadoutSequence features and calibrated marker logits for D1 Omni text.
D1TextReadoutOne variant’s feature boundary and trainable released readout.

Functions

NameDescription
_validate_feature_pairsReject missing feature slots before variant-specific scoring.
_validate_text_inputRequire the single-question, unpadded frozen-feature boundary.

API

class nemo_automodel.components.models.d1.text_readout.D1CausalTextReadout(
)

Final-token features and max-over-answer-alias logits for D1-3B.

head
token_ids
token_index
nemo_automodel.components.models.d1.text_readout.D1CausalTextReadout.extract_features(
input_ids: torch.Tensor,
attention_mask: torch.Tensor
) -> torch.Tensor

Return the causal final-token state before the tied vocabulary projection.

Parameters:

input_ids
torch.Tensor

Long Tensor of shape [1, sequence] on the model device.

attention_mask
torch.Tensor

Boolean Tensor of shape [1, sequence], all true.

Returns: torch.Tensor

Tensor of shape [hidden] containing the final normalized token state.

nemo_automodel.components.models.d1.text_readout.D1CausalTextReadout.score(
features: collections.abc.Sequence[torch.Tensor],
examples: collections.abc.Sequence[nemo_automodel.components.models.d1.records.D1TextExample],
head: torch.nn.Module
) -> list[torch.Tensor]

Apply answer-alias maxima without introducing a new temperature.

Parameters:

features
Sequence[torch.Tensor]

Tensors of shape [hidden] on the head device.

examples
Sequence[D1TextExample]

Causal questions whose alias vocabulary IDs were prepared by this readout, in feature order.

head
nn.Module

The additive answer-row adapter or a frozen reference copy.

Returns: list[torch.Tensor]

List of float32 Tensors of shape [options], in each example’s option order.

class nemo_automodel.components.models.d1.text_readout.D1OmniTextReadout(
)

Sequence features and calibrated marker logits for D1 Omni text.

head
= model.head.float()
nemo_automodel.components.models.d1.text_readout.D1OmniTextReadout.extract_features(
input_ids: torch.Tensor,
attention_mask: torch.Tensor
) -> torch.Tensor

Return normalized text states before the released marker head.

Parameters:

input_ids
torch.Tensor

Long Tensor of shape [1, sequence] on the model device.

attention_mask
torch.Tensor

Boolean Tensor of shape [1, sequence], all true.

Returns: torch.Tensor

Tensor of shape [sequence, hidden], retaining its backbone graph

nemo_automodel.components.models.d1.text_readout.D1OmniTextReadout.score(
features: collections.abc.Sequence[torch.Tensor],
examples: collections.abc.Sequence[nemo_automodel.components.models.d1.records.D1TextExample],
head: torch.nn.Module
) -> list[torch.Tensor]

Pad text features, score marker rows, and apply released calibration.

Parameters:

features
Sequence[torch.Tensor]

Tensors of shape [sequence, hidden] on the head device; sequence lengths may differ. Readout arithmetic uses float32.

examples
Sequence[D1TextExample]

Marker questions with released text temperatures, aligned with features and retaining internal false/true noul order.

head
nn.Module

The released Omni marker head or a frozen reference copy.

Returns: list[torch.Tensor]

List of float32 Tensors of shape [options], in each example’s option order,

class nemo_automodel.components.models.d1.text_readout.D1TextReadout()
Protocol

One variant’s feature boundary and trainable released readout.

head is the only trainable module in this frozen-feature workflow. A feature must be scored by the readout that produced it: causal features have shape [hidden], while Omni features have shape [sequence, hidden].

head
Module

Return the trainable released head or additive answer-row adapter.

nemo_automodel.components.models.d1.text_readout.D1TextReadout.extract_features(
input_ids: torch.Tensor,
attention_mask: torch.Tensor
) -> torch.Tensor

Encode one unpadded text question without applying the readout.

Parameters:

input_ids
torch.Tensor

Long Tensor of shape [1, sequence] on the model device.

attention_mask
torch.Tensor

Boolean Tensor of shape [1, sequence], all true.

Returns: torch.Tensor

Tensor of shape [hidden] for a causal final-token feature, or

nemo_automodel.components.models.d1.text_readout.D1TextReadout.score(
features: collections.abc.Sequence[torch.Tensor],
examples: collections.abc.Sequence[nemo_automodel.components.models.d1.records.D1TextExample],
head: torch.nn.Module
) -> list[torch.Tensor]

Score aligned features using the variant’s option and calibration rules.

Parameters:

features
Sequence[torch.Tensor]

Tensors of shape [hidden] for the causal variant, or [sequence, hidden] for Omni, on the head device, one per example.

examples
Sequence[D1TextExample]

Publisher-encoded questions in the same order as features.

head
nn.Module

This variant’s trainable readout, or a frozen reference copy.

Returns: list[torch.Tensor]

List of float32 Tensors of shape [options], one per example in its

nemo_automodel.components.models.d1.text_readout._validate_feature_pairs(
features: collections.abc.Sequence[torch.Tensor],
) -> None

Reject missing feature slots before variant-specific scoring.

Parameters:

features
Sequence[torch.Tensor]

Tensors of shape [hidden] or [sequence, hidden], one per example.

examples
Sequence[D1TextExample]

Publisher-encoded questions in feature order.

nemo_automodel.components.models.d1.text_readout._validate_text_input(
input_ids: torch.Tensor,
attention_mask: torch.Tensor
) -> None

Require the single-question, unpadded frozen-feature boundary.

Parameters:

input_ids
torch.Tensor

Long Tensor of shape [1, sequence] with nonempty sequence.

attention_mask
torch.Tensor

Boolean Tensor of shape [1, sequence], all true, on the same device as input_ids.