nemo_automodel.components.datasets.zephon.llm
nemo_automodel.components.datasets.zephon.llm
Text tokenizer IDs and pretokenized-document validation.
Module Contents
Classes
Functions
API
Resolved existing vocabulary IDs; no tokens are added to the model.
Validate tokens and supervision without allocating the delivered payload.
valid_token_ids is a sorted int64 vocabulary array constructed once per
pipeline. Exact vectorized membership preserves holes in tokenizer IDs.
Count supplied token IDs for mixture calibration, including masked tokens.
Calibration reads the raw document before field normalization, so it needs the configured token field. There is no tokenizer or filtering to replay; delivery validates the payload and preserves the token count.
Parameters:
Raw document containing token IDs of shape [tokens].
Field holding the unshifted token IDs.
Returns: int
Number of supplied tokens, independent of their loss-mask values.
Adapt pretokenized fields while preserving IDs and supplied supervision.
Uniform loss-mask fields keep supervision aligned when masked and unmasked documents are packed together. Short and fully masked documents are retained; document-boundary masking belongs to to_training’s mask_segment_starts option.
Parameters:
Document with token IDs of shape [tokens] and an
optional binary loss mask of shape [tokens], both before shifting.
Offline packs may include zero-based reset positions [tokens].
Source field names; absent loss masks select all tokens.
Sorted vocabulary IDs of shape [vocab].
Accept offline boundaries when online packing is off.
Returns: dict[str, np.ndarray]
int64 input_ids and uint8 loss_mask arrays, each of shape [tokens].
Supply boundaries when packing is off, without guessing from token values.
to_training needs scalar reset positions to derive document IDs and boundary loss masks. Offline exports can supply those positions; absent metadata means exactly one document, even when the tokens contain multiple EOS markers.
Parameters:
Tokenized document with input_ids [tokens], optional aligned loss_mask [tokens], and optional validated positions [tokens].
Unshifted token budget, including the final prediction target.
Returns: dict[str, Any]
The input mapping when it already has positions, otherwise a new mapping
Raises:
ValueError: When the document exceeds the configured input/target budget.
Resolve PAD/BOS/EOS using the effective AutoModel tokenizer.
Honor the declared tokenizer padding ID or a compatible explicit override. Otherwise prefer a named padding token, a reserved special token, UNK, then EOS. Reusing an existing ID avoids resizing model embeddings; preferring a non-EOS ID keeps padding distinct from document ends when possible. Padding is masked by position, including when PAD equals EOS.