File size: 727 Bytes
9605203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python

# generate jsonl version of dataset that can be fed to megatron-lm preprocessor
#
# full dataset
# ./openwebtext-to-jsonl.py
#
# 10k small dataset
# ./openwebtext-to-jsonl.py -10k

import sys
from datasets import load_dataset

if "-10k" in sys.argv:
    dataset_name = "stas/openwebtext-10k"
else:
    dataset_name = "openwebtext"

name = dataset_name.split('/')[-1]
ds = load_dataset(dataset_name, split='train')
ds.to_json(f"{name}.jsonl", orient="records", lines=True)

# subset to jsonlines
# n_samples = 1000
# ds = load_dataset(dataset_name, split='train')
# ds_small = ds.select(range(n_samples))
# path = f"{dataset_name}-{n_samples}.jsonl"
# ds_small.to_json(path, orient="records", lines=True)