Datasets:
Tasks:
Text Generation
Modalities:
Text
Sub-tasks:
language-modeling
Languages:
English
Size:
100K - 1M
License:
Zhangir Azerbayev
commited on
Commit
•
81d0091
1
Parent(s):
ed95795
added tar support
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- fetch_mathoverflow.py +25 -14
- proof-pile.py +70 -24
- stack-exchange/math_overflow.tar.gz +3 -0
- stack-exchange/math_overflow/shard_0.txt +0 -0
- stack-exchange/math_overflow/shard_1.txt +0 -0
- stack-exchange/math_overflow/shard_10.txt +0 -0
- stack-exchange/math_overflow/shard_11.txt +0 -0
- stack-exchange/math_overflow/shard_12.txt +0 -0
- stack-exchange/math_overflow/shard_13.txt +0 -0
- stack-exchange/math_overflow/shard_14.txt +0 -0
- stack-exchange/math_overflow/shard_15.txt +0 -0
- stack-exchange/math_overflow/shard_16.txt +0 -0
- stack-exchange/math_overflow/shard_17.txt +0 -0
- stack-exchange/math_overflow/shard_18.txt +0 -0
- stack-exchange/math_overflow/shard_19.txt +0 -0
- stack-exchange/math_overflow/shard_2.txt +0 -0
- stack-exchange/math_overflow/shard_20.txt +0 -0
- stack-exchange/math_overflow/shard_21.txt +0 -0
- stack-exchange/math_overflow/shard_22.txt +0 -0
- stack-exchange/math_overflow/shard_23.txt +0 -0
- stack-exchange/math_overflow/shard_24.txt +0 -0
- stack-exchange/math_overflow/shard_25.txt +0 -0
- stack-exchange/math_overflow/shard_26.txt +0 -0
- stack-exchange/math_overflow/shard_27.txt +0 -0
- stack-exchange/math_overflow/shard_3.txt +0 -0
- stack-exchange/math_overflow/shard_4.txt +0 -0
- stack-exchange/math_overflow/shard_5.txt +0 -0
- stack-exchange/math_overflow/shard_6.txt +0 -0
- stack-exchange/math_overflow/shard_7.txt +0 -0
- stack-exchange/math_overflow/shard_8.txt +0 -0
- stack-exchange/math_overflow/shard_9.txt +0 -0
- stack-exchange/math_overflow_val.tar.gz +3 -0
- stack-exchange/math_stack_exchange.tar.gz +3 -0
- stack-exchange/math_stack_exchange/shard_0.txt +0 -0
- stack-exchange/math_stack_exchange/shard_1.txt +0 -0
- stack-exchange/math_stack_exchange/shard_10.txt +0 -0
- stack-exchange/math_stack_exchange/shard_100.txt +0 -0
- stack-exchange/math_stack_exchange/shard_101.txt +0 -0
- stack-exchange/math_stack_exchange/shard_102.txt +0 -0
- stack-exchange/math_stack_exchange/shard_103.txt +0 -0
- stack-exchange/math_stack_exchange/shard_104.txt +0 -0
- stack-exchange/math_stack_exchange/shard_105.txt +0 -0
- stack-exchange/math_stack_exchange/shard_106.txt +0 -0
- stack-exchange/math_stack_exchange/shard_107.txt +0 -0
- stack-exchange/math_stack_exchange/shard_108.txt +0 -0
- stack-exchange/math_stack_exchange/shard_109.txt +0 -0
- stack-exchange/math_stack_exchange/shard_11.txt +0 -0
- stack-exchange/math_stack_exchange/shard_110.txt +0 -0
- stack-exchange/math_stack_exchange/shard_111.txt +0 -0
- stack-exchange/math_stack_exchange/shard_112.txt +0 -0
fetch_mathoverflow.py
CHANGED
@@ -12,6 +12,8 @@ from tqdm import tqdm
|
|
12 |
from bs4 import BeautifulSoup
|
13 |
import sys
|
14 |
from pathlib import Path
|
|
|
|
|
15 |
|
16 |
"""
|
17 |
Author: E.W.Ayers
|
@@ -176,8 +178,10 @@ def text_of_post(post):
|
|
176 |
|
177 |
return text, post.Score, post.Id, answered
|
178 |
|
179 |
-
def get_and_format(url, save_dir):
|
|
|
180 |
Path(save_dir).mkdir(exist_ok=True, parents=True)
|
|
|
181 |
archive_path = os.path.join(save_dir, "archive.7z")
|
182 |
os.system(f"wget -O {archive_path} {url}")
|
183 |
|
@@ -191,24 +195,31 @@ def get_and_format(url, save_dir):
|
|
191 |
|
192 |
print("converting xml to text...")
|
193 |
qs_texts = [text_of_post(qs[key]) for key in tqdm(qs.keys())]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
|
195 |
-
|
196 |
-
|
197 |
-
for i, batch in tqdm(enumerate(batches)):
|
198 |
-
shard_path = os.path.join(save_dir, f"shard_{i}.txt")
|
199 |
-
|
200 |
-
to_cat = [post for post, score, _, answered in batch
|
201 |
-
if score >=5 and answered]
|
202 |
-
shard = f"{DOC_SEP}\n".join(to_cat)
|
203 |
-
|
204 |
-
with open(shard_path, "w") as f:
|
205 |
-
f.write(shard)
|
206 |
|
207 |
os.system(f"rm -r {DATA_DIR}")
|
208 |
os.remove(archive_path)
|
209 |
|
|
|
|
|
|
|
|
|
|
|
210 |
if __name__ == '__main__':
|
211 |
get_and_format("https://archive.org/download/stackexchange/mathoverflow.net.7z",
|
212 |
-
"stack-exchange/math_overflow")
|
213 |
get_and_format("https://archive.org/download/stackexchange/math.stackexchange.com.7z",
|
214 |
-
"stack-exchange/math_stack_exchange")
|
|
|
|
|
|
|
|
|
|
12 |
from bs4 import BeautifulSoup
|
13 |
import sys
|
14 |
from pathlib import Path
|
15 |
+
import tarfile
|
16 |
+
import random
|
17 |
|
18 |
"""
|
19 |
Author: E.W.Ayers
|
|
|
178 |
|
179 |
return text, post.Score, post.Id, answered
|
180 |
|
181 |
+
def get_and_format(url, save_dir, val_dir):
|
182 |
+
VAL_RATE = 0.05
|
183 |
Path(save_dir).mkdir(exist_ok=True, parents=True)
|
184 |
+
Path(val_dir).mkdir(exist_ok=True, parents=True)
|
185 |
archive_path = os.path.join(save_dir, "archive.7z")
|
186 |
os.system(f"wget -O {archive_path} {url}")
|
187 |
|
|
|
195 |
|
196 |
print("converting xml to text...")
|
197 |
qs_texts = [text_of_post(qs[key]) for key in tqdm(qs.keys())]
|
198 |
+
|
199 |
+
for post, score, eyed, answered in tqdm(qs_texts):
|
200 |
+
if score >= 5 and answered:
|
201 |
+
if random.random() > VAL_RATE:
|
202 |
+
shard_path = os.path.join(save_dir, f"{eyed}.txt")
|
203 |
+
else:
|
204 |
+
shard_path = os.path.join(val_dir, f"{eyed}.txt")
|
205 |
|
206 |
+
with open(shard_path, "w") as f:
|
207 |
+
f.write(post)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
os.system(f"rm -r {DATA_DIR}")
|
210 |
os.remove(archive_path)
|
211 |
|
212 |
+
def make_archive(path):
|
213 |
+
with tarfile.open(path + ".tar.gz", "w:gz") as tar:
|
214 |
+
tar.add(path, arcname=os.path.sep)
|
215 |
+
os.system(f"rm -r {path}")
|
216 |
+
|
217 |
if __name__ == '__main__':
|
218 |
get_and_format("https://archive.org/download/stackexchange/mathoverflow.net.7z",
|
219 |
+
"stack-exchange/math_overflow", val_dir = "stack-exchange/math_overflow_val")
|
220 |
get_and_format("https://archive.org/download/stackexchange/math.stackexchange.com.7z",
|
221 |
+
"stack-exchange/math_stack_exchange", val_dir="stack-exchange/math_stack_exchange_val")
|
222 |
+
make_archive("stack-exchange/math_overflow")
|
223 |
+
make_archive("stack-exchange/math_overflow_val")
|
224 |
+
make_archive("stack-exchange/math_stack_exchange")
|
225 |
+
make_archive("stack-exchange/math_stack_exchange_val")
|
proof-pile.py
CHANGED
@@ -19,6 +19,9 @@ import csv
|
|
19 |
import json
|
20 |
import os
|
21 |
|
|
|
|
|
|
|
22 |
import datasets
|
23 |
|
24 |
|
@@ -84,6 +87,8 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
84 |
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
85 |
features = datasets.Features(
|
86 |
{
|
|
|
|
|
87 |
"text": datasets.Value("string"),
|
88 |
# These are the features of your dataset like images, labels ...
|
89 |
}
|
@@ -114,33 +119,74 @@ class NewDataset(datasets.GeneratorBasedBuilder):
|
|
114 |
with open("splits.json") as f:
|
115 |
splits = json.load(f)
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
"
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
|
134 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
135 |
def _generate_examples(self, data_files):
|
136 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
137 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
138 |
key = 0
|
139 |
-
|
140 |
-
|
141 |
-
text =
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
import json
|
20 |
import os
|
21 |
|
22 |
+
import itertools
|
23 |
+
from itertools import islice
|
24 |
+
|
25 |
import datasets
|
26 |
|
27 |
|
|
|
87 |
# TODO: This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
|
88 |
features = datasets.Features(
|
89 |
{
|
90 |
+
"config": datasets.Value("string"),
|
91 |
+
"file": datasets.Value("string"),
|
92 |
"text": datasets.Value("string"),
|
93 |
# These are the features of your dataset like images, labels ...
|
94 |
}
|
|
|
119 |
with open("splits.json") as f:
|
120 |
splits = json.load(f)
|
121 |
|
122 |
+
archived_configs = ["stack-exchange"]
|
123 |
+
|
124 |
+
if self.config.name in archived_configs:
|
125 |
+
if self.config.name=="stack-exchange":
|
126 |
+
train_paths = [os.path.join("./stack-exchange", x) for x in ["math_overflow.tar.gz",
|
127 |
+
"math_stack_exchange.tar.gz"]]
|
128 |
+
val_paths = [os.path.join("./stack-exchange", x) for x in ["math_overflow_val.tar.gz",
|
129 |
+
"math_stack_exchange_val.tar.gz"]]
|
130 |
+
|
131 |
+
train_files = itertools.chain.from_iterable(dl_manager.iter_archive(x) for x in train_paths)
|
132 |
+
val_files = itertools.chain.from_iterable(dl_manager.iter_archive(x) for x in val_paths)
|
133 |
+
|
134 |
+
return [
|
135 |
+
datasets.SplitGenerator(
|
136 |
+
name=datasets.Split.TRAIN,
|
137 |
+
# These kwargs will be passed to _generate_examples
|
138 |
+
gen_kwargs={
|
139 |
+
"data_files": train_files,
|
140 |
+
},
|
141 |
+
),
|
142 |
+
datasets.SplitGenerator(
|
143 |
+
name=datasets.Split.VALIDATION,
|
144 |
+
# These kwargs will be passed to _generate_examples
|
145 |
+
gen_kwargs={
|
146 |
+
"data_files": val_files,
|
147 |
+
},
|
148 |
+
),
|
149 |
+
]
|
150 |
+
else:
|
151 |
+
return [
|
152 |
+
datasets.SplitGenerator(
|
153 |
+
name=datasets.Split.TRAIN,
|
154 |
+
# These kwargs will be passed to _generate_examples
|
155 |
+
gen_kwargs={
|
156 |
+
"data_files": splits[self.config.name + "-train"],
|
157 |
+
},
|
158 |
+
),
|
159 |
+
datasets.SplitGenerator(
|
160 |
+
name=datasets.Split.VALIDATION,
|
161 |
+
# These kwargs will be passed to _generate_examples
|
162 |
+
gen_kwargs={
|
163 |
+
"data_files": splits[self.config.name + "-valid"],
|
164 |
+
},
|
165 |
+
),
|
166 |
+
]
|
167 |
|
168 |
# method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
|
169 |
def _generate_examples(self, data_files):
|
170 |
# TODO: This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
|
171 |
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
172 |
key = 0
|
173 |
+
if self.config.name=="stack-exchange":
|
174 |
+
for name, obj in data_files:
|
175 |
+
text = obj.read()
|
176 |
+
yield key, {
|
177 |
+
"config": self.config.name,
|
178 |
+
"file": name,
|
179 |
+
"text": text,
|
180 |
+
}
|
181 |
+
key += 1
|
182 |
+
else:
|
183 |
+
for name in data_files:
|
184 |
+
with open(name, encoding="utf-8") as f:
|
185 |
+
text = f.read()
|
186 |
+
# Yields examples as (key, example) tuples
|
187 |
+
yield key, {
|
188 |
+
"config": self.config.name,
|
189 |
+
"file": name,
|
190 |
+
"text": text,
|
191 |
+
}
|
192 |
+
key += 1
|
stack-exchange/math_overflow.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5c025d143cf622c9682be5aa76a88221c3533c1137f4f9e3efda9cf3bad4e74a
|
3 |
+
size 39853728
|
stack-exchange/math_overflow/shard_0.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_1.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_10.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_11.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_12.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_13.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_14.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_15.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_16.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_17.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_18.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_19.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_2.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_20.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_21.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_22.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_23.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_24.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_25.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_26.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_27.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_3.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_4.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_5.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_6.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_7.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_8.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow/shard_9.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_overflow_val.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:d9bf78d099c45f902ea9375aa052c1f58a3d45b77df63c40245a177d65767cb8
|
3 |
+
size 2099468
|
stack-exchange/math_stack_exchange.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:dc0df42d217200fa0057dc08119c6f7cc5bd5db6fdb21f75c8389fb0b5ae9b0d
|
3 |
+
size 74963325
|
stack-exchange/math_stack_exchange/shard_0.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_1.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_10.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_100.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_101.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_102.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_103.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_104.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_105.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_106.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_107.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_108.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_109.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_11.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_110.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_111.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|
stack-exchange/math_stack_exchange/shard_112.txt
DELETED
The diff for this file is too large to render.
See raw diff
|
|