SpeedOfMagic commited on
Commit
988aeff
·
verified ·
1 Parent(s): 0e6dc0c

Update polygraph_xsum.py

Browse files
Files changed (1) hide show
  1. polygraph_xsum.py +7 -6
polygraph_xsum.py CHANGED
@@ -4,9 +4,6 @@ import json
4
 
5
  _DESCRIPTION = "lm-polygraph wrapper for xsum dataset"
6
 
7
- _LANGS = ["en"]
8
-
9
-
10
  _DATA_DIRECTORY = "."
11
  VERSION = datasets.Version("0.0.1")
12
 
@@ -15,17 +12,21 @@ _CONFIG = {
15
  "splits": ["train", "validation", "test"],
16
  "input_column": "document",
17
  "output_column": "summary",
 
18
  }
19
 
20
 
21
  def _prepare_dataset(dataset):
22
- return dataset[_CONFIG["input_column"]], dataset[_CONFIG["output_column"]]
 
 
 
 
23
 
24
 
25
  class PolygraphXsum(datasets.GeneratorBasedBuilder):
26
  """lm-polygraph wrapper for xsum dataset"""
27
 
28
-
29
  def _info(self):
30
  features = datasets.Features(
31
  {
@@ -69,5 +70,5 @@ class PolygraphXsum(datasets.GeneratorBasedBuilder):
69
 
70
  def _generate_examples(self, filepath):
71
  dataset = datasets.Dataset.load_from_disk(filepath)
72
- for i in range(len(item)):
73
  yield i, dataset[i]
 
4
 
5
  _DESCRIPTION = "lm-polygraph wrapper for xsum dataset"
6
 
 
 
 
7
  _DATA_DIRECTORY = "."
8
  VERSION = datasets.Version("0.0.1")
9
 
 
12
  "splits": ["train", "validation", "test"],
13
  "input_column": "document",
14
  "output_column": "summary",
15
+ "prompt": "Here's the text and it's short one-sentence summary.\n\nText:\n{text}\n\nSummary (one sentence):\n",
16
  }
17
 
18
 
19
  def _prepare_dataset(dataset):
20
+ x, y = dataset[_CONFIG["input_column"]], dataset[_CONFIG["output_column"]]
21
+ if _CONFIG.get("prompt"):
22
+ for i in range(len(x)):
23
+ x[i] = _CONFIG["prompt"].format(text=x[i])
24
+ return x, y
25
 
26
 
27
  class PolygraphXsum(datasets.GeneratorBasedBuilder):
28
  """lm-polygraph wrapper for xsum dataset"""
29
 
 
30
  def _info(self):
31
  features = datasets.Features(
32
  {
 
70
 
71
  def _generate_examples(self, filepath):
72
  dataset = datasets.Dataset.load_from_disk(filepath)
73
+ for i in range(len(dataset)):
74
  yield i, dataset[i]