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

Method load

opencompass/datasets/inference_ppl.py:16–39  ·  view source on GitHub ↗
(path: str, name: List[str] = None, samples: int = None)

Source from the content-addressed store, hash-verified

14
15 @staticmethod
16 def load(path: str, name: List[str] = None, samples: int = None):
17 path = get_data_path(path, local_mode=True)
18
19 # Check if file exists in the given path
20 supported_extensions = ['jsonl']
21 for ext in supported_extensions:
22 filename = osp.join(
23 path, f'{name}.{ext}') # name refers to data subset name
24
25 if osp.exists(filename):
26 break
27 else:
28 raise FileNotFoundError(f'{filename} not found.')
29
30 samples = 'test' if samples is None else f'test[:{samples}]'
31
32 data_files = {'test': filename}
33
34 dataset = load_dataset('json', data_files=data_files, split=samples)
35
36 # Filter out empty samples
37 dataset = dataset.filter(lambda example: len(example['text']) > 0)
38
39 return dataset

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