2024-04-26 15:42:00 +08:00
|
|
|
import json
|
|
|
|
import os.path as osp
|
|
|
|
|
|
|
|
from datasets import Dataset, DatasetDict
|
|
|
|
|
|
|
|
from opencompass.registry import LOAD_DATASET
|
2024-08-06 01:35:20 +08:00
|
|
|
from opencompass.utils import get_data_path
|
2024-04-26 15:42:00 +08:00
|
|
|
|
|
|
|
from ..base import BaseDataset
|
|
|
|
|
|
|
|
|
|
|
|
@LOAD_DATASET.register_module()
|
|
|
|
class ArenaHardDataset(BaseDataset):
|
|
|
|
|
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)
|
2024-04-26 15:42:00 +08:00
|
|
|
filename = osp.join(path, f'{name}.jsonl')
|
|
|
|
dataset = DatasetDict()
|
|
|
|
raw_data = []
|
|
|
|
with open(filename, 'r', encoding='utf-8') as file:
|
|
|
|
for line in file:
|
|
|
|
problem = json.loads(line)
|
|
|
|
question_id = problem['question_id']
|
|
|
|
cluster = problem['cluster']
|
|
|
|
question = problem['turns'][0][
|
|
|
|
'content'] # only one turn in arena_hard
|
|
|
|
raw_data.append({
|
|
|
|
'question': question,
|
|
|
|
'capability': cluster,
|
|
|
|
'judge': {
|
|
|
|
'capability': cluster,
|
|
|
|
'question': question,
|
|
|
|
'question_id': question_id
|
|
|
|
}
|
|
|
|
})
|
|
|
|
dataset = Dataset.from_list(raw_data)
|
|
|
|
return dataset
|