dataset
CustomDataset
¶
Bases: Dataset
A custom dataset class that extends from datasets.Dataset
and is used to generate
an Argilla FeedbackDataset
instance from the pre-defined configuration within the task
provided to Pipeline.generate
.
Source code in src/distilabel/dataset.py
59 60 61 62 63 64 65 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 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
load_from_disk(dataset_path, **kwargs)
classmethod
¶
Load a CustomDataset from disk, also reading the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_path |
PathLike
|
Path to the dataset, as you would do with a standard Dataset. |
required |
Returns:
Type | Description |
---|---|
The loaded dataset. |
Source code in src/distilabel/dataset.py
push_to_hub(repo_id, *args, push_task=True, **kwargs)
¶
Same method as datasets.Dataset.push_to_hub
, but also pushes the task to simplify
creating a CustomDataset from HuggingFace hub.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
repo_id |
str
|
The ID of the repository to push to in the following format: |
required |
args |
Any
|
Additional arguments to be passed to |
()
|
push_task |
bool
|
description. Defaults to True. |
True
|
kwargs |
Any
|
Additional arguments to be passed to |
{}
|
Examples:
>>> from distilabel.dataset import CustomDataset
>>> dataset = CustomDataset(...)
>>> dataset.push_to_hub("path/to/dataset")
Source code in src/distilabel/dataset.py
save_to_disk(dataset_path, **kwargs)
¶
Saves the datataset to disk, also saving the task.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_path |
PathLike
|
Path to the dataset. |
required |
**kwargs |
Any
|
Additional arguments to be passed to |
{}
|
Source code in src/distilabel/dataset.py
to_argilla(dataset_columns=None, vector_strategy=True, metric_strategy=True)
¶
Converts the dataset to an Argilla FeedbackDataset
instance, based on the
task defined in the dataset as part of Pipeline.generate
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset_columns |
List[str]
|
the dataset columns or fields to be used for the Argilla |
None
|
vector_strategy |
Union[bool, SentenceTransformersExtractor]
|
the strategy to be used for
adding vectors to the dataset. If |
True
|
metrics_strategy |
Union[bool, TextDescriptivesExtractor]
|
the strategy to be used for
adding metrics to the dataset. If |
required |
Raises:
Type | Description |
---|---|
ImportError
|
if the argilla library is not installed. |
ValueError
|
if the task is not set. |
Returns:
Name | Type | Description |
---|---|---|
FeedbackDataset |
FeedbackDataset
|
the Argilla |
Source code in src/distilabel/dataset.py
DatasetCheckpoint
dataclass
¶
A checkpoint class that contains the information of a checkpoint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
The path to the checkpoint. |
cwd() / 'ckpt'
|
save_frequency |
int
|
The frequency at which the checkpoint should be saved By default is set to -1 (no checkpoint is saved to disk, but the dataset is returned upon failure). |
-1
|
extra_kwargs |
dict[str, Any]
|
Additional kwargs to be passed to the |
field(default_factory=dict)
|
Examples:
>>> from distilabel.dataset import DatasetCheckpoint
>>> # Save the dataset every 10% of the records generated.
>>> checkpoint = DatasetCheckpoint(save_frequency=len(dataset) // 10)
>>> # Afterwards, we can access the checkpoint's checkpoint.path.
Source code in src/distilabel/dataset.py
do_checkpoint(step)
¶
Determines if a checkpoint should be done.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
step |
int
|
The number of records generated. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
Whether a checkpoint should be done. |
Source code in src/distilabel/dataset.py
load_dataset(path, *args, **kwargs)
¶
Load a dataset from HuggingFace hub.
Overloads the datasets.load_dataset
method to return a CustomDataset
instance,
downloading the Task
from the hub (if any).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
Path to the dataset in the hub. |
required |
args, |
kwargs
|
and any other arguments used by |
required |
Returns:
Name | Type | Description |
---|---|---|
dataset |
Union[Dataset, CustomDataset]
|
CustomDataset instance, with the |
Examples:
>>> from distilabel.dataset import load_dataset
>>> dataset: CustomDataset = load_dataset("argilla/distilabel-sample-evol-instruct", split="train")