OpenCompass/opencompass/datasets/subjective/subjective_cmp.py

35 lines
1.0 KiB
Python
Raw Normal View History

import json
2023-10-13 19:50:54 +08:00
import os.path as osp
from datasets import Dataset, DatasetDict
2023-10-13 19:50:54 +08:00
from opencompass.registry import LOAD_DATASET
2024-01-16 18:03:11 +08:00
from ..base import BaseDataset
2023-10-13 19:50:54 +08:00
@LOAD_DATASET.register_module()
class SubjectiveCmpDataset(BaseDataset):
2023-10-13 19:50:54 +08:00
def load(self, path: str, name: str):
filename = osp.join(path, f'{name}.json')
dataset = DatasetDict()
raw_data = []
with open(filename, 'r', encoding='utf-8') as f:
json_data = json.load(f)
for problem in json_data:
question = problem['question']
capability = problem['capability']
others = problem['others']
raw_data.append({
'question': question,
'capability': capability,
'others': others,
'judge': {
'capability': capability,
'question': question
}
})
dataset = Dataset.from_list(raw_data)
return dataset