File size: 1,706 Bytes
256a159 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
from datasets import load_dataset
from .base import BaseDataset
class AiRiskDataset(BaseDataset):
@staticmethod
def load(path: str):
"""Load dataset."""
dataset = load_dataset('json', data_files=path)
def choices_process(example):
# the original answer format is ` (A)`, etc.
for i in 'ABCDEFGH':
if i in example['answer_matching_behavior']:
example['answer_matching_behavior'] = i
break
return example
dataset = dataset.map(choices_process)
return dataset
class PersonaDataset(BaseDataset):
@staticmethod
def load(path: str):
"""Load dataset."""
dataset = load_dataset('json', data_files=path)
def choices_process(example):
# the original answer format is ` No` or ` Yes`.
if example['answer_matching_behavior'] == ' Yes':
example['answer_matching_behavior'] = 'A'
else:
example['answer_matching_behavior'] = 'B'
return example
dataset = dataset.map(choices_process)
return dataset
class SycophancyDataset(BaseDataset):
@staticmethod
def load(path: str):
"""Load dataset."""
dataset = load_dataset('json', data_files=path)
def choices_process(example):
# the original answer format is ` (A)`, etc.
for i in 'ABCDEFG':
if i in example['answer_matching_behavior']:
example['answer_matching_behavior'] = i
break
return example
dataset = dataset.map(choices_process)
return dataset
|