Datasets:
data
Browse files- .DS_Store +0 -0
- dolma.py +122 -0
- urls/.DS_Store +0 -0
- urls/dolma-v1.json +0 -0
- urls/dolma-v1.txt +0 -0
- urls/dolma-v1_5r1-sample.json +0 -0
- urls/dolma-v1_5r1-sample.txt +0 -0
- urls/dolma-v1_5r1.json +0 -0
- urls/dolma-v1_5r1.txt +0 -0
- urls/dolma-v1_5r2.json +0 -0
- urls/dolma-v1_5r2.txt +0 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
dolma.py
ADDED
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright 2023 Allen Institute for AI
|
2 |
+
#
|
3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4 |
+
# you may not use this file except in compliance with the License.
|
5 |
+
# You may obtain a copy of the License at
|
6 |
+
#
|
7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8 |
+
#
|
9 |
+
# Unless required by applicable law or agreed to in writing, software
|
10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12 |
+
# See the License for the specific language governing permissions and
|
13 |
+
# limitations under the License.
|
14 |
+
|
15 |
+
# Lint as: python3
|
16 |
+
"""Dolma: an Open Corpus of Three Trillion Tokens for Language Model Pretraining Research"""
|
17 |
+
|
18 |
+
|
19 |
+
import json
|
20 |
+
from pathlib import Path
|
21 |
+
from typing import Dict, List
|
22 |
+
|
23 |
+
import datasets
|
24 |
+
import traceback
|
25 |
+
import os
|
26 |
+
|
27 |
+
logger = datasets.logging.get_logger(__name__)
|
28 |
+
|
29 |
+
_CURRENT_DIR = Path(__file__).resolve().parent
|
30 |
+
|
31 |
+
_DESCRIPTION = """\
|
32 |
+
Dolma: an Open Corpus of Three Trillion Tokens for Language Model Pretraining Research
|
33 |
+
"""
|
34 |
+
|
35 |
+
_SUBSET_URLS = {
|
36 |
+
"v1": _CURRENT_DIR / "urls/dolma-v1.txt",
|
37 |
+
"v1_5r1": _CURRENT_DIR / "urls/dolma-v1_5r1.txt",
|
38 |
+
"v1_5r1-sample": _CURRENT_DIR / "urls/dolma-v1_5r1-sample.txt",
|
39 |
+
"v1_5r2": _CURRENT_DIR / "urls/dolma-v1_5r2.txt",
|
40 |
+
}
|
41 |
+
_SUBSET_VERSION = {
|
42 |
+
"v1": "1.0.0",
|
43 |
+
"v1_5r1": "1.5.0",
|
44 |
+
"v1_5r1-sample": "1.5.0",
|
45 |
+
"v1_5r2": "1.5.0",
|
46 |
+
}
|
47 |
+
_SUBSET_NAME = {
|
48 |
+
"v1": "Dolma v1 (Aug 2023)",
|
49 |
+
"v1_5r1": "Dolma v1.5r1 (Oct 2023)",
|
50 |
+
"v1_5r1-sample": "Dolma v1.5r1, 2T sample (Oct 2023)",
|
51 |
+
"v1_5r2": "Dolma v1.5r2 (Dec 2023)",
|
52 |
+
}
|
53 |
+
|
54 |
+
_DATA_DIR = os.environ.get("DOLMA_DATA_DIR", None)
|
55 |
+
|
56 |
+
|
57 |
+
class RedPajama1TConfig(datasets.BuilderConfig):
|
58 |
+
"""BuilderConfig for RedPajama sample."""
|
59 |
+
|
60 |
+
def __init__(self, *args, subsets: List[str], url_file: Path, **kwargs):
|
61 |
+
"""BuilderConfig for RedPajama.
|
62 |
+
Args:
|
63 |
+
**kwargs: keyword arguments forwarded to super.
|
64 |
+
"""
|
65 |
+
super(RedPajama1TConfig, self).__init__(*args, **kwargs)
|
66 |
+
self.subsets = subsets
|
67 |
+
self.url_file = url_file
|
68 |
+
|
69 |
+
|
70 |
+
class RedPajama1T(datasets.GeneratorBasedBuilder):
|
71 |
+
"""Dolma: an Open Corpus of Three Trillion Tokens for Language Model Pretraining Research"""
|
72 |
+
|
73 |
+
config: RedPajama1TConfig
|
74 |
+
|
75 |
+
BUILDER_CONFIGS = [
|
76 |
+
RedPajama1TConfig(
|
77 |
+
name=subset,
|
78 |
+
subsets=[subset],
|
79 |
+
url_file=_SUBSET_URLS[subset],
|
80 |
+
version=datasets.Version(_SUBSET_VERSION[subset], _SUBSET_NAME[subset]),
|
81 |
+
description=_DESCRIPTION,
|
82 |
+
)
|
83 |
+
for subset in _SUBSET_URLS
|
84 |
+
]
|
85 |
+
|
86 |
+
DEFAULT_CONFIG_NAME = "v1_5r2"
|
87 |
+
|
88 |
+
def _info(self):
|
89 |
+
return datasets.DatasetInfo(
|
90 |
+
description=_DESCRIPTION,
|
91 |
+
features=datasets.Features(
|
92 |
+
{
|
93 |
+
"id": datasets.Value("string"),
|
94 |
+
"text": datasets.Value("string"),
|
95 |
+
"metadata": datasets.Value("string"),
|
96 |
+
"added": datasets.Value("string"),
|
97 |
+
# "metadata": datasets.Value("")
|
98 |
+
}
|
99 |
+
),
|
100 |
+
supervised_keys=None,
|
101 |
+
)
|
102 |
+
|
103 |
+
def _split_generators(self, dl_manager):
|
104 |
+
with open(self.config.url_file, encoding="utf-8") as f:
|
105 |
+
subset_urls: Dict[str, List[str]] = json.load(f)
|
106 |
+
|
107 |
+
breakpoint()
|
108 |
+
|
109 |
+
url_lists: Dict[str, List[str]] = {}
|
110 |
+
for subset in self.config.subsets:
|
111 |
+
url_lists[subset] = dl_manager.download(subset_urls[subset])
|
112 |
+
|
113 |
+
return [
|
114 |
+
datasets.SplitGenerator(
|
115 |
+
name=datasets.Split.TRAIN._name,
|
116 |
+
gen_kwargs={"files": {subset: url_lists[subset] for subset in self.config.subsets}},
|
117 |
+
)
|
118 |
+
]
|
119 |
+
|
120 |
+
def _generate_examples(self, files):
|
121 |
+
"""This function returns the examples in the raw (text) form."""
|
122 |
+
breakpoint()
|
urls/.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
urls/dolma-v1.json
DELETED
The diff for this file is too large to render.
See raw diff
|
|
urls/dolma-v1.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
urls/dolma-v1_5r1-sample.json
DELETED
The diff for this file is too large to render.
See raw diff
|
|
urls/dolma-v1_5r1-sample.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
urls/dolma-v1_5r1.json
DELETED
The diff for this file is too large to render.
See raw diff
|
|
urls/dolma-v1_5r1.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|
urls/dolma-v1_5r2.json
DELETED
The diff for this file is too large to render.
See raw diff
|
|
urls/dolma-v1_5r2.txt
ADDED
The diff for this file is too large to render.
See raw diff
|
|