Portgas37 commited on
Commit
7bfe660
·
1 Parent(s): 6f04b50

Add dataset loading script and dataset_infos.json for MNLP RAG evaluation

Browse files
Files changed (2) hide show
  1. dataset.py +3 -8
  2. dataset_infos.json +14 -6
dataset.py CHANGED
@@ -1,12 +1,10 @@
1
  import json
2
  import datasets
3
- import os
4
 
5
  class MNLPDataset(datasets.GeneratorBasedBuilder):
6
  def _info(self):
7
  return datasets.DatasetInfo(
8
  features=datasets.Features({
9
- "id": datasets.Value("string"),
10
  "title": datasets.Value("string"),
11
  "text": datasets.Value("string"),
12
  "source": datasets.Value("string"),
@@ -15,13 +13,11 @@ class MNLPDataset(datasets.GeneratorBasedBuilder):
15
  )
16
 
17
  def _split_generators(self, dl_manager):
18
- # download_and_extract gives directory path if it's just a .jsonl file
19
- data_dir = dl_manager.download_and_extract("wiki_rag_subset_with_source.jsonl")
20
- data_path = os.path.join(data_dir, "wiki_rag_subset_with_source.jsonl")
21
  return [
22
  datasets.SplitGenerator(
23
  name=datasets.Split.TRAIN,
24
- gen_kwargs={"filepath": data_path},
25
  )
26
  ]
27
 
@@ -30,8 +26,7 @@ class MNLPDataset(datasets.GeneratorBasedBuilder):
30
  for i, line in enumerate(f):
31
  data = json.loads(line)
32
  yield i, {
33
- "id": data.get("id", str(i)),
34
  "title": data.get("title", ""),
35
  "text": data.get("text", ""),
36
- "source": data.get("source", ""),
37
  }
 
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
  "title": datasets.Value("string"),
9
  "text": datasets.Value("string"),
10
  "source": datasets.Value("string"),
 
13
  )
14
 
15
  def _split_generators(self, dl_manager):
16
+ path = dl_manager.download_and_extract("wiki_rag_subset_with_source.jsonl")
 
 
17
  return [
18
  datasets.SplitGenerator(
19
  name=datasets.Split.TRAIN,
20
+ gen_kwargs={"filepath": path},
21
  )
22
  ]
23
 
 
26
  for i, line in enumerate(f):
27
  data = json.loads(line)
28
  yield i, {
 
29
  "title": data.get("title", ""),
30
  "text": data.get("text", ""),
31
+ "source": data.get("source", "wikipedia"),
32
  }
dataset_infos.json CHANGED
@@ -2,16 +2,24 @@
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": {
12
  "name": "train",
13
- "num_bytes": 1200000,
14
- "num_examples": 5000
15
  }
16
  }
17
  }
 
2
  "default": {
3
  "description": "RAG documents for MNLP",
4
  "features": {
5
+ "title": {
6
+ "_type": "Value",
7
+ "dtype": "string"
8
+ },
9
+ "text": {
10
+ "_type": "Value",
11
+ "dtype": "string"
12
+ },
13
+ "source": {
14
+ "_type": "Value",
15
+ "dtype": "string"
16
+ }
17
  },
18
  "splits": {
19
  "train": {
20
  "name": "train",
21
+ "num_bytes": 0,
22
+ "num_examples": 5000
23
  }
24
  }
25
  }