MCPcopy Create free account
hub / github.com/InternScience/SciReason / load

Method load

opencompass/datasets/mmlu.py:18–56  ·  view source on GitHub ↗
(path: str, name: str, **kwargs)

Source from the content-addressed store, hash-verified

16
17 @staticmethod
18 def load(path: str, name: str, **kwargs):
19 path = get_data_path(path)
20 dataset = DatasetDict()
21 if environ.get('DATASET_SOURCE') == 'ModelScope':
22 from modelscope import MsDataset
23 for split in ['dev', 'test']:
24 # 从 ModelScope 加载数据
25 ms_dataset = MsDataset.load(path,
26 subset_name=name,
27 split=split)
28 dataset_list = []
29 for line in ms_dataset:
30 dataset_list.append({
31 'input': line['question'],
32 'A': line['choices'][0],
33 'B': line['choices'][1],
34 'C': line['choices'][2],
35 'D': line['choices'][3],
36 'target': 'ABCD'[line['answer']],
37 })
38 dataset[split] = Dataset.from_list(dataset_list)
39 else:
40 for split in ['dev', 'test']:
41 raw_data = []
42 filename = osp.join(path, split, f'{name}_{split}.csv')
43 with open(filename, encoding='utf-8') as f:
44 reader = csv.reader(f)
45 for row in reader:
46 assert len(row) == 6
47 raw_data.append({
48 'input': row[0],
49 'A': row[1],
50 'B': row[2],
51 'C': row[3],
52 'D': row[4],
53 'target': row[5],
54 })
55 dataset[split] = Dataset.from_list(raw_data)
56 return dataset
57
58
59class MMLUDatasetClean(BaseDataset):

Callers 2

loadMethod · 0.45

Calls 3

get_data_pathFunction · 0.90
openFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected