jordiclive
commited on
Commit
•
a961415
1
Parent(s):
6385e1c
Upload folder using huggingface_hub
Browse files- .DS_Store +0 -0
- my_upsto.py +107 -0
- test/domain_test_0.jsonl.zst +3 -0
- test/pile_test_0.jsonl.zst +3 -0
- train/domain_01_0.jsonl.zst +3 -0
- train/domain_01_1.jsonl.zst +3 -0
- val/domain_val_0.jsonl.zst +3 -0
- val/pile_val_2.jsonl.zst +3 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
my_upsto.py
ADDED
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import DatasetBuilder, GeneratorBasedBuilder, SplitGenerator, Features, Value
|
2 |
+
import json
|
3 |
+
import datasets
|
4 |
+
import os
|
5 |
+
from glob import glob
|
6 |
+
import zstandard as zstd
|
7 |
+
from datasets.utils import Version
|
8 |
+
import io
|
9 |
+
|
10 |
+
class MyUSPTODataset(GeneratorBasedBuilder):
|
11 |
+
VERSION = Version("1.0.0")
|
12 |
+
|
13 |
+
def _info(self):
|
14 |
+
return datasets.DatasetInfo(
|
15 |
+
description="USPTO Patents Dataset",
|
16 |
+
features=datasets.Features(
|
17 |
+
{
|
18 |
+
"text": datasets.Value("string"),
|
19 |
+
|
20 |
+
}
|
21 |
+
),
|
22 |
+
supervised_keys=None,
|
23 |
+
|
24 |
+
)
|
25 |
+
|
26 |
+
def _split_generators(self, dl_manager):
|
27 |
+
|
28 |
+
return [
|
29 |
+
datasets.SplitGenerator(
|
30 |
+
name=datasets.Split.TRAIN,
|
31 |
+
# These kwargs will be passed to _generate_examples
|
32 |
+
gen_kwargs={
|
33 |
+
"data_dir": "train",
|
34 |
+
"split": None,
|
35 |
+
},
|
36 |
+
|
37 |
+
),
|
38 |
+
datasets.SplitGenerator(
|
39 |
+
name="validation_pile",
|
40 |
+
# These kwargs will be passed to _generate_examples
|
41 |
+
gen_kwargs={
|
42 |
+
"data_dir": "val",
|
43 |
+
"split": "pile",
|
44 |
+
},
|
45 |
+
),
|
46 |
+
datasets.SplitGenerator(
|
47 |
+
name="validation_domain",
|
48 |
+
# These kwargs will be passed to _generate_examples
|
49 |
+
gen_kwargs={
|
50 |
+
"data_dir": "val",
|
51 |
+
"split": "domain",
|
52 |
+
},
|
53 |
+
),
|
54 |
+
datasets.SplitGenerator(
|
55 |
+
name="test_pile",
|
56 |
+
# These kwargs will be passed to _generate_examples
|
57 |
+
gen_kwargs={
|
58 |
+
"data_dir": "test_pile",
|
59 |
+
"split": "pile"
|
60 |
+
},
|
61 |
+
|
62 |
+
),
|
63 |
+
datasets.SplitGenerator(
|
64 |
+
name="test_domain",
|
65 |
+
# These kwargs will be passed to _generate_examples
|
66 |
+
gen_kwargs={
|
67 |
+
"data_dir": "test_domain",
|
68 |
+
"split": "domain"
|
69 |
+
},
|
70 |
+
|
71 |
+
),
|
72 |
+
|
73 |
+
]
|
74 |
+
|
75 |
+
def _generate_examples(self, data_dir, split):
|
76 |
+
dctx = zstd.ZstdDecompressor()
|
77 |
+
idx = -1
|
78 |
+
file_paths = glob(os.path.join(data_dir, f"*.jsonl.zst"))
|
79 |
+
if split is not None:
|
80 |
+
file_paths = [f for f in file_paths if split in f]
|
81 |
+
for file in file_paths:
|
82 |
+
with open(file, "rb") as f:
|
83 |
+
reader = dctx.stream_reader(f)
|
84 |
+
buffer = io.BufferedReader(reader)
|
85 |
+
for _, line in enumerate(buffer.readlines()):
|
86 |
+
data = json.loads(line)
|
87 |
+
idx += 1
|
88 |
+
yield idx, data
|
89 |
+
|
90 |
+
|
91 |
+
# if __name__ == "__main__":
|
92 |
+
# import os
|
93 |
+
# import shutil
|
94 |
+
# import glob
|
95 |
+
# cache_directory = "/Users/jordanclive/.cache/huggingface/datasets"
|
96 |
+
#
|
97 |
+
# dataset = MyUSPTODataset()
|
98 |
+
#
|
99 |
+
# #
|
100 |
+
# dataset = MyUSPTODataset()
|
101 |
+
# dataset.download_and_prepare()
|
102 |
+
# dataset = dataset.as_dataset()
|
103 |
+
# # # x = 1
|
104 |
+
# # print(dataset)
|
105 |
+
# # print(dataset["train"][0])
|
106 |
+
# # print(dataset["test"][0])
|
107 |
+
# # print(dataset["validation"][0])
|
test/domain_test_0.jsonl.zst
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:70440e0cd17c331b7bd0552deef0d40dd3718247d63c691a23ae7b2488c47064
|
3 |
+
size 6529625
|
test/pile_test_0.jsonl.zst
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:98e433955df2cde6352bc6e3d879fc43e217924f636683f7d06203850bc9f44f
|
3 |
+
size 24110126
|
train/domain_01_0.jsonl.zst
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f4373900c9a5910b342ebbae6aa45ba1e803a47cc4f2a7aea48ae9de94f9b8e8
|
3 |
+
size 6503794
|
train/domain_01_1.jsonl.zst
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2a70695c68adbe576b608fcbbe2a8fc256a27bc2313bb7875fb2de5b2a84803c
|
3 |
+
size 6664613
|
val/domain_val_0.jsonl.zst
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:e6dd78b137a4a4824b84f435d88e1e78974113705807917f51127fce7dc3c81a
|
3 |
+
size 6688544
|
val/pile_val_2.jsonl.zst
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0516e81718eecff588899c9f2b174ffaed18ecb10b194648cf72d99ce4b39d88
|
3 |
+
size 23346058
|