2023-12-11 22:22:11 +08:00
|
|
|
import json
|
2023-10-13 19:50:54 +08:00
|
|
|
import os.path as osp
|
|
|
|
|
2023-12-11 22:22:11 +08:00
|
|
|
from datasets import Dataset, DatasetDict
|
2023-10-13 19:50:54 +08:00
|
|
|
|
|
|
|
from opencompass.registry import LOAD_DATASET
|
2024-08-06 01:35:20 +08:00
|
|
|
from opencompass.utils import get_data_path
|
2023-10-13 19:50:54 +08:00
|
|
|
|
2024-01-16 18:03:11 +08:00
|
|
|
from ..base import BaseDataset
|
2023-10-13 19:50:54 +08:00
|
|
|
|
|
|
|
|
|
|
|
@LOAD_DATASET.register_module()
|
2023-10-27 16:27:24 +08:00
|
|
|
class SubjectiveCmpDataset(BaseDataset):
|
2023-10-13 19:50:54 +08:00
|
|
|
|
2024-07-05 22:11:37 +08:00
|
|
|
def load(self, path: str, name: str, *args, **kwargs):
|
2024-08-06 01:35:20 +08:00
|
|
|
path = get_data_path(path, local_mode=True)
|
2023-12-11 22:22:11 +08:00
|
|
|
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,
|
2023-12-13 19:59:30 +08:00
|
|
|
'capability': capability,
|
2023-12-11 22:22:11 +08:00
|
|
|
'others': others,
|
|
|
|
'judge': {
|
2024-01-23 15:12:46 +08:00
|
|
|
'capability': capability,
|
|
|
|
'question': question
|
2023-12-11 22:22:11 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
dataset = Dataset.from_list(raw_data)
|
|
|
|
return dataset
|