Datasets:
Commit
•
4031401
1
Parent(s):
168eb4b
Add open serp script
Browse files- OpenSERP-v1.py +58 -0
OpenSERP-v1.py
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datasets import (
|
2 |
+
DatasetBuilder,
|
3 |
+
GeneratorBasedBuilder,
|
4 |
+
DatasetInfo,
|
5 |
+
Sequence,
|
6 |
+
Split,
|
7 |
+
SplitGenerator,
|
8 |
+
DownloadManager,
|
9 |
+
Features,
|
10 |
+
Value,
|
11 |
+
Version,
|
12 |
+
)
|
13 |
+
import os
|
14 |
+
|
15 |
+
|
16 |
+
_DESCRIPTION = """\
|
17 |
+
OpenSERP-v1 is a large dataset of over one billion embeddings designed to power a webscale information retrieval systems.
|
18 |
+
"""
|
19 |
+
|
20 |
+
|
21 |
+
class MyDataset(GeneratorBasedBuilder):
|
22 |
+
VERSION = Version("1.0.0")
|
23 |
+
|
24 |
+
def _info(self):
|
25 |
+
return DatasetInfo(
|
26 |
+
description=_DESCRIPTION,
|
27 |
+
# Specify dataset features here
|
28 |
+
features=Features(
|
29 |
+
{
|
30 |
+
"id": Value("string"),
|
31 |
+
"url": Value("string"),
|
32 |
+
"title": Value("string"),
|
33 |
+
"metadata": Value("string"),
|
34 |
+
"dataset": Value("string"),
|
35 |
+
"text_chunks": Sequence(Value("string")),
|
36 |
+
"embeddings": Sequence(Value("float")),
|
37 |
+
}
|
38 |
+
),
|
39 |
+
)
|
40 |
+
|
41 |
+
def _split_generators(self, dl_manager: DownloadManager):
|
42 |
+
# Define dataset splits and where to find them
|
43 |
+
return [
|
44 |
+
SplitGenerator(
|
45 |
+
name=Split.TRAIN,
|
46 |
+
gen_kwargs={"filepath": "arxiv"},
|
47 |
+
),
|
48 |
+
# Add other splits/folders as needed
|
49 |
+
]
|
50 |
+
|
51 |
+
def _generate_examples(self, filepath):
|
52 |
+
# Generate data examples from files
|
53 |
+
for filename in os.listdir(filepath):
|
54 |
+
file_path = os.path.join(filepath, filename)
|
55 |
+
with open(file_path, encoding="utf-8") as f:
|
56 |
+
data = f.read()
|
57 |
+
# Process and yield each example
|
58 |
+
yield filename, {"text": data}
|