nemo_automodel.components.datasets.mockable
nemo_automodel.components.datasets.mockable
Datasets, and their configs, that can serve mock token ids in place of their data.
Module Contents
Classes
Data
API
The token ids of the samples of a mock MockableDataset, which walk a vocabulary in order.
The walk is k, k + 1, k + 2, ... over the vocabulary, wrapping around at its end. samples[i] is the
length ids that follow the first i * length ids of the walk, so reading a sample costs one slice and no
random numbers. len(samples) is the number of samples of a map-style dataset.
Return the int64 token ids of sample index, as a read-only view.
Raises:
IndexError: Ifindexis outside a map-style dataset’snum_samples(counted from the end when negative), so that iterating the dataset ends.
Bases: Dataset[_SampleT]
Base of datasets that can serve mock token ids instead of reading their data.
mocked builds a dataset without running its data-loading __init__. Each subclass’s data methods
check is_mock and serve mock_samples through their own mock implementation when it is true.
Whether the dataset serves mock_samples instead of its data.
The token ids of the mock samples, set when the dataset is built with mocked.
Return a mock of this dataset without running its data-loading __init__.
Base of dataset configs whose dataset can serve mock token ids instead of reading its data.
Subclassing it gives a dataset config the mock switch. With mock: true the dataset keeps what its config
describes (sequence length, sample fields and dtypes, number of samples, …) but takes its token ids from
MockSamples instead of its files, so a recipe runs without its data and without preprocessing, for
example to benchmark it. With mock set, each subclass’s build returns its dataset’s
MockableDataset.mocked of mock_samples.
Serve mock token ids instead of reading the dataset’s files.
Mock token ids are below this; defaults to the tokenizer’s vocabulary size.
Return the samples a mock of this dataset serves.
Their token ids walk the vocabulary without its special tokens, which keeps padding and document boundaries out of the mock samples, so every position is trained on.
Parameters:
Runtime tokenizer of the recipe, or None when the recipe has none.
Token ids per sample.
Number of samples of a map-style dataset; None for an endless stream.
Raises:
ValueError: If neithermock_vocab_sizenortokenizergives the vocabulary size.