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

Method load

opencompass/datasets/LCBench.py:25–63  ·  view source on GitHub ↗

Load LC dataset for pass k mode. Note that you can use num_repeats > 1 when your model does not support `num_return_sequence` in generation, otherwise use the raw LC dataset and set `num_return_sequence` in model config to generate multiple responses for testing pass

(path: str,
             num_repeats: int = 1,
             difficulty='ALL',
             local_mode=False)

Source from the content-addressed store, hash-verified

23
24 @staticmethod
25 def load(path: str,
26 num_repeats: int = 1,
27 difficulty='ALL',
28 local_mode=False):
29 """Load LC dataset for pass k mode.
30
31 Note that you can use num_repeats > 1 when your model does not support
32 `num_return_sequence` in generation, otherwise use the raw
33 LC dataset and set `num_return_sequence` in model config to
34 generate multiple responses for testing pass@k>1.
35
36 It better to change your dataset abbr correspondingly if you want to
37 change num_repeats>1, otherwise the number in
38 `.cache/dataset_size.json` might be inconsistent.
39
40 Args:
41 num_repeats(int): Number of repetition for this dataset to get
42 multiple responses in special cases.
43 """
44 path = get_data_path(path, local_mode=local_mode)
45
46 def processing_test(example):
47 example['test_case'] = example['test_list']
48 example['test_list'] = '\n'.join(example['test_list'])
49 example['test_column'] = dict(test_list_2=example['test_list'],
50 task_id=example['Contest id'])
51 return example
52
53 train = load_dataset('json', data_files=path,
54 split='train[:5]').map(processing_test)
55 test = load_dataset('json', data_files=path,
56 split='train[5:]').map(processing_test)
57 if not difficulty == 'ALL':
58 train = train.filter(
59 lambda example: example['Difficulty'] == difficulty)
60 test = test.filter(
61 lambda example: example['Difficulty'] == difficulty)
62 test = concatenate_datasets([test] * num_repeats)
63 return DatasetDict({'train': train, 'test': test})
64
65
66class TimeOutException(Exception):

Callers

nothing calls this directly

Calls 3

get_data_pathFunction · 0.90
load_datasetFunction · 0.90
filterMethod · 0.80

Tested by

no test coverage detected