Skip to navigation

nemo_automodel.components.models.clm.prompting

View as Markdown

CLM prompt layout: how a SystemOne record becomes state texts and candidate texts.

This mirrors clm.schema from the contrastive-lm package (Apache-2.0) exactly, because the released CLM heads were trained on this layout: the state head sees context + question, the action head sees each option’s own text.

Module Contents

Functions

NameDescription
clm_candidates(option ids in CLM order, candidate text per option) for one question.
clm_pairs{question_id: (state_text, option_ids, candidate_texts)} for every question of a record.
clm_state_textContext first, question last: the layout CLM’s state head was trained on.
prepare_tokenizerLoad the tokenizer with the publisher’s CLM serving input contract.
to_textRender a JSON value as prose: objects become key: value lines, arrays become - item lines.

Data

CLM_NOUL_KEYS

API

nemo_automodel.components.models.clm.prompting.clm_candidates(
question: dict[str, typing.Any]
) -> tuple[list[str], list[str]]

(option ids in CLM order, candidate text per option) for one question.

nemo_automodel.components.models.clm.prompting.clm_pairs(
record: dict[str, typing.Any]
) -> dict[str, tuple[str, list[str], list[str]]]

{question_id: (state_text, option_ids, candidate_texts)} for every question of a record.

nemo_automodel.components.models.clm.prompting.clm_state_text(
state: typing.Any,
instructions: typing.Any
) -> str

Context first, question last: the layout CLM’s state head was trained on.

nemo_automodel.components.models.clm.prompting.prepare_tokenizer(
name_or_path: str,
revision: str | None
) -> transformers.PreTrainedTokenizerBase

Load the tokenizer with the publisher’s CLM serving input contract.

Parameters:

name_or_path
str

Tokenizer repository ID or local directory.

revision
str | None

Tokenizer revision recorded in the frozen-feature cache identity.

Returns: PreTrainedTokenizerBase

Tokenizer using right padding and left truncation, retaining the final

nemo_automodel.components.models.clm.prompting.to_text(
x: typing.Any,
indent: int = 0
) -> str

Render a JSON value as prose: objects become key: value lines, arrays become - item lines.

nemo_automodel.components.models.clm.prompting.CLM_NOUL_KEYS = ('false', 'true')