in cookbook-efforts/dpo-orpo-preference/custom_preference_to_argilla.py [0:0]
def process(self, inputs: StepInput) -> "StepOutput": # type: ignore
records = []
for input in inputs:
# Generate the SHA-256 hash of the instruction to use it as the metadata
instruction_id = hashlib.sha256(
input["instruction"].encode("utf-8") # type: ignore
).hexdigest()
generations = {
f"{self._generations}-{idx}": generation
for idx, generation in enumerate(input["generations"]) # type: ignore
}
records.append( # type: ignore
rg.FeedbackRecord( # type: ignore
fields={
"id": instruction_id,
"instruction": input["instruction"], # type: ignore
**generations,
},
suggestions=self._add_suggestions_if_any(input), # type: ignore
metadata={
metadata_property["name"]: input[metadata_property["name"]]
for metadata_property in self.metadata_properties
if metadata_property["name"] in input
},
)
)
self._rg_dataset.add_records(records) # type: ignore
yield inputs