Text Datasets #
Causal language-model sample and dataset constructors.
Split exact (sequenceLength + 1) token windows into causal-LM input and target tensors.
For a window $[t_0,t_1,\ldots,t_{\mathrm{sequenceLength}}]$, the model input is $[t_0,\ldots,t_{\mathrm{sequenceLength}-1}]$ and the target is $[t_1,\ldots,t_{\mathrm{sequenceLength}}]$. Corpus readers perform any requested padding before constructing this tensor, so the split itself cannot invent or discard tokens.
Instances For
Build a one-hot causal-language-model sample over an arbitrary batch shape.
The input and target both append sequence and vocabulary axes to batchShape.
Instances For
Build an indexed-token causal-language-model batch from a tensor corpus.
The result contains the input and next-token target as separate bounded-index tensors. Validation happens once at this corpus boundary; model code therefore has no out-of-range token case.
Instances For
Build one unbatched one-hot causal-language-model sample from a text corpus string.
This takes one (sequenceLength + 1) byte window from the UTF-8 bytes of text and constructs
one-hot input/target matrices directly in the selected scalar type α.
Instances For
Build an indexed stream of causal-language-model samples from approximately evenly spaced byte windows.
Offsets are measured in UTF-8 bytes, matching byteSample. Short corpora remain total because
byteTokenWindow pads beyond the end, while windowCount = 0 returns an empty stream. Samples
are constructed on access. For supervised training, select α := Float and wrap the result with
Data.fromStream.
Instances For
Build one fixed-batch one-hot causal-language-model sample from a text corpus string by repeating the same text window across every batch row.