-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdclm_download.py
43 lines (34 loc) · 1.32 KB
/
dclm_download.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#
# For licensing see accompanying LICENSE file.
# Copyright (C) 2024 Apple Inc. All Rights Reserved.
#
import argparse
import os
from datasets import load_dataset
from tqdm import tqdm
def main(output_dir: str, num_shards: int = 128) -> None:
"""Downloads a small subset of the DCLM-Baseline dataset.
:param output_dir: The path to the output directory where the downloaded files will be saved.
:param num_shards: The number of JSONL files to divide the downloaded data into.
:return: None
"""
os.makedirs(output_dir, exist_ok=True)
# Download a small fraction of DCLM-Baseline dataset
data = load_dataset("mlfoundations/dclm-baseline-1.0",
data_dir="global-shard_01_of_10/local-shard_0_of_10")
for split, dataset in data.items():
for i in tqdm(range(num_shards)):
dataset_shard = dataset.shard(
num_shards=num_shards, index=i, contiguous=True)
output_file = os.path.join(output_dir, f"dclm_{split}_{i}.jsonl")
dataset_shard.to_json(output_file)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
"--output-dir",
type=str,
required=True,
help="Where to store the DCLM subset .jsonl files.",
)
args = parser.parse_args()
main(args.output_dir)