Create download_dataset.py
Browse files- download_dataset.py +29 -0
download_dataset.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
import requests
|
4 |
+
from tqdm import tqdm
|
5 |
+
|
6 |
+
subdir = 'data'
|
7 |
+
if not os.path.exists(subdir):
|
8 |
+
os.makedirs(subdir)
|
9 |
+
subdir = subdir.replace('\\','/') # needed for Windows
|
10 |
+
|
11 |
+
for ds in [
|
12 |
+
'webtext',
|
13 |
+
'small-117M', 'small-117M-k40',
|
14 |
+
'medium-345M', 'medium-345M-k40',
|
15 |
+
'large-762M', 'large-762M-k40',
|
16 |
+
'xl-1542M', 'xl-1542M-k40',
|
17 |
+
]:
|
18 |
+
for split in ['train', 'valid', 'test']:
|
19 |
+
filename = ds + "." + split + '.jsonl'
|
20 |
+
r = requests.get("https://storage.googleapis.com/gpt-2/output-dataset/v1/" + filename, stream=True)
|
21 |
+
|
22 |
+
with open(os.path.join(subdir, filename), 'wb') as f:
|
23 |
+
file_size = int(r.headers["content-length"])
|
24 |
+
chunk_size = 1000
|
25 |
+
with tqdm(ncols=100, desc="Fetching " + filename, total=file_size, unit_scale=True) as pbar:
|
26 |
+
# 1k for chunk_size, since Ethernet packet size is around 1500 bytes
|
27 |
+
for chunk in r.iter_content(chunk_size=chunk_size):
|
28 |
+
f.write(chunk)
|
29 |
+
pbar.update(chunk_size)
|