MCPcopy Create free account
hub / github.com/AIS-SNU/Smart-Infinity / RaceDataset

Class RaceDataset

DeepSpeedExample/tasks/race/data.py:19–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19class RaceDataset(Dataset):
20
21 def __init__(self, dataset_name, datapaths, tokenizer, max_seq_length,
22 max_qa_length=MAX_QA_LENGTH):
23
24 self.dataset_name = dataset_name
25 print_rank_0(' > building RACE dataset for {}:'.format(
26 self.dataset_name))
27
28 string = ' > paths:'
29 for path in datapaths:
30 string += ' ' + path
31 print_rank_0(string)
32
33 self.samples = []
34 for datapath in datapaths:
35 self.samples.extend(process_single_datapath(datapath, tokenizer,
36 max_qa_length,
37 max_seq_length))
38
39 print_rank_0(' >> total number of samples: {}'.format(
40 len(self.samples)))
41
42 def __len__(self):
43 return len(self.samples)
44
45 def __getitem__(self, idx):
46 return self.samples[idx]
47
48
49def process_single_datapath(datapath, tokenizer, max_qa_length, max_seq_length):

Callers 2

single_dataset_providerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected