Dan Fu
commited on
Commit
•
4e62b3b
1
Parent(s):
0d59dbd
Update loader script for local files
Browse files- README.md +8 -0
- RedPajama-Data-1T.py +68 -6
README.md
CHANGED
@@ -25,6 +25,14 @@ while read line; do
|
|
25 |
done < urls.txt
|
26 |
```
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
A smaller 1B-token sample of the dataset can be found [here](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-1T-Sample).
|
30 |
|
|
|
25 |
done < urls.txt
|
26 |
```
|
27 |
|
28 |
+
After downloading the files, you can load the dataset from disk by setting the `RED_PAJAMA_DATA_DIR` environment variable to the directory containing the files:
|
29 |
+
|
30 |
+
```python
|
31 |
+
import os
|
32 |
+
from datasets import load_dataset
|
33 |
+
os.environ["RED_PAJAMA_DATA_DIR"] = "/path/to/download"
|
34 |
+
ds = load_dataset("togethercomputer/RedPajama-Data-1T")
|
35 |
+
```
|
36 |
|
37 |
A smaller 1B-token sample of the dataset can be found [here](https://huggingface.co/datasets/togethercomputer/RedPajama-Data-1T-Sample).
|
38 |
|
RedPajama-Data-1T.py
CHANGED
@@ -20,6 +20,7 @@ import json
|
|
20 |
|
21 |
import datasets
|
22 |
import traceback
|
|
|
23 |
|
24 |
logger = datasets.logging.get_logger(__name__)
|
25 |
|
@@ -37,7 +38,9 @@ _URL_LISTS = {
|
|
37 |
"stackexchange": "urls/stackexchange.txt",
|
38 |
"wikipedia": "urls/wikipedia.txt",
|
39 |
}
|
|
|
40 |
|
|
|
41 |
|
42 |
class RedPajama1TConfig(datasets.BuilderConfig):
|
43 |
"""BuilderConfig for RedPajama sample."""
|
@@ -48,7 +51,6 @@ class RedPajama1TConfig(datasets.BuilderConfig):
|
|
48 |
**kwargs: keyword arguments forwarded to super.
|
49 |
"""
|
50 |
super(RedPajama1TConfig, self).__init__(**kwargs)
|
51 |
-
|
52 |
self.subsets = subsets
|
53 |
|
54 |
|
@@ -57,10 +59,59 @@ class RedPajama1T(datasets.GeneratorBasedBuilder):
|
|
57 |
|
58 |
BUILDER_CONFIGS = [
|
59 |
RedPajama1TConfig(
|
|
|
60 |
subsets = list(_URL_LISTS.keys()),
|
61 |
-
name="plain_text",
|
62 |
version=datasets.Version("1.0.0", ""),
|
63 |
-
description="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
),
|
65 |
]
|
66 |
|
@@ -86,9 +137,20 @@ class RedPajama1T(datasets.GeneratorBasedBuilder):
|
|
86 |
|
87 |
for subset, url_list in url_lists.items():
|
88 |
with open(url_list, encoding="utf-8") as f:
|
89 |
-
urls[subset] = [line.strip() for line in f]
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
return [
|
94 |
datasets.SplitGenerator(
|
|
|
20 |
|
21 |
import datasets
|
22 |
import traceback
|
23 |
+
import os
|
24 |
|
25 |
logger = datasets.logging.get_logger(__name__)
|
26 |
|
|
|
38 |
"stackexchange": "urls/stackexchange.txt",
|
39 |
"wikipedia": "urls/wikipedia.txt",
|
40 |
}
|
41 |
+
_URL_BASE = 'https://data.together.xyz/redpajama-data-1T/v1.0.0'
|
42 |
|
43 |
+
_DATA_DIR = os.environ.get('RED_PAJAMA_DATA_DIR', None)
|
44 |
|
45 |
class RedPajama1TConfig(datasets.BuilderConfig):
|
46 |
"""BuilderConfig for RedPajama sample."""
|
|
|
51 |
**kwargs: keyword arguments forwarded to super.
|
52 |
"""
|
53 |
super(RedPajama1TConfig, self).__init__(**kwargs)
|
|
|
54 |
self.subsets = subsets
|
55 |
|
56 |
|
|
|
59 |
|
60 |
BUILDER_CONFIGS = [
|
61 |
RedPajama1TConfig(
|
62 |
+
name = 'default',
|
63 |
subsets = list(_URL_LISTS.keys()),
|
|
|
64 |
version=datasets.Version("1.0.0", ""),
|
65 |
+
description="RedPajama1T",
|
66 |
+
),
|
67 |
+
|
68 |
+
RedPajama1TConfig(
|
69 |
+
name = 'arxiv',
|
70 |
+
subsets = 'arxiv',
|
71 |
+
version=datasets.Version("1.0.0", ""),
|
72 |
+
description="RedPajama1T arxiv subset",
|
73 |
+
),
|
74 |
+
|
75 |
+
RedPajama1TConfig(
|
76 |
+
name = 'book',
|
77 |
+
subsets = 'book',
|
78 |
+
version=datasets.Version("1.0.0", ""),
|
79 |
+
description="RedPajama1T book subset",
|
80 |
+
),
|
81 |
+
|
82 |
+
RedPajama1TConfig(
|
83 |
+
name = 'c4',
|
84 |
+
subsets = 'c4',
|
85 |
+
version=datasets.Version("1.0.0", ""),
|
86 |
+
description="RedPajama1T c4 subset",
|
87 |
+
),
|
88 |
+
|
89 |
+
RedPajama1TConfig(
|
90 |
+
name = 'common_crawl',
|
91 |
+
subsets = 'common_crawl',
|
92 |
+
version=datasets.Version("1.0.0", ""),
|
93 |
+
description="RedPajama1T common crawl subset",
|
94 |
+
),
|
95 |
+
|
96 |
+
RedPajama1TConfig(
|
97 |
+
name = 'github',
|
98 |
+
subsets = 'github',
|
99 |
+
version=datasets.Version("1.0.0", ""),
|
100 |
+
description="RedPajama1T github subset",
|
101 |
+
),
|
102 |
+
|
103 |
+
RedPajama1TConfig(
|
104 |
+
name = 'stackexchange',
|
105 |
+
subsets = 'stackexchange',
|
106 |
+
version=datasets.Version("1.0.0", ""),
|
107 |
+
description="RedPajama1T stackexchange subset",
|
108 |
+
),
|
109 |
+
|
110 |
+
RedPajama1TConfig(
|
111 |
+
name = 'wikipedia',
|
112 |
+
subsets = 'wikipedia',
|
113 |
+
version=datasets.Version("1.0.0", ""),
|
114 |
+
description="RedPajama1T wikipedia subset",
|
115 |
),
|
116 |
]
|
117 |
|
|
|
137 |
|
138 |
for subset, url_list in url_lists.items():
|
139 |
with open(url_list, encoding="utf-8") as f:
|
140 |
+
urls[subset] = [line.strip() for line in f]
|
141 |
+
|
142 |
+
if _DATA_DIR is not None:
|
143 |
+
print(f'Reading data from {_DATA_DIR}')
|
144 |
+
url_prefix_slashes = len(_URL_BASE.split('/'))
|
145 |
+
downloaded_files = {
|
146 |
+
subset: [
|
147 |
+
os.path.join(_DATA_DIR, *url.split('/')[url_prefix_slashes:])
|
148 |
+
for url in url_list
|
149 |
+
]
|
150 |
+
for subset, url_list in urls.items()
|
151 |
+
}
|
152 |
+
else:
|
153 |
+
downloaded_files = dl_manager.download(urls)
|
154 |
|
155 |
return [
|
156 |
datasets.SplitGenerator(
|