Generator Steps¶
LoadDataFromDicts
¶
Bases: GeneratorStep
A generator step that loads a dataset from a list of dictionaries.
This step will load the dataset and yield the transformed data as it is loaded from the list of dictionaries.
Attributes:
Name | Type | Description |
---|---|---|
data |
List[Dict[str, Any]]
|
The list of dictionaries to load the data from. |
Runtime parameters
batch_size
: The batch size to use when processing the data.
Output columns
Dynamic, based on the keys found on the first dictionary of the list
Source code in src/distilabel/steps/generators/data.py
outputs: List[str]
property
¶
Returns a list of strings with the names of the columns that the step will generate.
process(offset=0)
¶
Yields batches from a list of dictionaries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset |
int
|
The offset to start the generation from. Defaults to |
0
|
Yields:
Type | Description |
---|---|
GeneratorStepOutput
|
A list of Python dictionaries as read from the inputs (propagated in batches) |
GeneratorStepOutput
|
and a flag indicating whether the yield batch is the last one. |
Source code in src/distilabel/steps/generators/data.py
LoadHubDataset
¶
Bases: GeneratorStep
A generator step that loads a dataset from the Hugging Face Hub using the datasets
library.
This step will load the dataset in streaming mode, which means that it will not load the entire dataset into memory at once. Instead, it will load the dataset in chunks and yield the transformed data as it is loaded from the Hugging Face Hub.
Attributes:
Name | Type | Description |
---|---|---|
repo_id |
RuntimeParameter[str]
|
The Hugging Face Hub repository ID of the dataset to load. |
split |
RuntimeParameter[str]
|
The split of the dataset to load. |
config |
Optional[RuntimeParameter[str]]
|
The configuration of the dataset to load. This is optional and only needed if the dataset has multiple configurations. |
Runtime parameters
batch_size
: The batch size to use when processing the data.repo_id
: The Hugging Face Hub repository ID of the dataset to load.split
: The split of the dataset to load. Defaults to 'train'.config
: The configuration of the dataset to load. This is optional and only needed if the dataset has multiple configurations.
Output columns - dynamic, based on the dataset being loaded
Source code in src/distilabel/steps/generators/huggingface.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
outputs: List[str]
property
¶
The columns that will be generated by this step, based on the datasets loaded from the Hugging Face Hub.
Returns:
Type | Description |
---|---|
List[str]
|
The columns that will be generated by this step. |
load()
¶
Load the dataset from the Hugging Face Hub
process(offset=0)
¶
Yields batches from the loaded dataset from the Hugging Face Hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset |
int
|
The offset to start yielding the data from. Will be used during the caching process to help skipping already processed data. |
0
|
Yields:
Type | Description |
---|---|
GeneratorStepOutput
|
A tuple containing a batch of rows and a boolean indicating if the batch is |
GeneratorStepOutput
|
the last one. |