Skip to content

base

PreferenceTask dataclass

Bases: RatingToArgillaMixin, Task

A Task for preference rating tasks.

Parameters:

Name Type Description Default
system_prompt str

the system prompt to be used for generation.

required
task_description Union[str, None]

the description of the task. Defaults to None.

None
Source code in src/distilabel/tasks/preference/base.py
@dataclass
class PreferenceTask(RatingToArgillaMixin, Task):
    """A `Task` for preference rating tasks.

    Args:
        system_prompt (str): the system prompt to be used for generation.
        task_description (Union[str, None], optional): the description of the task. Defaults to `None`.
    """

    __type__: ClassVar[Literal["labelling"]] = "labelling"

    @property
    def input_args_names(self) -> List[str]:
        """Returns the names of the input arguments of the task."""
        return ["input", "generations"]

    @property
    def output_args_names(self) -> List[str]:
        """Returns the names of the output arguments of the task."""
        return ["rating", "rationale"]

input_args_names: List[str] property

Returns the names of the input arguments of the task.

output_args_names: List[str] property

Returns the names of the output arguments of the task.

PreferenceTaskNoRationale dataclass

Bases: PreferenceTask

A Task for preference rating tasks, that only returns the rating, without the rationale.

Parameters:

Name Type Description Default
system_prompt str

the system prompt to be used for generation.

required
task_description Union[str, None]

the description of the task. Defaults to None.

None
Source code in src/distilabel/tasks/preference/base.py
@dataclass
class PreferenceTaskNoRationale(PreferenceTask):
    """A `Task` for preference rating tasks, that only returns the rating, without the rationale.

    Args:
        system_prompt (str): the system prompt to be used for generation.
        task_description (Union[str, None], optional): the description of the task. Defaults to `None`.
    """

    @property
    def output_args_names(self) -> List[str]:
        """Returns the names of the output arguments of the task."""
        return ["rating"]

    def to_argilla_dataset(
        self,
        dataset_row: Dict[str, Any],
        generations_column: str = "generations",
        ratings_column: str = "rating",
        ratings_values: Optional[List[int]] = None,
    ):
        """Same definition from the parent class, but removing the rationale column."""
        return super().to_argilla_dataset(
            dataset_row,
            generations_column=generations_column,
            ratings_column=ratings_column,
            rationale_column=None,
            ratings_values=ratings_values,
        )

    def to_argilla_record(  # noqa: C901
        self,
        dataset_row: Dict[str, Any],
        generations_column: str = "generations",
        ratings_column: str = "rating",
        ratings_values: Optional[List[int]] = None,
    ):
        """Same definition from the parent class, but removing the rationale column."""
        return super().to_argilla_record(
            dataset_row,
            generations_column=generations_column,
            ratings_column=ratings_column,
            rationale_column=None,
            ratings_values=ratings_values,
        )

output_args_names: List[str] property

Returns the names of the output arguments of the task.

to_argilla_dataset(dataset_row, generations_column='generations', ratings_column='rating', ratings_values=None)

Same definition from the parent class, but removing the rationale column.

Source code in src/distilabel/tasks/preference/base.py
def to_argilla_dataset(
    self,
    dataset_row: Dict[str, Any],
    generations_column: str = "generations",
    ratings_column: str = "rating",
    ratings_values: Optional[List[int]] = None,
):
    """Same definition from the parent class, but removing the rationale column."""
    return super().to_argilla_dataset(
        dataset_row,
        generations_column=generations_column,
        ratings_column=ratings_column,
        rationale_column=None,
        ratings_values=ratings_values,
    )

to_argilla_record(dataset_row, generations_column='generations', ratings_column='rating', ratings_values=None)

Same definition from the parent class, but removing the rationale column.

Source code in src/distilabel/tasks/preference/base.py
def to_argilla_record(  # noqa: C901
    self,
    dataset_row: Dict[str, Any],
    generations_column: str = "generations",
    ratings_column: str = "rating",
    ratings_values: Optional[List[int]] = None,
):
    """Same definition from the parent class, but removing the rationale column."""
    return super().to_argilla_record(
        dataset_row,
        generations_column=generations_column,
        ratings_column=ratings_column,
        rationale_column=None,
        ratings_values=ratings_values,
    )