Transforms
Functional API
functional
Functions:
-
preference_swap_transform–Swaps the 'chosen' and 'rejected' responses for each sample in the dataset.
-
split_transform–Splits a Dataset training data into train and test datasets.
preference_swap_transform
preference_swap_transform(
dataset: Dataset,
swap_probability: float,
in_place: bool = False,
) -> Dataset
Swaps the 'chosen' and 'rejected' responses for each sample in the dataset.
Parameters:
-
dataset(Union[ContinualAlignmentDataset, AlignmentDataset]) –The dataset to transform.
-
in_place(bool, default:False) –Whether to apply the transform in-place or return a new dataset.
-
swap_probability(float) –The independent probability of swapping responses for each sample in the dataset.
Returns:
-
Dataset–Union[ContinualAlignmentDataset, AlignmentDataset]: The transformed dataset.
Raises:
-
ValueError–If the swap probability is not in the range [0, 1].
Source code in aif_gen/transforms/functional.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
split_transform
Splits a Dataset training data into train and test datasets.
Parameters:
-
dataset(Union[ContinualAlignmentDataset, AlignmentDataset]) –The dataset to transform.
-
in_place(bool, default:False) –Whether to apply the transform in-place or return a new dataset.
-
test_ratio(float) –The test ratio to split the dataset with.
Returns:
-
Dataset–Union[ContinualAlignmentDataset, AlignmentDataset]: The transformed dataset.
Raises:
-
ValueError–If a dataset in the Continual Dataset has test data.
Source code in aif_gen/transforms/functional.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
Objected-Oriented API
base
Classes:
-
DatasetTransform–Base class for transforming Alignment Datasets.
DatasetTransform
Bases: ABC
Base class for transforming Alignment Datasets.
Methods:
-
apply–Apply the transform onto a dataset.
apply
abstractmethod
apply(dataset: Dataset, in_place: bool = False) -> Dataset
Apply the transform onto a dataset.
Parameters:
-
dataset(Union[ContinualAlignmentDataset, AlignmentDataset]) –The dataset to transform.
-
in_place(bool, default:False) –Whether to apply the transform in-place or return a new dataset.
Returns:
-
Dataset–Union[ContinualAlignmentDataset, AlignmentDataset]: The transformed dataset.
Source code in aif_gen/transforms/base.py
10 11 12 13 14 15 16 17 18 19 20 | |
preference_swap_transform
preference_swap_transform(
dataset: Dataset,
swap_probability: float,
in_place: bool = False,
) -> Dataset
Swaps the 'chosen' and 'rejected' responses for each sample in the dataset.
Parameters:
-
dataset(Union[ContinualAlignmentDataset, AlignmentDataset]) –The dataset to transform.
-
in_place(bool, default:False) –Whether to apply the transform in-place or return a new dataset.
-
swap_probability(float) –The independent probability of swapping responses for each sample in the dataset.
Returns:
-
Dataset–Union[ContinualAlignmentDataset, AlignmentDataset]: The transformed dataset.
Raises:
-
ValueError–If the swap probability is not in the range [0, 1].
Source code in aif_gen/transforms/functional.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
split_transform
Splits a Dataset training data into train and test datasets.
Parameters:
-
dataset(Union[ContinualAlignmentDataset, AlignmentDataset]) –The dataset to transform.
-
in_place(bool, default:False) –Whether to apply the transform in-place or return a new dataset.
-
test_ratio(float) –The test ratio to split the dataset with.
Returns:
-
Dataset–Union[ContinualAlignmentDataset, AlignmentDataset]: The transformed dataset.
Raises:
-
ValueError–If a dataset in the Continual Dataset has test data.
Source code in aif_gen/transforms/functional.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |