rm python script
#3
by
ivanzhou-uber
- opened
- RedPajama-Tiny.py +0 -103
RedPajama-Tiny.py
DELETED
@@ -1,103 +0,0 @@
|
|
1 |
-
# Copyright 2023 Together Computer
|
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 |
-
"""RedPajama: An Open-Source, Clean-Room 1.2 Trillion Token Dataset."""
|
17 |
-
|
18 |
-
|
19 |
-
import json
|
20 |
-
|
21 |
-
import datasets
|
22 |
-
|
23 |
-
|
24 |
-
logger = datasets.logging.get_logger(__name__)
|
25 |
-
|
26 |
-
|
27 |
-
_DESCRIPTION = """\
|
28 |
-
RedPajama is a clean-room, fully open-source implementation of the LLaMa dataset. This is a 1B-token sample of the full dataset.
|
29 |
-
"""
|
30 |
-
|
31 |
-
_URLS = [
|
32 |
-
"arxiv_sample.jsonl",
|
33 |
-
"book_sample.jsonl",
|
34 |
-
"c4_sample.jsonl",
|
35 |
-
"cc_2023-06_sample.jsonl",
|
36 |
-
"github_sample.jsonl",
|
37 |
-
"stackexchange_sample.jsonl",
|
38 |
-
"wikipedia_sample.jsonl",
|
39 |
-
]
|
40 |
-
|
41 |
-
|
42 |
-
class RedPajamaTinyConfig(datasets.BuilderConfig):
|
43 |
-
"""BuilderConfig for RedPajama sample."""
|
44 |
-
|
45 |
-
def __init__(self, **kwargs):
|
46 |
-
"""BuilderConfig for RedPajama sample.
|
47 |
-
Args:
|
48 |
-
**kwargs: keyword arguments forwarded to super.
|
49 |
-
"""
|
50 |
-
super(RedPajamaTinyConfig, self).__init__(**kwargs)
|
51 |
-
|
52 |
-
|
53 |
-
class RedPajamaTiny(datasets.GeneratorBasedBuilder):
|
54 |
-
"""RedPajama 1T Sample: version 1.0.0."""
|
55 |
-
|
56 |
-
BUILDER_CONFIGS = [
|
57 |
-
RedPajamaTinyConfig(
|
58 |
-
name="plain_text",
|
59 |
-
version=datasets.Version("1.0.0", ""),
|
60 |
-
description="Plain text",
|
61 |
-
),
|
62 |
-
]
|
63 |
-
|
64 |
-
def _info(self):
|
65 |
-
return datasets.DatasetInfo(
|
66 |
-
description=_DESCRIPTION,
|
67 |
-
features=datasets.Features(
|
68 |
-
{
|
69 |
-
"text": datasets.Value("string"),
|
70 |
-
"meta": datasets.Value("string"),
|
71 |
-
}
|
72 |
-
),
|
73 |
-
supervised_keys=None,
|
74 |
-
)
|
75 |
-
|
76 |
-
def _split_generators(self, dl_manager):
|
77 |
-
downloaded_files = dl_manager.download_and_extract(_URLS)
|
78 |
-
|
79 |
-
return [
|
80 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepaths": downloaded_files})
|
81 |
-
]
|
82 |
-
|
83 |
-
def _generate_examples(self, filepaths):
|
84 |
-
"""This function returns the examples in the raw (text) form."""
|
85 |
-
logger.info("generating examples from = %s", filepaths)
|
86 |
-
key = 0
|
87 |
-
for filepath in filepaths:
|
88 |
-
with open(filepath, encoding="utf-8") as f:
|
89 |
-
for row in f:
|
90 |
-
data = json.loads(row)
|
91 |
-
if "meta" not in data:
|
92 |
-
text = data["text"]
|
93 |
-
del data["text"]
|
94 |
-
yield key, {
|
95 |
-
"text": text,
|
96 |
-
"meta": json.dumps(data),
|
97 |
-
}
|
98 |
-
else:
|
99 |
-
yield key, {
|
100 |
-
"text": data["text"],
|
101 |
-
"meta": data["meta"],
|
102 |
-
}
|
103 |
-
key += 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|