Skip to navigation

nemo_automodel.components.models.nemotron_decision.records

View as MarkdownOpen in Claude

SystemOne records for Nemotron Decision post-training: one-question encoding and one-decision JSONL conversion.

The recipe reads SystemOne records ({"id", "state", "questions", "answers"} plus optional rewards, soft_labels and meta) and reads every question of a record through its own serving prompt. Simple one-decision-per-line JSONL (state, question, type, options, label, optional soft_labels and group) converts to single-question records, with group kept in meta for group-disjoint splits.

Module Contents

Functions

NameDescription
convert_simple_lineConvert one simple decision line into a single-question SystemOne record.
encode_questionEncode one question of a record as its decision prompt, or None if this model cannot read it.
has_mediaTrue for records with images or videos (top-level, or state.image): never read as text decisions.
in_heldoutDeterministic group-disjoint split: hash of seed|meta.group (or the state) below fraction.
normalize_labelNormalize a gold/soft label key (noul labels are lower-case true/false).
read_jsonlRead one JSON value per \n-terminated line (not str.splitlines: U+2028 is legal inside JSON strings).
write_jsonlWrite rows as UTF-8 JSONL, creating parent directories.

Data

NOUL_ALIASES

SIMPLE_QUESTION_ID

API

nemo_automodel.components.models.nemotron_decision.records.convert_simple_line(
line: dict[str, typing.Any],
number: int = 0
) -> dict[str, typing.Any]

Convert one simple decision line into a single-question SystemOne record.

Parameters:

line
dict[str, Any]

{"state", "question", "label"} plus optional id, type (default choice), options, soft_labels and group.

number
intDefaults to 0

Line number, used for the record ID when the line has none.

Returns: dict[str, Any]

A record whose only question is "decision". Soft labels are normalized over all options, and group

Raises:

  • ValueError: If a field is missing or the label/options are inconsistent.
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.records.has_media(
record: dict[str, typing.Any]
) -> bool

True for records with images or videos (top-level, or state.image): never read as text decisions.

nemo_automodel.components.models.nemotron_decision.records.in_heldout(
record: dict[str, typing.Any],
fraction: float,
seed: str | int
) -> bool

Deterministic group-disjoint split: hash of seed|meta.group (or the state) below fraction.

nemo_automodel.components.models.nemotron_decision.records.normalize_label(
kind: str,
label: typing.Any
) -> str

Normalize a gold/soft label key (noul labels are lower-case true/false).

nemo_automodel.components.models.nemotron_decision.records.read_jsonl(
path: str | pathlib.Path
) -> list[dict[str, typing.Any]]

Read one JSON value per \n-terminated line (not str.splitlines: U+2028 is legal inside JSON strings).

nemo_automodel.components.models.nemotron_decision.records.write_jsonl(
path: str | pathlib.Path,
rows: typing.Iterable[dict[str, typing.Any]]
) -> None

Write rows as UTF-8 JSONL, creating parent directories.

nemo_automodel.components.models.nemotron_decision.records.NOUL_ALIASES = {'true': 'true', 'yes': 'true', '1': 'true', 'false': 'false', 'no': 'false', '0...
nemo_automodel.components.models.nemotron_decision.records.SIMPLE_QUESTION_ID = 'decision'