Portgas37 commited on
Commit
16530e7
·
1 Parent(s): 2346989

Add loading script and schema for RAG documents

Browse files
Files changed (2) hide show
  1. dataset.py +34 -0
  2. dataset_infos.json +14 -0
dataset.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import datasets
3
+
4
+ class MNLPDataset(datasets.GeneratorBasedBuilder):
5
+ def _info(self):
6
+ return datasets.DatasetInfo(
7
+ features=datasets.Features({
8
+ "id": datasets.Value("string"),
9
+ "title": datasets.Value("string"),
10
+ "text": datasets.Value("string"),
11
+ "source": datasets.Value("string"),
12
+ }),
13
+ description="RAG documents for MNLP",
14
+ )
15
+
16
+ def _split_generators(self, dl_manager):
17
+ path = dl_manager.download_and_extract("wiki_rag_subset_with_source.jsonl")
18
+ return [
19
+ datasets.SplitGenerator(
20
+ name=datasets.Split.TRAIN,
21
+ gen_kwargs={"filepath": path},
22
+ )
23
+ ]
24
+
25
+ def _generate_examples(self, filepath):
26
+ with open(filepath, encoding="utf-8") as f:
27
+ for i, line in enumerate(f):
28
+ data = json.loads(line)
29
+ yield i, {
30
+ "id": data.get("id", str(i)),
31
+ "title": data.get("title", ""),
32
+ "text": data.get("text", ""),
33
+ "source": data.get("source", ""),
34
+ }
dataset_infos.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "default": {
3
+ "description": "RAG documents for MNLP",
4
+ "features": {
5
+ "id": {"dtype": "string"},
6
+ "title": {"dtype": "string"},
7
+ "text": {"dtype": "string"},
8
+ "source": {"dtype": "string"}
9
+ },
10
+ "splits": {
11
+ "train": {"name": "train", "num_bytes": 0, "num_examples": 0}
12
+ }
13
+ }
14
+ }