CarlyChin parquet-converter commited on
Commit
d3ee5bf
·
0 Parent(s):

Duplicate from armanc/scientific_papers

Browse files

Co-authored-by: Parquet-converter (BOT) <parquet-converter@users.noreply.huggingface.co>

Files changed (3) hide show
  1. .gitattributes +27 -0
  2. README.md +252 -0
  3. scientific_papers.py +138 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - found
4
+ language:
5
+ - en
6
+ language_creators:
7
+ - found
8
+ license:
9
+ - unknown
10
+ multilinguality:
11
+ - monolingual
12
+ pretty_name: ScientificPapers
13
+ size_categories:
14
+ - 100K<n<1M
15
+ source_datasets:
16
+ - original
17
+ task_categories:
18
+ - summarization
19
+ task_ids: []
20
+ paperswithcode_id: null
21
+ tags:
22
+ - abstractive-summarization
23
+ dataset_info:
24
+ - config_name: arxiv
25
+ features:
26
+ - name: article
27
+ dtype: string
28
+ - name: abstract
29
+ dtype: string
30
+ - name: section_names
31
+ dtype: string
32
+ splits:
33
+ - name: train
34
+ num_bytes: 7148341992
35
+ num_examples: 203037
36
+ - name: validation
37
+ num_bytes: 217125524
38
+ num_examples: 6436
39
+ - name: test
40
+ num_bytes: 217514961
41
+ num_examples: 6440
42
+ download_size: 4504646347
43
+ dataset_size: 7582982477
44
+ - config_name: pubmed
45
+ features:
46
+ - name: article
47
+ dtype: string
48
+ - name: abstract
49
+ dtype: string
50
+ - name: section_names
51
+ dtype: string
52
+ splits:
53
+ - name: train
54
+ num_bytes: 2252027383
55
+ num_examples: 119924
56
+ - name: validation
57
+ num_bytes: 127403398
58
+ num_examples: 6633
59
+ - name: test
60
+ num_bytes: 127184448
61
+ num_examples: 6658
62
+ download_size: 4504646347
63
+ dataset_size: 2506615229
64
+ ---
65
+
66
+ # Dataset Card for "scientific_papers"
67
+
68
+ ## Table of Contents
69
+ - [Dataset Description](#dataset-description)
70
+ - [Dataset Summary](#dataset-summary)
71
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
72
+ - [Languages](#languages)
73
+ - [Dataset Structure](#dataset-structure)
74
+ - [Data Instances](#data-instances)
75
+ - [Data Fields](#data-fields)
76
+ - [Data Splits](#data-splits)
77
+ - [Dataset Creation](#dataset-creation)
78
+ - [Curation Rationale](#curation-rationale)
79
+ - [Source Data](#source-data)
80
+ - [Annotations](#annotations)
81
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
82
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
83
+ - [Social Impact of Dataset](#social-impact-of-dataset)
84
+ - [Discussion of Biases](#discussion-of-biases)
85
+ - [Other Known Limitations](#other-known-limitations)
86
+ - [Additional Information](#additional-information)
87
+ - [Dataset Curators](#dataset-curators)
88
+ - [Licensing Information](#licensing-information)
89
+ - [Citation Information](#citation-information)
90
+ - [Contributions](#contributions)
91
+
92
+ ## Dataset Description
93
+
94
+ - **Homepage:**
95
+ - **Repository:** https://github.com/armancohan/long-summarization
96
+ - **Paper:** [A Discourse-Aware Attention Model for Abstractive Summarization of Long Documents](https://arxiv.org/abs/1804.05685)
97
+ - **Point of Contact:** [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
98
+ - **Size of downloaded dataset files:** 9.01 GB
99
+ - **Size of the generated dataset:** 10.09 GB
100
+ - **Total amount of disk used:** 19.10 GB
101
+
102
+ ### Dataset Summary
103
+
104
+ Scientific papers datasets contains two sets of long and structured documents.
105
+ The datasets are obtained from ArXiv and PubMed OpenAccess repositories.
106
+
107
+ Both "arxiv" and "pubmed" have two features:
108
+ - article: the body of the document, paragraphs separated by "/n".
109
+ - abstract: the abstract of the document, paragraphs separated by "/n".
110
+ - section_names: titles of sections, separated by "/n".
111
+
112
+ ### Supported Tasks and Leaderboards
113
+
114
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
115
+
116
+ ### Languages
117
+
118
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
119
+
120
+ ## Dataset Structure
121
+
122
+ ### Data Instances
123
+
124
+ #### arxiv
125
+
126
+ - **Size of downloaded dataset files:** 4.50 GB
127
+ - **Size of the generated dataset:** 7.58 GB
128
+ - **Total amount of disk used:** 12.09 GB
129
+
130
+ An example of 'train' looks as follows.
131
+ ```
132
+ This example was too long and was cropped:
133
+
134
+ {
135
+ "abstract": "\" we have studied the leptonic decay @xmath0 , via the decay channel @xmath1 , using a sample of tagged @xmath2 decays collected...",
136
+ "article": "\"the leptonic decays of a charged pseudoscalar meson @xmath7 are processes of the type @xmath8 , where @xmath9 , @xmath10 , or @...",
137
+ "section_names": "[sec:introduction]introduction\n[sec:detector]data and the cleo- detector\n[sec:analysys]analysis method\n[sec:conclusion]summary"
138
+ }
139
+ ```
140
+
141
+ #### pubmed
142
+
143
+ - **Size of downloaded dataset files:** 4.50 GB
144
+ - **Size of the generated dataset:** 2.51 GB
145
+ - **Total amount of disk used:** 7.01 GB
146
+
147
+ An example of 'validation' looks as follows.
148
+ ```
149
+ This example was too long and was cropped:
150
+
151
+ {
152
+ "abstract": "\" background and aim : there is lack of substantial indian data on venous thromboembolism ( vte ) . \\n the aim of this study was...",
153
+ "article": "\"approximately , one - third of patients with symptomatic vte manifests pe , whereas two - thirds manifest dvt alone .\\nboth dvt...",
154
+ "section_names": "\"Introduction\\nSubjects and Methods\\nResults\\nDemographics and characteristics of venous thromboembolism patients\\nRisk factors ..."
155
+ }
156
+ ```
157
+
158
+ ### Data Fields
159
+
160
+ The data fields are the same among all splits.
161
+
162
+ #### arxiv
163
+ - `article`: a `string` feature.
164
+ - `abstract`: a `string` feature.
165
+ - `section_names`: a `string` feature.
166
+
167
+ #### pubmed
168
+ - `article`: a `string` feature.
169
+ - `abstract`: a `string` feature.
170
+ - `section_names`: a `string` feature.
171
+
172
+ ### Data Splits
173
+
174
+ | name |train |validation|test|
175
+ |------|-----:|---------:|---:|
176
+ |arxiv |203037| 6436|6440|
177
+ |pubmed|119924| 6633|6658|
178
+
179
+ ## Dataset Creation
180
+
181
+ ### Curation Rationale
182
+
183
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
184
+
185
+ ### Source Data
186
+
187
+ #### Initial Data Collection and Normalization
188
+
189
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
190
+
191
+ #### Who are the source language producers?
192
+
193
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
194
+
195
+ ### Annotations
196
+
197
+ #### Annotation process
198
+
199
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
200
+
201
+ #### Who are the annotators?
202
+
203
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
204
+
205
+ ### Personal and Sensitive Information
206
+
207
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
208
+
209
+ ## Considerations for Using the Data
210
+
211
+ ### Social Impact of Dataset
212
+
213
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
214
+
215
+ ### Discussion of Biases
216
+
217
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
218
+
219
+ ### Other Known Limitations
220
+
221
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
222
+
223
+ ## Additional Information
224
+
225
+ ### Dataset Curators
226
+
227
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
228
+
229
+ ### Licensing Information
230
+
231
+ [More Information Needed](https://github.com/huggingface/datasets/blob/master/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
232
+
233
+ ### Citation Information
234
+
235
+ ```
236
+ @article{Cohan_2018,
237
+ title={A Discourse-Aware Attention Model for Abstractive Summarization of
238
+ Long Documents},
239
+ url={http://dx.doi.org/10.18653/v1/n18-2097},
240
+ DOI={10.18653/v1/n18-2097},
241
+ journal={Proceedings of the 2018 Conference of the North American Chapter of
242
+ the Association for Computational Linguistics: Human Language
243
+ Technologies, Volume 2 (Short Papers)},
244
+ publisher={Association for Computational Linguistics},
245
+ author={Cohan, Arman and Dernoncourt, Franck and Kim, Doo Soon and Bui, Trung and Kim, Seokhwan and Chang, Walter and Goharian, Nazli},
246
+ year={2018}
247
+ }
248
+ ```
249
+
250
+ ### Contributions
251
+
252
+ Thanks to [@thomwolf](https://github.com/thomwolf), [@jplu](https://github.com/jplu), [@lewtun](https://github.com/lewtun), [@patrickvonplaten](https://github.com/patrickvonplaten) for adding this dataset.
scientific_papers.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # coding=utf-8
2
+ # Copyright 2020 The TensorFlow Datasets Authors and the HuggingFace Datasets Authors.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+ # Lint as: python3
17
+ """Scientific Papers Dataset."""
18
+
19
+
20
+ import json
21
+ import os
22
+
23
+ import datasets
24
+
25
+
26
+ _CITATION = """
27
+ @article{Cohan_2018,
28
+ title={A Discourse-Aware Attention Model for Abstractive Summarization of
29
+ Long Documents},
30
+ url={http://dx.doi.org/10.18653/v1/n18-2097},
31
+ DOI={10.18653/v1/n18-2097},
32
+ journal={Proceedings of the 2018 Conference of the North American Chapter of
33
+ the Association for Computational Linguistics: Human Language
34
+ Technologies, Volume 2 (Short Papers)},
35
+ publisher={Association for Computational Linguistics},
36
+ author={Cohan, Arman and Dernoncourt, Franck and Kim, Doo Soon and Bui, Trung and Kim, Seokhwan and Chang, Walter and Goharian, Nazli},
37
+ year={2018}
38
+ }
39
+ """
40
+
41
+ _DESCRIPTION = """
42
+ Scientific papers datasets contains two sets of long and structured documents.
43
+ The datasets are obtained from ArXiv and PubMed OpenAccess repositories.
44
+
45
+ Both "arxiv" and "pubmed" have two features:
46
+ - article: the body of the document, pagragraphs seperated by "/n".
47
+ - abstract: the abstract of the document, pagragraphs seperated by "/n".
48
+ - section_names: titles of sections, seperated by "/n".
49
+
50
+ """
51
+
52
+ _DOCUMENT = "article"
53
+ _SUMMARY = "abstract"
54
+
55
+ _URLS = {
56
+ "arxiv": "https://s3.amazonaws.com/datasets.huggingface.co/scientific_papers/1.1.1/arxiv-dataset.zip",
57
+ "pubmed": "https://s3.amazonaws.com/datasets.huggingface.co/scientific_papers/1.1.1/pubmed-dataset.zip",
58
+ }
59
+
60
+
61
+ class ScientificPapersConfig(datasets.BuilderConfig):
62
+ """BuilderConfig for Scientific Papers."""
63
+
64
+ def __init__(self, filename=None, **kwargs):
65
+ """BuilderConfig for ScientificPapers
66
+
67
+ Args:
68
+ filename: filename of different configs for the dataset.
69
+ **kwargs: keyword arguments forwarded to super.
70
+ """
71
+ # 1.1.0 remove sentence breaker <S> and </S> in summary.
72
+ super(ScientificPapersConfig, self).__init__(version=datasets.Version("1.1.1"), **kwargs)
73
+ self.filename = filename
74
+
75
+
76
+ class ScientificPapers(datasets.GeneratorBasedBuilder):
77
+ """Scientific Papers."""
78
+
79
+ BUILDER_CONFIGS = [
80
+ ScientificPapersConfig(name="pubmed", description="Documents from PubMed repository."),
81
+ ScientificPapersConfig(name="arxiv", description="Documents from ArXiv repository."),
82
+ ]
83
+
84
+ def _info(self):
85
+ return datasets.DatasetInfo(
86
+ description=_DESCRIPTION,
87
+ features=datasets.Features(
88
+ {
89
+ _DOCUMENT: datasets.Value("string"),
90
+ _SUMMARY: datasets.Value("string"),
91
+ "section_names": datasets.Value("string"),
92
+ }
93
+ ),
94
+ supervised_keys=None,
95
+ homepage="https://github.com/armancohan/long-summarization",
96
+ citation=_CITATION,
97
+ )
98
+
99
+ def _split_generators(self, dl_manager):
100
+ """Returns SplitGenerators."""
101
+ dl_paths = dl_manager.download_and_extract(_URLS)
102
+ path = os.path.join(dl_paths[self.config.name], self.config.name + "-dataset")
103
+ return [
104
+ datasets.SplitGenerator(
105
+ name=datasets.Split.TRAIN,
106
+ gen_kwargs={"path": os.path.join(path, "train.txt")},
107
+ ),
108
+ datasets.SplitGenerator(
109
+ name=datasets.Split.VALIDATION,
110
+ gen_kwargs={"path": os.path.join(path, "val.txt")},
111
+ ),
112
+ datasets.SplitGenerator(
113
+ name=datasets.Split.TEST,
114
+ gen_kwargs={"path": os.path.join(path, "test.txt")},
115
+ ),
116
+ ]
117
+
118
+ def _generate_examples(self, path=None):
119
+ """Yields examples."""
120
+ with open(path, encoding="utf-8") as f:
121
+ for line in f:
122
+ # Possible keys are:
123
+ # "article_id": str
124
+ # "article_text": list[str] article (list of paragraphs).
125
+ # "abstract_text": list[str], abstract (list of paragraphs).
126
+ # "section_names": list[str], list of section names.
127
+ # "sections": list[list[str]], list of sections (list of paragraphs)
128
+ d = json.loads(line)
129
+ summary = "\n".join(d["abstract_text"])
130
+ # In original paper, <S> and </S> are not used in vocab during training
131
+ # or during decoding.
132
+ # https://github.com/armancohan/long-summarization/blob/master/data.py#L27
133
+ summary = summary.replace("<S>", "").replace("</S>", "")
134
+ yield d["article_id"], {
135
+ _DOCUMENT: "\n".join(d["article_text"]),
136
+ _SUMMARY: summary,
137
+ "section_names": "\n".join(d["section_names"]),
138
+ }