Generic text dataset using MosaicML's StreamingDataset. Args: tokenizer (Tokenizer): HuggingFace tokenizer to tokenize samples. max_seq_len (int): The max sequence length of each sample. streams (Sequence[Stream], optional): One or more Streams to stream/cach
| 97 | |
| 98 | |
| 99 | class StreamingTextDataset(StreamingDataset): |
| 100 | """Generic text dataset using MosaicML's StreamingDataset. |
| 101 | |
| 102 | Args: |
| 103 | tokenizer (Tokenizer): HuggingFace tokenizer to |
| 104 | tokenize samples. |
| 105 | max_seq_len (int): The max sequence length of each sample. |
| 106 | streams (Sequence[Stream], optional): One or more Streams to stream/cache samples from, |
| 107 | which may be upsampled or downsampled. StreamingDataset uses either ``streams`` or |
| 108 | ``remote``/``local``. Defaults to ``None``. |
| 109 | remote (str, optional): Remote path or directory to download the dataset from. If ``None``, |
| 110 | its data must exist locally. StreamingDataset uses either ``streams`` or |
| 111 | ``remote``/``local``. Defaults to ``None``. |
| 112 | local (str, optional): Local working directory to download shards to. This is where shards |
| 113 | are cached while they are being used. Uses a temp directory if not set. |
| 114 | StreamingDataset uses either ``streams`` or ``remote``/``local``. Defaults to ``None``. |
| 115 | split (str, optional): Which dataset split to use, if any. If provided, we stream from/to |
| 116 | the ``split`` subdirs of ``remote`` and ``local``. Defaults to ``None``. |
| 117 | download_retry (int): Number of download re-attempts before giving up. Defaults to ``2``. |
| 118 | download_timeout (float): Number of seconds to wait for a shard to download before raising |
| 119 | an exception. Defaults to ``60``. |
| 120 | validate_hash (str, optional): Optional hash or checksum algorithm to use to validate |
| 121 | shards. Defaults to ``None``. |
| 122 | keep_zip (bool): Whether to keep or delete the compressed form when decompressing |
| 123 | downloaded shards. If ``False``, keep iff remote is local or no remote. Defaults to |
| 124 | `False``. |
| 125 | epoch_size (int, optional): Provide this field iff you are weighting sub-datasets |
| 126 | proportionally. Defaults to ``None``. |
| 127 | predownload (int, optional): Target number of samples ahead to download the shards of while |
| 128 | iterating. Defaults to ``100_000``. |
| 129 | partition_algo (str): Which partitioning algorithm to use. Defaults to ``orig``. |
| 130 | num_canonical_nodes (int, optional): Canonical number of nodes for shuffling with |
| 131 | resumption. Defaults to ``None``, which is interpreted as the number of nodes of the |
| 132 | initial run. |
| 133 | batch_size (int, optional): Batch size of its DataLoader, which affects how the dataset is |
| 134 | partitioned over the workers. Defaults to ``None``. |
| 135 | shuffle (bool): Whether to iterate over the samples in randomized order. Defaults to |
| 136 | ``False``. |
| 137 | shuffle_algo (str): Which shuffling algorithm to use. Defaults to ``py1s``. |
| 138 | shuffle_seed (int): Seed for Deterministic data shuffling. Defaults to ``9176``. |
| 139 | """ |
| 140 | |
| 141 | def __init__( |
| 142 | self, |
| 143 | tokenizer: Tokenizer, |
| 144 | max_seq_len: int, |
| 145 | streams: Optional[Sequence[Stream]] = None, |
| 146 | remote: Optional[str] = None, |
| 147 | local: Optional[str] = None, |
| 148 | split: Optional[str] = None, |
| 149 | download_retry: int = 2, |
| 150 | download_timeout: float = 60, |
| 151 | validate_hash: Optional[str] = None, |
| 152 | keep_zip: bool = False, |
| 153 | epoch_size: Optional[int] = None, |
| 154 | predownload: int = 100_000, |
| 155 | partition_algo: str = "orig", |
| 156 | num_canonical_nodes: Optional[int] = None, |
no outgoing calls
no test coverage detected