Description :
This dataset from https://huggingface.co/datasets/OpenAssistant/oasst1
code: I just keep 'text' and labels then and do this preprocessing
HARD_NEGATIVE = [
"spam",
'fails_task',
"lang_mismatch",
"pii",
"not_appropriate",
"hate_speech",
"sexual_content",
"violence",
"helpfulness"
]
Quality_scores = ["quality","toxicity"]
def get_reward(exemple):
neg_dict, qual_dict = {}, {}
# print(exemple)
if exemple['labels'] is None:
return {"reward": 0}
for name,value in zip(exemple['labels']['name'],exemple['labels']['value']):
-if name in HARD_NEGATIVE:
neg_dict[name] = value
elif name in Quality_scores:
qual_dict[name] = value
else:
pass
quality = qual_dict.get("quality", 0.0)
toxicity = qual_dict.get("toxicity", 0.0)
quality_score = (
1.0 * quality
- 0.7 * toxicity
)
unsafe = int(any(neg_dict.get(label, 0) == 1 for …