Skip to content

Commit

Permalink
Fix None issues for to_argilla method (#114)
Browse files Browse the repository at this point in the history
* Rename self_instruct_.py to self_instruct.py

* Add SelfInstructTask to init

* Fix dataclass issues selfinstruct

* Add simple example instruction gen

* Improve example

* Fix issue with none rationale

* Fix issues with Nones for to_argilla
  • Loading branch information
dvsrepo authored Nov 23, 2023
1 parent 455c43b commit 698f379
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/distilabel/tasks/preference/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
AllowedQuestionTypes,
)


@dataclass
class PreferenceTask(Task):
"""A `Task` for preference rating tasks.
Expand Down Expand Up @@ -130,26 +129,30 @@ def to_argilla_record( # noqa: C901
suggestions = []

# add rationale
suggestions.append(
{
"question_name": "ratings-rationale",
"value": self._to_argilla_rationale(dataset_row),
}
)
if self._to_argilla_rationale(dataset_row) is not None:
suggestions.append(
{
"question_name": "ratings-rationale",
"value": self._to_argilla_rationale(dataset_row),
}
)
for output_arg_name in self.output_args_names:
if output_arg_name == "rating":
ratings = []
output_data = dataset_row.get(output_arg_name)
if output_data is not None:
for idx, value in enumerate(output_data, start=1):
ratings.append(value)
# add suggestions
suggestions.append(
{
"question_name": f"generations-{idx}-rating",
"value": int(value),
}
)
if value <=0:
value = 1.0
if value <= 10:
# add suggestions
suggestions.append(
{
"question_name": f"generations-{idx}-rating",
"value": int(value),
}
)
# update rating metadata
metadata.update({f"rating-generations-{idx}": value})
if len(ratings) >= 2:
Expand Down

0 comments on commit 698f379

Please sign in to comment.