yuyang commited on
Commit
c4baf1b
1 Parent(s): 232b771

update distil_cnndm.py

Browse files
Files changed (1) hide show
  1. distil_cnndm.py +23 -11
distil_cnndm.py CHANGED
@@ -18,8 +18,11 @@ There are two features:
18
  - highlights: joined text of highlights with <s> and </s> around each
19
  highlight, which is the target summary
20
 
21
- The distilled data is obtained by running facebook/bart-large-cnn on the
22
- training dataset. The files used here is directly downloaded from
 
 
 
23
  https://github.com/huggingface/transformers/blob/main/examples/research_projects/seq2seq-distillation/precomputed_pseudo_labels.md.
24
  """
25
 
@@ -47,18 +50,18 @@ _SUPPORTED_VERSIONS = [
47
  _DEFAULT_VERSION = datasets.Version("2.0.0", "Using cased version.")
48
 
49
 
50
- class DistillCNNDMConfig(datasets.BuilderConfig):
51
- """BuilderConfig for DistillCNNDM."""
52
 
53
  def __init__(self, **kwargs):
54
  super().__init__(**kwargs)
55
 
56
 
57
- class DistillCNNDM(datasets.GeneratorBasedBuilder):
58
  """Distilled CNN/DailyMail non-anonymized summarization dataset."""
59
 
60
  BUILDER_CONFIGS = [
61
- DistillCNNDMConfig(name=str(version), description="Plain text", version=version)
62
  for version in _SUPPORTED_VERSIONS
63
  ]
64
 
@@ -83,17 +86,21 @@ class DistillCNNDM(datasets.GeneratorBasedBuilder):
83
 
84
  Although dl_manager is not used, we still need to keep it.
85
  """
86
- dl_paths = dl_manager.download(_DL_URLS)
87
  if self.config.version == "1.0.0":
 
88
  return [
89
  datasets.SplitGenerator(
90
  name=split,
91
  gen_kwargs={
92
  "src_path": os.path.join(
93
- dl_paths["cnn_bart_pl"], f"{_SPLIT_MAP[split]}.source"
 
 
94
  ),
95
  "tgt_path": os.path.join(
96
- dl_paths["cnn_bart_pl"], f"{_SPLIT_MAP[split]}.target"
 
 
97
  ),
98
  "num_examples": _NUM_EXAMPLES[_SPLIT_MAP[split]],
99
  },
@@ -105,15 +112,20 @@ class DistillCNNDM(datasets.GeneratorBasedBuilder):
105
  ]
106
  ]
107
  elif self.config.version == "2.0.0":
 
108
  return [
109
  datasets.SplitGenerator(
110
  name=datasets.Split.TRAIN,
111
  gen_kwargs={
112
  "src_path": os.path.join(
113
- dl_paths["cnn_pegasus_pl"], "train.source"
 
 
114
  ),
115
  "tgt_path": os.path.join(
116
- dl_paths["cnn_pegasus_pl"], "train.target"
 
 
117
  ),
118
  "num_examples": 287112,
119
  },
 
18
  - highlights: joined text of highlights with <s> and </s> around each
19
  highlight, which is the target summary
20
 
21
+ The pseudo labels are generated by running
22
+ 1. facebook/bart-large-cnn on the CNN/DailyMail dataset, or
23
+ 2. sshleifer/pegasus-cnn-ft-v2 on the CNN/DailyMail dataset.
24
+
25
+ The files used here is directly downloaded from
26
  https://github.com/huggingface/transformers/blob/main/examples/research_projects/seq2seq-distillation/precomputed_pseudo_labels.md.
27
  """
28
 
 
50
  _DEFAULT_VERSION = datasets.Version("2.0.0", "Using cased version.")
51
 
52
 
53
+ class DistilCNNDMConfig(datasets.BuilderConfig):
54
+ """BuilderConfig for DistilCNNDM."""
55
 
56
  def __init__(self, **kwargs):
57
  super().__init__(**kwargs)
58
 
59
 
60
+ class DistilCNNDM(datasets.GeneratorBasedBuilder):
61
  """Distilled CNN/DailyMail non-anonymized summarization dataset."""
62
 
63
  BUILDER_CONFIGS = [
64
+ DistilCNNDMConfig(name=str(version), description="Plain text", version=version)
65
  for version in _SUPPORTED_VERSIONS
66
  ]
67
 
 
86
 
87
  Although dl_manager is not used, we still need to keep it.
88
  """
 
89
  if self.config.version == "1.0.0":
90
+ extracted_path = dl_manager.download_and_extract(_DL_URLS["cnn_bart_pl"])
91
  return [
92
  datasets.SplitGenerator(
93
  name=split,
94
  gen_kwargs={
95
  "src_path": os.path.join(
96
+ extracted_path,
97
+ "cnn_bart_pl",
98
+ f"{_SPLIT_MAP[split]}.source",
99
  ),
100
  "tgt_path": os.path.join(
101
+ extracted_path,
102
+ "cnn_bart_pl",
103
+ f"{_SPLIT_MAP[split]}.target",
104
  ),
105
  "num_examples": _NUM_EXAMPLES[_SPLIT_MAP[split]],
106
  },
 
112
  ]
113
  ]
114
  elif self.config.version == "2.0.0":
115
+ extracted_path = dl_manager.download_and_extract(_DL_URLS["cnn_pegasus_pl"])
116
  return [
117
  datasets.SplitGenerator(
118
  name=datasets.Split.TRAIN,
119
  gen_kwargs={
120
  "src_path": os.path.join(
121
+ extracted_path,
122
+ "pegasus_cnn_cnn_pls",
123
+ "train.source",
124
  ),
125
  "tgt_path": os.path.join(
126
+ extracted_path,
127
+ "pegasus_cnn_cnn_pls",
128
+ "train.target",
129
  ),
130
  "num_examples": 287112,
131
  },