MCPcopy Create free account
hub / github.com/OpenBitSys/BitDistiller / extract_random_dataset

Function extract_random_dataset

data/generation/data_utils.py:81–95  ·  view source on GitHub ↗
(sources, targets, max_sample=None)

Source from the content-addressed store, hash-verified

79 raise ValueError(f"{dataset_name} not implement yet")
80
81def extract_random_dataset(sources, targets, max_sample=None):
82 if max_sample is not None:
83 if max_sample <= len(sources):
84 print(f"only use {max_sample} samples")
85 random_indices = random.sample(range(len(sources)), max_sample)
86 sources = [sources[i] for i in random_indices]
87 targets = [targets[i] for i in random_indices]
88 else:
89 print("max_sample exceeds the length of the array. Using the entire array.")
90 sources = sources
91 targets = targets
92 else:
93 print(f"using the whole {len(sources)} samples")
94
95 return sources, targets
96
97def get_wiki_dataset(max_sample):
98 wiki_dataset = load_dataset("wikitext", 'wikitext-2-raw-v1', split='train')

Callers 8

get_wiki_datasetFunction · 0.85
get_redpajama_datasetFunction · 0.85
get_alpaca_datasetFunction · 0.85
get_alpaca_solar_datasetFunction · 0.85
get_ultra_solar_datasetFunction · 0.85
get_code_datasetFunction · 0.85
get_math_datasetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected